[antlr-interest] Problem using += operator in actions
Terence Parr
parrt at cs.usfca.edu
Thu Apr 19 18:54:18 PDT 2007
Hi Martin,
This has been fixed. Added a slew of unit tests. It will magically
appear in next build when I push. I am *almost* satisfied that my
new AST rewrite implementation correct. Soon as I add yet more unit
tests for this stuff I'll push.
Thanks for the impetus to fix this annoying bug. It now binds +=
tighter than + and * loops etc...
Ter
On Apr 17, 2007, at 6:00 AM, Martin Fowler wrote:
> This is another one of those problems I ended up solving myself but
> I post here to help others.
>
> I wanted to collect together some words using the += operator. I
> used a grammar line like this:
>
> item : 'item' w += WORD+ ';'
> {System.out.println("name is: " + $w);}
> ;
>
> The problem was that $w ended up being null.
>
> My mistake was that the phrase w+=WORD needed to be contained in
> parentheses before applying the +, like so:
>
> item : 'item' (w += WORD)+ ';'
> {System.out.println("name is: " + $w);}
> ;
>
>
> --
> Martin Fowler
> http://martinfowler.com
More information about the antlr-interest
mailing list