[racket] Developing a Recursive Descent Parser in Racket

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Thu Oct 24 00:25:18 EDT 2013

On 2013-10-23 23:15:28 -0500, Gregory Gelfond wrote:
>    I would like to develop a simple compiler for a declarative language in
>    Racket (as a personal project), and am at a bit of a loss as to how to
>    proceed with respect to how to process text in Racket. What is the
>    standard means of reading a sequence of string (or characters) from a
>    file?

Depending on how you plan to process the input, there are several
functions you can choose from. Most of them are documented here:
  http://docs.racket-lang.org/reference/Byte_and_String_Input.html

In particular, you may want to look at `read-line`, `read-string`,
`port->string`. These functions are generic over ports (you'll probably
want to make an input file port using `open-input-file`).

>    Also, I'm coming from Python, and was wondering if there was anything
>    similar to the LEPL library available for Racket. The basic idea is that
>    the library provides a syntax similar to EBNF syntax allowing me to
>    declare the grammar, and then generates a parser for me, whose function
>    interface is defined by the nonterminal symbols of the grammar.

Danny Yoo's "ragg" library might be what you're looking for:
  http://hashcollision.org/ragg/

Cheers,
Asumu

Posted on the users mailing list.