#!/bin/zsh

# assumes zsh and java is installed (openjdk-11-jdk works)
# download antlr-4.13.1-complete.jar from https://github.com/antlr/website-antlr4/tree/gh-pages/download ant put in /usr/local/lib/
# change directory to this folder and run ./generate.sh
rm -r query_autogenerated/*.cc
rm -r update_autogenerated/*.cc
java -Xmx500M -cp "/usr/local/lib/antlr-4.13.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=Cpp SparqlQueryLexer.g4 -o query_autogenerated -no-listener -visitor
java -Xmx500M -cp "/usr/local/lib/antlr-4.13.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=Cpp SparqlQueryParser.g4 -o query_autogenerated -no-listener -visitor

java -Xmx500M -cp "/usr/local/lib/antlr-4.13.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=Cpp SparqlUpdateLexer.g4 -o update_autogenerated -no-listener -visitor
java -Xmx500M -cp "/usr/local/lib/antlr-4.13.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=Cpp SparqlUpdateParser.g4 -o update_autogenerated -no-listener -visitor

autoload zmv
zmv 'query_autogenerated/(*).cpp' query_autogenerated/'$1.cc'
zmv 'update_autogenerated/(*).cpp' update_autogenerated/'$1.cc'
