[antlr-interest] Clarification on Attribute Reference in Actions

Gavin Lambert antlr at mirality.co.nz
Thu Jul 5 04:40:32 PDT 2007


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.



More information about the antlr-interest mailing list