Linux, OpenSource, Programming And Hacks

Mar 28, 2016

How to Install Antlr4 in Ubuntu/Linux

Mar 28, 2016

Antlr is a parser generator written in Java.

Execute these commands to download atlr .jar file in /usr/local/lib directory

cd /usr/local/lib
curl -O

add antlr4 to your class path.

export CLASSPATH=".:/usr/local/lib/antlr-4.5-complete.jar:$CLASSPATH"

create alias

alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.5-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
alias grun='java org.antlr.v4.runtime.misc.TestRig'
Test installation

java org.antlr.v4.Tool

ANTLR Parser Generator  Version 4.5
 -o ___              specify output directory where all output is generated
 -lib ___            specify location of grammars, tokens files
 -atn                generate rule augmented transition network diagrams

The above 3 commands (one export and two alias commands) needs to be run every time you start a new terminal. To solve this problem put the three commands in your .bashrc file like shown below.

Open the.bashrc file in any text editor
gedit ~/.bashrc

and add the three commands at the bottom of the file, Like shown in the image below

Note: bashrc is a script file that automatically executes whenever a new terminal is opened.

No comments:

Post a Comment