[antlr-interest] Faster expression parsing

Gavin Lambert antlr at mirality.co.nz
Thu Aug 28 13:20:59 PDT 2008


At 06:07 29/08/2008, Terence Parr wrote:
 >Note that you can improve the speed slightly when you are 
grammar
 >by removing unnecessary tree stuff.
 >
 >> primary_expression
 >>         :       INTEGER
 >>                 -> ^(INTEGER)
 >>         |       '(' expression ')'
 >>                 -> expression
 >>         ;
 >
 >primary_expression
 >         :       INTEGER
 >         |       '(' expression ')' -> expression
 >         ;

If the second one is faster than the first, does that mean that 
the below would be faster than the second?  Or are they 
equivalent?

primary_expression
     :    INTEGER
     |    '('! expression ')'!
     ;



More information about the antlr-interest mailing list