[antlr-interest] multiplicity in TreeParser
Rusty Burchfield
GICodeWarrior+antlr at gmail.com
Tue Feb 26 18:17:56 PST 2008
Olivier Lefevre wrote:
> Assuming a Java target, something along these lines should work:
>
> example returns [List list]
> @init { list = new ArrayList(); }
> : ^( TOKEN (x1=OBJ1 {list.add(x1);})+ (x2=OBJ2 {list.add(x2);})+ )
> ;
>
> In other words if you want a list I think in a tree grammar context
> you have to build it yourself because the x1 etc "collections" are
> not held in collections but in trees. This is different from the
> expression grammar context. Or did I misunderstand the question?
Looks like exactly what I need. :)
Thank you!
Rusty Burchfield
More information about the antlr-interest
mailing list