build AST in antlr4
问题 I was wondering whether we could build an AST using Antlr version 4. I couldn't find any reference on building it using antlr4. One SO answer says that it would be easy to use antlr4 which produces only parse tree but my question is what about the efficiency ? It forces us to crawl whole parse tree instead of an abstract syntax tree which is not efficient way to walk through the whole tree and perform task using visitors. 回答1: There are two key items I'd like to point out first: Efficiency