[antlr-interest] Tree Blocks,

Craig Main craig at palantir.co.za
Mon Aug 8 04:09:22 PDT 2005



It is quite common practice to introduce a virtual root node into a tree to
allow predicates and other constructs to work properly.

For instance:


   #( TOK_IF expr ( statement )* ( TOK_ELSE ( statement )* )? ) With this:

   #( TOK_IF expr #(BLOCK (statement)* ) ( #(BLOCK (statement)* ) ) )? )


Is there any good documentation on this practice?

I am a little unsure of the how's and whyfore's of this construct. Is there
some good documentation on the #BLOCK thing and how and what exactly is
meant by 


{#block = #([BLOCK, "block"], #block);}


I don't' really understand it, even though I am using it.

Does the above statement always introduce a virtual parent root node?


I have been told to make the change above to allow syntactic predicates to
work correctly on the if and else part of the statement, which makes sense.
I would just like to understand it better.







-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050808/691cc5b8/attachment-0001.html

More information about the antlr-interest mailing list