-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebuild_parsers.sh
executable file
·23 lines (18 loc) · 1.16 KB
/
rebuild_parsers.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# current openqasm commit: 429781bb9c95ef15944861f306ac6b9e4ff0abf0
# This script rebuilds the parsers from the source g4 files. Use for
# development when making changes to the grammar.
if [ ! -f "antlr-4.11.1-complete.jar" ]; then
curl -O https://www.antlr.org/download/antlr-4.11.1-complete.jar
fi
cp antlr-4.11.1-complete.jar /usr/local/lib/antlr-4.11.1-complete.jar
export CLASSPATH=".:/usr/local/lib/antlr-4.11.1-complete.jar:$CLASSPATH"
alias antlr4='java -Xmx500M -cp "/usr/local/lib/antlr-4.11.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
alias grun='java -Xmx500M -cp "/usr/local/lib/antlr-4.11.1-complete.jar:$CLASSPATH" org.antlr.v4.gui.TestRig'
cd src/braket/default_simulator/openqasm/parser || exit
antlr4 -Dlanguage=Python3 -visitor BraketPragmasLexer.g4 BraketPragmasParser.g4 -o generated
antlr4 -Dlanguage=Python3 -visitor qasm3Lexer.g4 qasm3Parser.g4 -o generated
cd generated || exit
rm BraketPragmasParser.interp BraketPragmasParser.tokens BraketPragmasLexer.interp \
BraketPragmasLexer.tokens BraketPragmasParserListener.py qasm3Lexer.interp \
qasm3Lexer.tokens qasm3Parser.interp qasm3Parser.tokens qasm3ParserListener.py
cd ../../../../../.. || exit