[antlr-interest] Using labels in actions of a tree parser
Foust
javafoust at gmail.com
Wed Aug 13 13:38:35 PDT 2008
> missing attribute access on rule scope: t
You cannot print the node, but must access its fields (attributes translated
by Antlr). Try:
$t.text
Brent
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Oliver B. Fischer
> Sent: Wednesday, August 13, 2008 7:28 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Using labels in actions of a tree parser
>
> Dear all,
>
> I would like to use labels in the actions of my tree parser to have an
> alternative way to access the tree nodes. Unfortunately ANTLR reports
> an
> error I can't understand.
>
> Here is my action definition:
>
>
> term returns [DataType rt]
> : factor { $rt = $factor.rt; }
> -> template(f={$factor.st})"<f>"
> | ^(ASTERISK t1=term t2=term)
> | ^(SLASH t1=term t2=term)
> | ^(AND t=term term)
> { System.out.println($t); }
> ;
>
> And this is the error:
>
> ANTLR Parser Generator Version 3.0.1 (August 13, 2007) 1989-2007
> error(117):
> C:\javaproj\c1compiler.trunk\build\gensrc\de\fischer\c1compiler\antlr\C
> 1Tree.g:243:5:
> missing attribute access on rule scope: t
>
> My someone of you can explain the reason for this error to me?
>
> BYe
>
> Oliver
>
More information about the antlr-interest
mailing list