ANTLR Parse tree modification
问题 I'm using ANTLR4 to create a parse tree for my grammar, what I want to do is modify certain nodes in the tree. This will include removing certain nodes and inserting new ones. The purpose behind this is optimization for the language I am writing. I have yet to find a solution to this problem. What would be the best way to go about this? 回答1: While there is currently no real support or tools for tree rewriting, it is very possible to do. It's not even that painful. The ParseTreeListener or