[antlr-interest] Returns name

Ian Moor iwm at doc.ic.ac.uk
Wed Feb 27 07:57:22 PST 2008


 I have a rule in  tree grammar:
expr returns [ Register result ] :
	result=binary
	| result=unary ;
where binary and unary also return registers.

Antlr says 
  "label result conflicts with rule expr's return value or parameter with same name"

  I am working round this by writing
  expr  returns  [Register result  ] 
   @after{result=res;}
     : res = binaryexpr 
     | res = unaryexpr

which seems to work. Shouldn't the first case work as well ?
     Ian W Moor                    Department of Computing,
iwm at doc.ic.ac.uk           Imperial College.
                                    180 Queensgate
                                     London SW7 2AZ UK.
  



More information about the antlr-interest mailing list