javapythonpython-2.7antlrantlr4

How to install antlr4?


I read a lot in the antlr4 doc on github and I kind of understood how it works. The thing is I am not a pro java coder, I am trying to use antlr4 with python.

Anyway I reached a deadend on the step to execute this

antlr4 -Dlanguage=Python2 Hello.g4

I downloaded the antlr4 complete.jar but I don't know how to setup or use it. so any help?


Solution

  • I found the -jar paramater easiest to use, so my command line (in a batch file) looks so:

    set LOCATION=antlr4-4.5.4-SNAPSHOT.jar
    java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
    

    taken from the C++ ANTLR runtime demo. You don't need to change your classpath, nor have to add any environment variables (or doskeys).