[antlr-interest] ab? b?a

Gavin Lambert antlr at mirality.co.nz
Fri Jun 27 19:13:09 PDT 2008


Mere moments ago, I wrote:
 >fragment POSTPROMOTE: '+';
 >
 >PREPROMOTE
 >   : ( '+' (' '|'\t'|'\r'|'\n'|EOF) ) => '+' { $type =
 >POSTPROMOTE; }
 >   | '+'
 >   ;

Actually, riffing on my other post:  another way to write this 
(which is a little more complicated in the grammar, but should 
produce slightly cleaner target code):

fragment POSTPROMOTE: '+';

PREPROMOTE
   : '+'
     ( (' '|'\t'|'\r'|'\n'|EOF) => /*epsilon*/ { $type = 
POSTPROMOTE; } )?
   ;



More information about the antlr-interest mailing list