[antlr-interest] AST generation in a recursive rule

Arnar Birgisson arnarb at oddi.is
Fri Oct 24 01:44:02 PDT 2003


Hi there

> - Is ## shorthand for #<rulename>?  

Yup..

- Won't using the imaginary token build a tree like:

> CATCH_BLOCK-->CATCH_BLOCK-->(another CATCH_BLOCK, etc.)
>    |
> CATCH
>    |
>    v
> Exception1--(right)-->e1--(right)-->block--(right)-->null
> 
> Is there any way to use the CATCH token in the same manner as the
CATCH_BLOCK imaginary token and in effect, remove the extra node?  

Monty's solution builds a tree like this:

CATCH_BLOCK
  |
CATCH ----> CATCH ----> CATCH ----> ...
  |
Exception1 -> e1 -> block -> null

The CATCH_BLOCK pseudo-token is just a handle to the multiple
catch-nodes, so that your try-catch-finally tree will have constant
size:

try
 |
block - CATCH_BLOCK - finally_block

Arnar


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list