[antlr-interest] Syntax for token accumulation
Gavin Lambert
antlr at mirality.co.nz
Thu Mar 20 19:16:18 PDT 2008
At 13:55 21/03/2008, Olivier Lefevre wrote:
>Assume ID is a valid lexer token. (list+=ID)* works as you'd
expect
>but (list+=(tok=ID))* does not, although it compiles: when the
rule
>exits the list in question is null. I had a look at the Java
code
>and the list is indeed not even initialized. Even merely
>parenthesizing ID as in: ((list+=(ID))* gives the same null
result.
>It would be useful for this syntax to be supported, though. Is
it
>indeed an ANTLR limitation?
Yes (for the moment anyway).
But you can extract it to a subrule and then it will work:
a : (list+=b)* { ... };
b : tok=ID { ... };
More information about the antlr-interest
mailing list