[antlr-interest] Problem with keeping data associated with AST nodes in antlr transform mode

Jogchem de Groot r.e.j.degroot at student.utwente.nl
Tue Jun 15 05:30:25 PDT 2004


Good afternoon,

I'm working on a translater using ANTLR which uses several
transformation phases (implemented
as tree walkers). Frequently i'd like to associate data with AST nodes
in the transformation phases
which can be used in later phases.

The problem is that data i associate with some AST does keep associated
with the equivalent AST nodes
in the resulting transformed AST. I looked a little into the problem at
it seems to me that ANTLR
generates AST generation code which constructs the new AST just after
the nodes have been matched.
So even though you can create your own initialize() methode in your own
AST node class, which can copy
all extended data fields from an existing AST node in a new AST node,
this wont have any effect as
updates done the old AST node will not be reflected in the new AST node.

For example:

#(b:blah) { b.setData(data); }

This will associate 'data' with the old AST node (b), but not with the
newly generated equivalent AST node for
the transformed tree, because that AST node has been constructed before
the 'b.setData(..)' code has executed.

Is there anyway to get around this problem?

Thanks in advance!

Regards,
    Jogchem






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list