0

Right now, we have code that translates from one AST tree to their own tree. I would prefer to get rid of this second tree(it is hard enough to understand one tree, let alone two when you join a project as trees are complex as it is). One of the reasons for this is stuff was looked up on the tree walk.

I am wondering instead if during the tree walk, I could somehow add state to CommonTree that has the lookup information?

What I would like to see is something like this

CommonTree tree = parent.getChildren().get(0);
tree.setState(myMapOrObjectState);

This allows me to attach state to some nodes where it is needed before I pass to plugins. Right now, I have this ugly recreate the whole tree and wrrap the AST tree :(.

thanks, Dean

Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
  • Not quite sure what you're trying to do (asking for). Can you elaborate (a bit)? – Bart Kiers Jul 09 '12 at 09:22
  • 1
    In your previous question, http://stackoverflow.com/questions/11364723/antlr-is-there-any-way-to-generate-the-visitor-codegeneric-visitor, I answered how you can use your own AST. When doing so, you can use this custom AST to set a state during parsing. – Bart Kiers Jul 09 '12 at 15:52
  • godd point, I didn't go down that route yet, lots to learning still to do I guess – Dean Hiller Jul 10 '12 at 00:07

0 Answers0