[antlr-interest] Clarification on Attribute Reference in Actions
Kay Roepke
kroepke at classdump.org
Thu Jul 5 06:14:08 PDT 2007
On Jul 5, 2007, at 1:40 PM, Gavin Lambert wrote:
> At 11:22 5/07/2007, Kay Roepke wrote:
> >term returns [Term t]
> > : ^(ComplexTerm term termSequence)
> > {
> > Object o = asObject($term.t);
> > }
> > ;
> [...]
> >Notice how it references retval.t in my version. I think
> >this is a bug in the actionparser code. It should warn
> >you that $term.t will refer to the rule's return
> >value and not the subtree reference's retval object.
>
> I don't know, the current behaviour makes a certain amount of sense
> to me. If the action block was inside the parentheses, though, I'd
> definitely expect it to refer to the recursive term, and not the
> parent rule.
Definitely. What I was proposing was that it merely warns you of the
ambiguity, it should still pick the return value. However, if you
meant the rule reference `term` ANTLR should tell you what to do.
It was only about the warning, not about changing the behavior.
cheers,
-k
--
Kay Röpke
http://classdump.org/
More information about the antlr-interest
mailing list