[antlr-interest] Repeating Tree Nodes, help.

Raphael Reitzig r_reitzi at cs.uni-kl.de
Thu Jul 24 00:49:23 PDT 2008


Hi Craig!

Fallback Hack: Declare your own AST node class with a list attribute.

But I think there was a way to iterate children in ANTLR, just can't remember.

Regards

Raphael

craig at palantir.co.za wrote (Thu Jul 24 07:36:03 2008):

> Hi,
>
> I know this probably a very elementary question, but I have tried quite a few
> combinations. I have a working template grammar that I am trying to  
> convert to
> using trees.
>
> I have a production that looks like this:
> rule: ROOT id+=IDENTIFIER (SEP id+=IDENTIFIER)+
>       -> ^(ROOT $id)
>
> I want to match something in the tree, and get out all the identifier(s) in a
> list.
>
> In the tree I have
> rule: ^(ROOT xn+=IDENTIFIER+)
>
> I only manage to ever get one identifer out. The above is a list  
> with one token.
> I don't really want to make a tree root with each identifer because  
> then getting
> them out into a list is a mission.
>
> What should I do?
>
> Thanks
> Regards
> Craig.
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
>



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


More information about the antlr-interest mailing list