4 # Created 2016, Mike Lischke (public domain)
6 # This script is used to generate source files from the test grammars in the same folder. The generated files are placed
7 # into a subfolder "generated" which the demo project uses to compile a demo binary.
9 # There are 2 ways of running the ANTLR generator here.
11 # 1) Running from jar. Use the given jar (or replace it by another one you built or downloaded) for generation.
12 #LOCATION=antlr4-4.5.4-SNAPSHOT.jar
13 #java -jar $LOCATION -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
14 #java -jar $LOCATION -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
15 #java -jar $LOCATION -Dlanguage=Java -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
17 # 2) Running from class path. This requires that you have both antlr3 and antlr4 compiled. In this scenario no installation
18 # is needed. You just compile the java class files (using "mvn compile" in both the antlr4 and the antlr3 root folders).
19 # The script then runs the generation using these class files, by specifying them on the classpath.
20 # Also the string template jar is needed. Adjust CLASSPATH if you have stored the jar in a different folder as this script assumes.
21 # Furthermore is assumed that the antlr3 folder is located side-by-side with the antlr4 folder. Adjust CLASSPATH if not.
22 # This approach is especially useful if you are working on a target stg file, as it doesn't require to regenerate the
23 # antlr jar over and over again.
24 CLASSPATH=../../../tool/resources/:ST-4.0.8.jar:../../../tool/target/classes:../../../runtime/Java/target/classes:../../../../antlr3/runtime/Java/target/classes
26 java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
27 #java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
28 #java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Java -listener -visitor -o generated/ TLexer.g4 TParser.g4