[antlr-interest] assign optional rule values into a list
Austin Hastings
Austin_Hastings at Yahoo.com
Tue Oct 9 06:13:39 PDT 2007
Maybe try it without spaces around the '+=' operator?
I've got something similar that seems to work in my own grammar:
expr_l00_sequence
: seq+=expr_l01_assignment (Pc seq+=expr_l01_assignment)*
-> ^(SEQUENCE $seq+)
;
=Austin
OJAY78 at gmx.de wrote:
> Hi,
>
> I have a rule in my grammar which can contain one parameter or more than one seperated by '|' sign. Now I have the problem that I want to add those parameters into a list.
>
> I tried it with the += but this does not work, when I look into the generated code I can see that there will be generated a list, but it will be not filled
>
> infiniteParameterList returns[List lst]
> : ps += parameter ('|' parameter) *
> {
> }
> ;
> Then I tried this variant, but this will result in a grammar syntax failure
> infiniteParameterList returns[List lst]
> : ps += parameter ('|' ps+=parameter) *
> {
> }
> ;
>
> Does anyone can tell me how I can make this assignment?
>
> Thanks
>
More information about the antlr-interest
mailing list