[antlr-interest] labels for rule results?
Torsten Curdt
tcurdt at vafer.org
Sun Aug 24 04:19:53 PDT 2008
Hey Gavin,
Thanks for the answer. But that wasn't what I was trying to ask. :)
attributeDeclaration
: thetype=type_specifier name=Identifier ';'
{
System.out.println("name:" + name.getText());
System.out.println("type:" + thetype);
}
;
"thetype" is problem. There is no problem with "name".
cheers
--
Torsten
On Aug 24, 2008, at 08:33, Gavin Lambert wrote:
> At 15:24 24/08/2008, Torsten Curdt wrote:
> >attributeDeclaration
> > : type_specifier name=Identifier ';'
> > {
> > System.out.println("name:" + name.getText());
> > }
> > ;
> >
> >The above works just fine. But what's the easiest way to access
> >the result of the rules?
>
> Depends on what you mean by the "result".
>
> If you just want the text, you can use $name.text.
> If you want the return value of the rule (assuming you've defined
> one), you can use $name.valuename (whatever it happens to be --
> there can even be more than one).
>
> There's a number of other possibilities. They're listed in the wiki.
>
More information about the antlr-interest
mailing list