[antlr-interest] Null variable value for tree grammar rule variables

Matthieu Riou matthieu.riou at gmail.com
Wed Feb 27 16:09:57 PST 2008


Hi,

I have a tree grammar with the following rule:

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.

Now if I take the generated class and add myself the variables assignment in
the assign() method corresponding to that rule like so:

lv=(Tree)input.LT(1);
rv=(Tree)input.LT(1);

It just works perfectly.

As a side note if I omit the parentheses around the assigned rule names
(like ASSIGN lv=path_expr rv=rvalue) the generated class doesn't compile at
all as the variables are declared with:

        void lv=null;
        void rv=null;

Bug or known limitation?

Thanks!
Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080227/a0bae65e/attachment.html 


More information about the antlr-interest mailing list