arcadio wrote:
> I've asked the following question in the ANTLR mailing list, with no
> luck. Since it's quite Ruby-centric, perhaps someone here knows the
> answer, given the popularity of ANTLR.
> 
> I'm in the process of migrating a YACC grammar to ANTLR.
> 
> However, since the rest of the project is written in Ruby, I'd like to
> generate the ANTLR code in Ruby, if possible.

Have you tried just adding the required options section below your grammar
statement? It just worked for me, though the generated code is a little
quirky. The Ruby generator has been a standard part of ANTLR for years.

options {
        language = Ruby;
        output = AST;
}

I found that ANTLR was very poor at reporting situations for which it
couldn't generate correct code (or rather, the designer has a strange
idea of "correct"), and in particular the lexing behaviour is very
non-intuitive. I was attempting a very difficult grammar that needs
LL(*) behaviour, and as I know now, needs to handle lexing using parse
rules (no lexer at all). After some unhelpful arguments, I gave up and
implemented my grammar using Treetop. Terribly slow, but powerful and
simple to use, once you get the hang of PEG parsing.

Clifford Heath.