"Wayne Blair" <wayne.blair / relian.com> wrote:

>Does anyone have any experience with javacc?  I've been playing with it and
>it doesn't seem _too_ brutal.  Anyway, if you do:

Well, last weekend, I spend some time evaluating quite a few different
parser generators.  My motivation was (of course) to find a tool that
would help creating a Ruby parser in Java :-)

I nice collection of different parsers can be found here.  I'll post
the google-cache link as it seems that the original site is down right
now:
http://www.google.com/search?q=cache:seXdT50Yzq4:www.first.gmd.de/cogent/catalog/java.html+compiler+construction+java&hl=en


I wasn't really successful.  Most parsers, including javacc are LL(1)
or LL(k) parsers.  Unfortunately, Ruby can't be expressed as LL(k)
grammar, so these parsers aren't powerful enough to be used without
modification.

I checked out javacc and antlr and found both difficult to use and
strange in their syntax.  I also tried sablecc which is nice as it's I
think the only one that can generate type safe parse trees (so called
AST) which is a really nice feature.  Unfortunately, it's again only
LL(k), it has again a different syntax for its grammar and I had a
hard time to even make it run some trivial examples.  All you get as
documentation (or I overlooked something) is a somewhat dated master
thesis.  COCO/R is a nice LL(1) parser generator (and I fixed two
bugs) but I stopped trying to hack the parser to make it parse Ruby.

I think, you has to use at least an LALR(k) parser, BYACC or CUP for
example.  Unfortunately, Ruby isn't also LALR(k), not even LR(k) or
any context free grammar.  But you can work around these problems
using a custom lexer and some special built production rules.  At
least, Matz succeeded in using YACC to create a parser.

Also interesting seems to be JACCIE, a parser construction IDE written
in Java.  I'll probably look at it next weekend.  It's pased on a
Smalltalk system which I also tried - and which eventually told me
that Ruby isn't context free.  It can apply a larger set of different
parser engines on a grammar.

bye
-- 
Stefan Matthias Aust \/ Truth Until Paradox