ANTLR ANTLR Targets/Language Runtimes Language Support


ANTLR is capable of generating parsers for a number of programming languages:

  1. C# Target
  2. Python Target
  3. JavaScript Target
  4. Java Target

By default ANTLR will generate a parser from commandline in the Java programming language :

Java -jar antlr-4.5.3-complete.jar yourGrammar.g4 //Will output a
    java parser

To change the target language you can run the following command from the OS terminal/commandline:

    antlr4 -Dlanguage=Python3 yourGrammar.g4 
//with alias
    java -jar antlr-4.5.3-complete.jar -Dlanguage=Python3 yourGrammar.g4 
//without alias

Rather than use the '-Dlanguage' parameter on the commandline/terminal each time to build your desired parser for a specific language you can select the target from within your .g4 grammar file by including the target within the global section:

options {
    language  = "CSharp";
options {

To use the generated parser output make sure you have the ANTLR runtime for the specified language :

  1. CSharp runtime
  2. Python 2 runtime
  3. python 3 runtime

Full instructions and information on ANTLR run-times libraries