[antlr-interest] Root node transformation

Bryan Ewbank ewbank at gmail.com
Tue Jun 21 05:19:04 PDT 2005


On 6/20/05, Paul Johnson <gt54-antlr at cyconix.com> asked:
> Should this be ## = #(B,C,D), rather than ## = #B?

There's only need for "## = #B;" because the default construction of
#B is to replicate what's already there - i.e., #(B, C, D).  If you
have default construction disabled for this rule, then yes, you need
to build it explicitly.

On 6/20/05, Paul Johnson <gt54-antlr at cyconix.com> again asked:
> And can you use labels here:
> #(A
>    b:#(B,C,D) {## = #b; }
>    ...
> ?

Yes, you can use labels, but they need to be associated with tokens or
productions, not #() blocks -- at least, I've never tried that.

So, instead of:
   #(A b:#(B C D) ) { ## = #b; }  // doesn't compile, AFAIK

Use this:
   #(A #(b:B C D) ) { ## = #b; }  // here, #b is #(B C D) by construction


More information about the antlr-interest mailing list