[antlr-interest] how to get hold of individual nodes in a tree parser
Jim Idle
jimi at temporal-wave.com
Tue Feb 26 16:49:07 PST 2008
Can't you just do:
name : ^(NAME (n=name_literal {Console.writeln($n.text);} )+)
Jim
> -----Original Message-----
> From: Benjamin Shropshire [mailto:shro8822 at vandals.uidaho.edu]
> Sent: Tuesday, February 26, 2008 4:49 PM
> To: Antlr Interest
> Subject: Re: [antlr-interest] how to get hold of individual nodes in a
> tree parser
>
> Benjamin Shropshire wrote:
> > I have a tree grammar with a rule like this:
> >
> > name : ^(NAME name_literal+) { ; }
> >
> > I need to do a foreach over the name_literal nodes but I can't seem
> to
> > find anywhere in the manual that inserts action rules for repeated
> > nodes in a tree parser. Anyone known how to do this?
> >
> I'm still stumped
>
> Looking at the generated code it looks like the parsed subtrees are
> discarded (or if I refer to name_literal all but the last one is). Is
> this the the planned behavior?
>
> It seems that "look for a list of foo's and then let me at them" is
> common enough that there would be some special way to make it easy.
> Something like "$name_literal.List". Is this not the case?
>
> Am I approaching this wrong? I want to do stuff with the list of
> name_literals. Working with each name_literal by it's self is useless
> to me.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Jim Idle.vcf
Type: text/x-vcard
Size: 1863 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080226/0d7c8e1a/attachment.vcf
More information about the antlr-interest
mailing list