aboutsummaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh37
1 files changed, 26 insertions, 11 deletions
diff --git a/build.sh b/build.sh
index ac98b68..0e73e1e 100755
--- a/build.sh
+++ b/build.sh
@@ -1,22 +1,30 @@
-#!/bin/sh
+#!/bin/sh
-set -xe
+set -e
+
+function log
+{
+ >&2 echo "-> $@"
+ "$@"
+}
function cc
{
mkdir -p bin
- gcc -Wall -Wextra -Wpedantic -I. -g $2 $1.c -o bin/$(basename $1)
+ [ -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
- gcc -Wall -Wextra -Wpedantic -I. -shared -fPIC $2 $1.c -o bin/$(basename $1).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
{
- 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 lexer -D_LEXER_STANDALONE
@@ -25,7 +33,7 @@ function leak
# cc util-tables -D_UTIL_TABLES_STANDALONE
# cc slr-table -D_SLR_TABLE_STANDALONE
# cc clr-table -D_CLR_TABLE_STANDALONE
-# cc clr-table "-D_CLR_TABLE_STANDALONE -D_LAZY_LALR"
+# cc clr-table "-D_CLR_TABLE_STANDALONE -D_LAZY_LALR" lalr-table
# cc lr-parser -D_LR_PARSER_STANDALONE
# cc demos/instant-parser
@@ -36,14 +44,21 @@ function leak
# leak util-tables
# leak slr-table
# leak clr-table
+# leak lalr-table
# leak lr-parser
# leak instant-parser
#--------------------------------------------------------------------------------------------------#
-cc demos/generate-parser
-shared demos/sample-files/defs
+cc demos/generate-parser "-rdynamic"
+
+shared demos/sample-files/lalr-defs
+shared demos/sample-files/arithmetic-defs
+
+shared slr-table
+shared clr-table
+shared clr-table -D_LAZY_LALR lalr-table
-leak "generate-parser bin/defs.so" > bin/generated.c
-cc demos/sample-files/parser-skeleton # this includes bin/generated.c
-leak parser-skeleton "0-1+(1+0)-1+0"
+leak "generate-parser -t slr-table bin/arithmetic-defs.so" > bin/generated.c
+cc demos/sample-files/parser-skeleton "" parser # this includes bin/generated.c
+leak parser "0-1+(1+0)-1+0"