[antlr-interest] Returns name
Bertalan Fodor (LilyPondTool)
lilypondtool at organum.hu
Wed Feb 27 08:04:29 PST 2008
I think you wanted to write
expr returns [ Register result ] :
binary { result = $binary.result; }
| unary { result = $unary.result; }
Return values are always set in actions.
result=binary
assigns the label 'result' to the result of binary rule, so using that
you should have written:
res=binary { result = $res.value; }
Bert
Ian Moor wrote:
> 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.
>
>
>
>
--
LilyPondTool is the editor for LilyPond files.
See http://lilypondtool.organum.hu
More information about the antlr-interest
mailing list