-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-grammar.sh
executable file
·27 lines (25 loc) · 1.03 KB
/
build-grammar.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# build custom peg grammar
if [ "generated/custom-peg.mjs" -ot "custom-peg.pegjs" ]; then
echo "Building custom PEG grammar..."
peggy -o generated/custom-peg.mjs --format es custom-peg.pegjs
node grammar-preprocessor.mjs grammar.custom.pegjs generated/grammar.out.pegjs
else
echo "No need to rebuild custom PEG grammar"
# convert custom peg to pegjs
if [ "generated/grammar.out.pegjs" -ot "grammar.custom.pegjs" ]; then
echo "Preprocessing append grammar..."
node grammar-preprocessor.mjs grammar.custom.pegjs generated/grammar.out.pegjs
else
echo "No need to preprocess append grammar"
fi
fi
# build append grammar
if [ "generated/grammar.out.mjs" -ot "generated/grammar.out.pegjs" ]; then
echo "Building append grammar..."
peggy -o generated/grammar.out.mjs -d tree:../tree.mjs --format es generated/grammar.out.pegjs
# import all tree
perl -i -pe 's|import tree from|import * as tree from|' generated/grammar.out.mjs
else
echo "No need to build append grammar"
fi
echo "Done."