[antlr-interest] ".tree" attribute produces a compiler error

Stephen Kou stephen at hyarros.com
Thu Nov 11 15:34:35 PST 2010


Hi Everyone,

I'm trying to make a tree parser with ANTLR 3.2, and using the '.tree' 
attribute on a rule produces a compiler error:

The rule:
modifiers returns [Modifiers modifier]
   :
   (mod = modifier+)
   {
     $modifier = new Modifiers($mod.tree);
   }
   ;

The offending line of Java code produced:
modifier = new Modifiers((mod != null ? ((CommonTree)mod.tree) : null ));
--> "tree cannot be resolved or is not a field"

I have modify it manually from .tree to .getTree() for the Java to 
compile, there's no field called 'tree'.

Is this a bug, or am I doing something wrong?

Thanks,
Stephen


More information about the antlr-interest mailing list