[racket-dev] Working on Ragg. Suggestions?

From: Danny Yoo (dyoo at hashcollision.org)
Date: Tue Jan 1 17:59:28 EST 2013

Hi everyone,

I've been working on a parsing framework with the design goal to be
easy to use.  I'm calling it "ragg": Racket AST Generator Generator.
(It used to be called 'autogrammar', but that was too much of a
mouthful. Thanks to Joe Politz for the new name!)


The current source code uses PLaneT2 conventions:

    https://github.com/dyoo/ragg

The beginnings of its documentation can be read here:

    http://hashcollision.org/ragg/


Major features:

* Ragg provides a #lang for writing extended BNF grammars.  Modules
written in #lang ragg automatically generate a parser.  It tries to
follow HTDP doctrine, for the structure of the grammar informs the
structure of the parser's output: the generated parsers produces
native Racket syntax objects in the same shape as the rules.

The documentation link above shows a trivial example, and I'll put
more substantive examples and uses in:

    https://github.com/dyoo/ragg/blob/master/ragg/examples
    https://github.com/dyoo/ragg/blob/master/ragg/test

(Note: the Python parser example works!  It's basically a copy and
paste of the one in the original Python source tree.)

* The language uses an uppercase convention to determine if a
production is a terminal token or not.  Tokens can optionally provide
location, and the generated syntax objects will have source location
if the tokens do.

* Ragg should work on ambiguous grammars.  I'm using a parser based
(hilariously enough) on the cfg-parser from the algol60 collection,
rather than the more finicky LALR parser in parser-tools/yacc.

---

I need to polish ragg.  I'm going to get most of the test cases, error
traps, and documentation done by the end of this week.  I would really
like some comments and suggestions before I release this on PLaneT2,
because I do want this to be useful to other people.  In my view, the
big thing missing is a story about lexers, which I don't quite know
what to do yet, and if anyone has ideas, I'd love to hear them.

Other work: I don't know if cfg-parser has been optimized yet.  I'll
have to investigate that.


Hope this helps!

Posted on the dev mailing list.