ANTLR is capable of generating parsers for a number of programming languages:
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";
}
//or
options {
language="Python";
}
To use the generated parser output make sure you have the ANTLR runtime for the specified language :
Full instructions and information on ANTLR run-times libraries