In Squirrel away the trees, call on the visitors Terence describes how you can add actions without putting them into the grammar file. This really sounds like a cool idea, but sometimes you might want to have an AST. What I would like to see is support from ANTLR 4 to generate heterogeneous, non normalized trees.
Example of syntax for that - based on syntax for homogeneous tree construction:
You would then have to supply matching AST classes:
... and walk them using whichever technique you like - no need for further ANTLR support here.
Labels: