-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add scripts to generate cypher parser
- Loading branch information
1 parent
2d50c42
commit 147926a
Showing
8 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Antlr4 Parser | ||
To generate antlr4 parser, simply run `./generate_grammar.sh` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
// Generated from src/antlr4/Cypher.g4 by ANTLR 4.9 | ||
// Generated from Cypher.g4 by ANTLR 4.9 | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
// Generated from src/antlr4/Cypher.g4 by ANTLR 4.9 | ||
// Generated from Cypher.g4 by ANTLR 4.9 | ||
|
||
#pragma once | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
// Generated from src/antlr4/Cypher.g4 by ANTLR 4.9 | ||
// Generated from Cypher.g4 by ANTLR 4.9 | ||
|
||
#pragma once | ||
|
||
|