[antlr-interest] rules with parameters are not equivalent to rules without parameters

John B. Brodie jbb at acm.org
Tue Oct 10 06:56:46 PDT 2006


>( {a = a_sub();} | {b = b_sub();} ) COL c SEMIC {//do sth};;
>
>a_sub returns [String a] : a { a = "AAA"; /*alt. get it from token*/};
>b_sub returns [String b] : b { b =" BBB"; /*alt. get it from token*/};

do not bury the reference to a_sub (| b_sub) in actions - remove the {}'s

body : { String a=null; String b=null; }
   ( a=a_sub | b=b_sub ) COL c SEMIC {/*do something*/};

Hope this helps...
   -jbb


More information about the antlr-interest mailing list