[antlr-interest] Null variable value for tree grammar rule variables
Gavin Lambert
antlr at mirality.co.nz
Thu Feb 28 02:41:35 PST 2008
At 13:09 28/02/2008, Matthieu Riou wrote:
>assign : ^(ASSIGN lv=(path_expr) rv=(rvalue)) {
>builder.build(OAssign.class, $BPELScope::oscope,
>$Parent::activity, $lv, $rv); };
>
>In the above method call both $lv and $rv are null. When I check
>the generated class the two local variables lv and rv are
>properly defined but never assigned to. Note that I've only
>observed this behavior when the variables are set as being the
>tree resulting from a subrule, not for a plain token.
This rings a bell. I think if you remove the parentheses, the
problem should go away. ie. change the rule to this:
assign : ^(ASSIGN lv=path_expr rv=rvalue) {
builder.build(OAssign.class, $BPELScope::oscope,
$Parent::activity, $lv, $rv); };
The problem is that anything in parentheses is a block, and you
can't assign a name to a block, only to a single rule/token.
More information about the antlr-interest
mailing list