一、安装Antlr https://github.com/antlr/antlr4/blob/master/doc/getting-started.md
- 安装 Java (version 1.7 or higher)
- 下载Antlr
-
$ cd /usr/local/lib $ curl -O https://www.antlr.org/download/antlr-4.10.1-complete.jar
或者官网下载:https://www.antlr.org/download.html 并将其放在 /usr/local/lib目录
- 添加 antlr-4.10.1-complete.jar 到CLASSPATH环境变量:
-
$ export CLASSPATH="$CLASSPATH:/usr/local/lib/antlr-4.10.1-complete.jar"
也可以将其放在.bash_profile 或启动脚本中
- 为ANTLR Tool和TestRig创建别名
-
$ alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.10.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool' $ alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.10.1-complete.jar:$CLASSPATH" org.antlr.v4.gui.TestRig'
二、安装C++运行时库 https://github.com/antlr/antlr4/tree/master/runtime/Cpp
-
cd antlr4-cpp-runtime-4
-
mkdir build && mkdir run && cd build
-
cmake ..
-
make
-
make install DESTDIR=../run