[antlr-interest] translating a tree to another tree
Philippe Faes
ph_reader at faes.net
Sun Feb 10 02:39:31 PST 2008
Dear all,
I would like to translate an AST, generated with ANTLR to another AST. This
is usefull for having layers of intermediate representations, each new layer
more abstract than the previous.
I tried using a treewalker and setting output=AST, but this gives two
problems.
First, I need to set ASTLabelType=Token so that the TreeAdaptor can take
Tokens as input. This is not what I want, since the tree being walked
constists of Tree nodes.
Second, the generated code tries to read retval.stop on objects of
TreeRuleReturnScope, but these objects only have a "start" field. The "stop"
field is found in ParserRuleReturnScope, but the tree walker uses
TreeRuleReturnScope instead.
Am I doing something wrong? Is the generation of new trees from old trees
not supported in ANTLR? If not: Why? It seems like a natural thing to try.
kind regards
Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080210/3edd39a1/attachment.html
More information about the antlr-interest
mailing list