diff --git a/.gitignore b/.gitignore index 4b7196f0ca..a7765abb4d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,9 @@ __pycache__/ *$py.class cmake-build-debug/ test/unittest_temp/ + +# antlr4 jar +scripts/antlr4/antlr4.jar + +# macOS +.DS_Store diff --git a/README.md b/README.md index 1d9a182cee..a9e9007dde 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Kùzu is being actively developed at University of Waterloo as a feature-rich an ## Build To build from source code, Kùzu requires Cmake(>=3.11), Python 3, and a compiler that supports `C++20`. - Perform a full clean build without tests and benchmark: - - `make clean && make` + - `make clean && make release` - Perform a full clean build with tests and benchmark (optional): - `make clean && make all` - Run tests (optional): diff --git a/scripts/antlr4/README.md b/scripts/antlr4/README.md new file mode 100644 index 0000000000..847789b4ee --- /dev/null +++ b/scripts/antlr4/README.md @@ -0,0 +1,2 @@ +# Antlr4 Parser +To generate antlr4 parser, simply run `./generate_grammar.sh` \ No newline at end of file diff --git a/scripts/antlr4/generate_grammar.sh b/scripts/antlr4/generate_grammar.sh new file mode 100755 index 0000000000..a11a1509bb --- /dev/null +++ b/scripts/antlr4/generate_grammar.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# the root directory of the project +ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../" >/dev/null 2>&1 && pwd )" + +# download antlr4.jar if not exists +if [ ! -e antlr4.jar ] +then + echo "Downloading antlr4.jar" + curl --url 'https://www.antlr.org/download/antlr-4.9-complete.jar'\ + --output './antlr4.jar' +fi + +# create the directory for the generated grammar +mkdir -p ./generated + +# move grammar file to current directory +cp $ROOT_DIR/src/antlr4/Cypher.g4 ./Cypher.g4 + +# generate grammar +java -jar antlr4.jar -Dlanguage=Cpp -no-visitor -no-listener Cypher.g4 -o ./generated + +# rename include path +sed 's/#include "CypherLexer.h"/#include "cypher_lexer.h"/g' ./generated/CypherLexer.cpp > ./generated/cypher_lexer.cpp +sed 's/#include "CypherParser.h"/#include "cypher_parser.h"/g' ./generated/CypherParser.cpp > ./generated/cypher_parser.cpp +mv ./generated/CypherLexer.h ./generated/cypher_lexer.h +mv ./generated/CypherParser.h ./generated/cypher_parser.h + +# move generated files to the right place +mv ./generated/cypher_lexer.h $ROOT_DIR/third_party/antlr4_cypher/include/cypher_lexer.h +mv ./generated/cypher_lexer.cpp $ROOT_DIR/third_party/antlr4_cypher/cypher_lexer.cpp +mv ./generated/cypher_parser.h $ROOT_DIR/third_party/antlr4_cypher/include/cypher_parser.h +mv ./generated/cypher_parser.cpp $ROOT_DIR/third_party/antlr4_cypher/cypher_parser.cpp + +# remove the generated directory +rm -rf ./generated + +# remove the grammar file +rm ./Cypher.g4 diff --git a/third_party/antlr4_cypher/cypher_lexer.cpp b/third_party/antlr4_cypher/cypher_lexer.cpp index 9113d94609..6548273081 100644 --- a/third_party/antlr4_cypher/cypher_lexer.cpp +++ b/third_party/antlr4_cypher/cypher_lexer.cpp @@ -1,5 +1,5 @@ -// Generated from src/antlr4/Cypher.g4 by ANTLR 4.9 +// Generated from Cypher.g4 by ANTLR 4.9 #include "cypher_lexer.h" diff --git a/third_party/antlr4_cypher/cypher_parser.cpp b/third_party/antlr4_cypher/cypher_parser.cpp index 981a4ce844..50af943b09 100644 --- a/third_party/antlr4_cypher/cypher_parser.cpp +++ b/third_party/antlr4_cypher/cypher_parser.cpp @@ -1,5 +1,5 @@ -// Generated from src/antlr4/Cypher.g4 by ANTLR 4.9 +// Generated from Cypher.g4 by ANTLR 4.9 diff --git a/third_party/antlr4_cypher/include/cypher_lexer.h b/third_party/antlr4_cypher/include/cypher_lexer.h index f00d6d022d..8742f643e5 100644 --- a/third_party/antlr4_cypher/include/cypher_lexer.h +++ b/third_party/antlr4_cypher/include/cypher_lexer.h @@ -1,5 +1,5 @@ -// Generated from src/antlr4/Cypher.g4 by ANTLR 4.9 +// Generated from Cypher.g4 by ANTLR 4.9 #pragma once diff --git a/third_party/antlr4_cypher/include/cypher_parser.h b/third_party/antlr4_cypher/include/cypher_parser.h index 5e5cd81a28..e33fd10fdd 100644 --- a/third_party/antlr4_cypher/include/cypher_parser.h +++ b/third_party/antlr4_cypher/include/cypher_parser.h @@ -1,5 +1,5 @@ -// Generated from src/antlr4/Cypher.g4 by ANTLR 4.9 +// Generated from Cypher.g4 by ANTLR 4.9 #pragma once