aboutsummaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorkartofen <kartofen.mail.0@protonmail.com>2025-07-20 01:32:24 +0300
committerkartofen <kartofen.mail.0@protonmail.com>2025-07-20 01:32:24 +0300
commit34357640c0676f33ad13aac1fe28effc6f6e47c7 (patch)
treed656ee61da7d7a0b133aa57311266653ef100569 /build.sh
parent174e9b35ce3b6e99e500907f1bb24c6f31f481bf (diff)
start of grammar parsing
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh28
1 files changed, 18 insertions, 10 deletions
diff --git a/build.sh b/build.sh
index aa0c308..1fe06a9 100755
--- a/build.sh
+++ b/build.sh
@@ -4,27 +4,27 @@ set -e
function log
{
- >&2 echo "-> $@"
+ echo "-> $@"
"$@"
}
function cc
{
mkdir -p bin
- [ -n "$3" ] && NAME=$3 || NAME=$(basename $1)
- log gcc -Wall -Wextra -Wpedantic -I. -g $2 $1.c -o "bin/$NAME"
+ [ -n "$3" ] && NAME="$3" || NAME=$(basename "$1")
+ log gcc -Wall -Wextra -Wpedantic -I. -g $2 "$1.c" -o "bin/$NAME"
}
function shared
{
mkdir -p bin
- [ -n "$3" ] && NAME=$3 || NAME=$(basename $1)
- log gcc -Wall -Wextra -Wpedantic -I. -g -shared -fPIC $2 $1.c -o "bin/$NAME.so"
+ [ -n "$3" ] && NAME="$3" || NAME=$(basename "$1")
+ log gcc -Wall -Wextra -Wpedantic -I. -g -shared -fPIC $2 "$1.c" -o "bin/$NAME.so"
}
function leak
{
- log valgrind --leak-check=full --show-leak-kinds=all -s bin/$1 "$2"
+ log valgrind --leak-check=full --show-leak-kinds=all -s bin/"$1" $2
}
# cc util/dict -D_DICT_STANDALONE
@@ -67,7 +67,15 @@ shared clr-table -D_LAZY_LALR lalr-table
shared demos/sample-files/lalr-defs
# --- Calc example ---
-shared demos/sample-files/calc-defs
-leak "generate-parser -t lalr-table bin/calc-defs.so"
-cc demos/sample-files/calc-skeleton "" parser
-leak parser "13*10+9 - (54*(10+8))"
+# shared demos/sample-files/calc-defs
+# leak generate-parser "-o bin/calc -t lalr-table bin/calc-defs.so"
+# cc demos/sample-files/calc-skeleton "" parser
+# leak parser "13*10+9 - (54*(10+8))" # wrong answer
+# leak parser "-13 + 20"
+# leak parser "1 > 52 ? 2 + 3 : 53"
+
+# --- Grammar Definitino example ---
+shared demos/sample-files/gram-defs
+leak generate-parser "-o bin/gram -t lalr-table bin/gram-defs.so"
+cc demos/sample-files/gram-skeleton "" parser
+leak parser