Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
ANTLR
1. ANTLR

ANTLR is a DSL for processing grammars.
ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It's widely used to build languages, tools, and frameworks. From a grammar, ANTLR generates a parser that can build and walk parse trees. From the ANTLR web site at
https://www.antlr.org/ .
This documentation on ANTLR is not ready yet. Do not try anything here until it is ready.
2. CentOS installation
The following Linux command(s) install ANTLR.
sudo yum -y install antlr-tool
3. Installed version
The following Linux command(s) verify the installed version of ANTLR.
antlr -v
On
2019-08-04 the output was as follows.
ANTLR Parser Generator Version 2.7.7 (2006-11-01) 1989-2005
error: no grammar file specified
Note that ANTLR has no version command, but displays the version if an input grammar file is not provided.
4. Hello world in ANTLR
The file type of a
ANTLR program file is
g4.
The following Linux command(s) create/edit a hello program in the your home directory using the nano text editor.
nano ~/hello.g4
Create the following program text in the editor that will output the text "Hello world"
// define a grammar called Hello
grammar Hello;
r : 'hello' ID;
ID : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;
To exit with save, remember to press
Ctrl-X, then "
y" (for yes) and
Enter to exit.
The following Linux command(s) run the program.
antlr ~/hello.antlr
The output should be as follows.
Hello world
5. End of page