From 34357640c0676f33ad13aac1fe28effc6f6e47c7 Mon Sep 17 00:00:00 2001 From: kartofen Date: Sun, 20 Jul 2025 01:32:24 +0300 Subject: start of grammar parsing --- build.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'build.sh') 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 -- cgit v1.2.3