I\'ve found a sample template in the ANTLR website, its the Javatreeparser.g, which the site says could produce the AST that I need, but since I\'m new to ANTLR, how do I ma
I really recommend you to use antlr4.
First, set your CLASSPATH (including antlr-4.5.3-complete.jar) and JAVA_HOME.
Second, generate a lexer and parser from the grammar Java.g4:
java -cp antlr-4.5.2-complete.jar Java.g4
Third, compile all Java*.java genereated:
javac Java*.java
Finally, run TestRig:
java org.antlr.v4.runtime.misc.TestRig Java compilationUnit -gui Test.java
You will see AST visually as follows: