简体   繁体   中英

AST Parser tree ANTLR4

After making these with: java org.antlr.v4.Tool -visitor -lib scanner/ parser/Decaf.g, that instruction generated(DecafParserBaseListener.java, DecafParserBaseVisitor.java, DecafParserListener.java, DecafParserVisitor.java). Our question is how to use this methods to make the AST?

Short: It's not available (yet) in Antlr4. It was available in Antlr3, but dropped in the releases of Antlr4 so far. Afaik it may be included in further releases.

You have to use the parse tree and visitor/listener to do your tasks or generate an AST "manually".

From my own experience - if you create/organize your parser rules in an efficient way - it's not such a big advantage to start from an AST compared to starting from a parse tree.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM