[antlr-interest] AST generation in a recursive rule
Jeff Vincent
JVincent at Novell.Com
Fri Oct 24 08:24:32 PDT 2003
Ah! I didn't notice initially that the statment ## = #(#CATCH_BLOCK,
##); was *outside* the ( ... )+ expression.
Also, it seems that AST.toStringList() and AST.toStringTree() output
the exact same thing. Why is that?
Thanks for the input.
>>> arnarb at oddi.is 10/24/2003 2:44:02 AM >>>
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/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20031024/f2663620/attachment.html
More information about the antlr-interest
mailing list