[antlr-interest] Rule-local variables?
Vaclav Barta
vbar at comp.cz
Tue Jul 3 04:42:18 PDT 2007
Johannes Luber wrote:
> Scopes are using stacks, so your concern is unfounded. Usually you don't
> need to access the other slots of the stack, so it does look like using
> a single variable.
Fine by me... A related question: is it better to say
subExpression returns [ Expression value ] :
{ $value = new Expression(); }
( o = unaryOperator { $value.Operator = $o.value; } )? (
...
or
subExpression returns [ Expression value ]
@init { $value = new Expression(); } :
( o = unaryOperator { $value.Operator = $o.value; } )? (
...
Both seem to work...
Bye
Vasek
More information about the antlr-interest
mailing list