$ cd /usr/local/lib $ sudo curl -O https://www.antlr.org/download/antlr-4.7.2-complete.jar $ export CLASSPATH=".:/usr/local/lib/antlr-4.7.2-complete.jar:$CLASSPATH" $ alias antlr4='java -jar /usr/local/lib/antlr-4.7.2-complete.jar' $ alias grun='java org.antlr.v4.gui.TestRig'
$ lein run <grammar> <arg>*
-
input file example
$ lein run labeled-expr data/t.expr 193 17 9
-
STDIN example
$ lein run labeled-expr (2+3)*4 <Enter> <Ctrl-D or Ctrl-Z> 20
-
expr
(4.1 Matching an Arithmetic Expression Language)Generating lexers and parsers# in src/java/grammar/expr folder $ antlr4 -package grammar.expr Expr.g4
Running an example$ lein run expr data/t.expr
-
labeled-expr
(4.2 Building a Calculator Using a Visitor)Generating lexers and parsers# in src/java/grammar/labeledexpr folder $ antlr4 -package grammar.labeledexpr -no-listener -visitor LabeledExpr.g4
Running an example$ lein run labeled-expr data/t.expr
-
java
(4.3 Building a Translator with a Listener)Generating lexers and parsers# in src/java/grammar/java folder $ antlr4 -package grammar.java Java.g4
Running an example$ lein run java data/Demo.java
-
rows
(4.4 Making Things Happen During the Parse)Generating lexers and parsers# in src/java/grammar/rows folder $ antlr4 -package grammar.rows -no-listener Rows.g4
Running an example$ lein run rows data/t.rows
-
serial-id
(4.5 Cool Lexical Features)Generating lexers and parsers# in src/java/grammar/java folder $ antlr4 -package grammar.java Java.g4
Running an example$ lein run serial-id data/Demo.java