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?
0
votes
1 Answers
0
votes
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.