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

Matthieu Riou matthieu.riou at gmail.com
Thu Feb 28 10:06:56 PST 2008


But as I mentioned, when I remove the parentheses, the generated variables
declarations look like:

        void lv=null;
        void rv=null;

And the Java compiler doesn't really like it...

Thanks,
Matthieu

On Thu, Feb 28, 2008 at 2:41 AM, Gavin Lambert <antlr at mirality.co.nz> wrote:

> 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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080228/4089d75f/attachment-0001.html 


More information about the antlr-interest mailing list