ANTLR4 Notes based on "The Definitive ANTLR4 Reference" Book.
Download ANTLR.jar
and put it in the lib folder.
Create antlr.bat
file and put the following code.
java -cp .;.\lib\antlr4.jar org.antlr.v4.Tool %*
Create grun.bat
file and put the following code.
java -cp .\lib\antlr4.jar org.antlr.v4.gui.TestRig %*
Follow steps on how to install antlr4.
> antlr <FileName>.g4 -o out/
> javac .\out\*.java
> cd out
> grun <GrammarName> <Rule> -tokens ../<FileName>.txt
Example for Hello
:
> grun Hello r -tokens ../Hello.txt
> cd out
> grun <GrammarName> <Rule> -tree ../<FileName>.txt
Example for Hello
:
> grun Hello r -tree ../Hello.txt
> cd out
> grun <GrammarName> <Rule> -gui ../<FileName>.txt
Example for Hello
:
> grun Hello r -gui ../Hello.txt