[antlr-interest] Using labels in actions of a tree parser

Oliver B. Fischer o.b.fischer at gmx.de
Wed Aug 13 07:27:50 PDT 2008


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\C1Tree.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