[antlr-interest] ANTLR3 Crash when building template output (tree grammar)

David Holroyd dave at badgers-in-foil.co.uk
Wed Mar 21 16:10:34 PDT 2007

On Wed, Mar 21, 2007 at 02:46:15PM -0400, Kailey Joanette wrote:
> My question then. would this be equivalent (at least this compiles):
> equalityExpression
>     :   i1=instanceOfExpression ( (o1='==' | o2='!=') i2=instanceOfExpression )* 
>                 -> ^(EXPRESSION_EQUALITY $i1 ($o1? $o2? $i2)*)
>                 ;

I think that will overwrite the vars each time around the (..)* and the
rewrite will only see the last values; probably not what you want.

Also, it unconditionally creates EXPRESSION_EQUALITY nodes in the AST
even if no (in)equality operators are present in the input.

If your not too determined to get exactly the structure above, this
might be better (untested):

      :    instanceOfExpression (equalityOperator^ instanceOfExpression)

      :    (o='==' | o='!=')
           -> EXPRESSION_EQUALITY[$o]



More information about the antlr-interest mailing list