[antlr-interest] Simple grammar with error

Gavin Lambert antlr at mirality.co.nz
Sun Sep 16 00:34:15 PDT 2007


At 10:12 16/09/2007, Cédric Berger wrote:
 >Alfonso wrote:
 >
 >> PLUS     : '+';
 >> MINUS    : '-';
 >> DIVIDE  : '/';
 >> ASTERISK : '*';
 >>
 >> OPEN_PAREN : '(' ;
 >> CLOSE_PAREN: ')' ;
 >
 >I keep wondering why people do that...
 >Is that just to obfuscate the grammar and make it less readable
 >or is there a real rationale here?

I prefer this style:

tokens {
   PLUS = '+';
   MINUS = '-';
}

... but it's basically the same thing.  It does 
make the grammar itself a little longer, but it 
gives nice names to the generated tokens instead 
of things like "T46", which is helpful.



More information about the antlr-interest mailing list