#!/bin/sh set -e function log { 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" } 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" } function leak { log valgrind --leak-check=full --show-leak-kinds=all -s bin/"$1" $2 } # cc util/dict -D_DICT_STANDALONE # leak dict # cc demos/lexer util/dict.c # leak lexer # cc recursive/recursive-ascent # leak recursive-ascent # cc recursive/recursive-ascent-descent # leak recursive-ascent-descent # cc util-tables -D_UTIL_TABLES_STANDALONE # leak util-tables # cc slr-table -D_SLR_TABLE_STANDALONE # leak slr-table # cc clr-table -D_CLR_TABLE_STANDALONE # leak clr-table # cc clr-table "-D_CLR_TABLE_STANDALONE -D_LAZY_LALR" lalr-table # leak lalr-table # cc lr-parser -D_LR_PARSER_STANDALONE # leak lr-parser # cc demos/instant-parser # not working # leak instant-parser # not working #--------------------------------------------------------------------------------------------------# cc demos/generate-parser "-rdynamic" shared slr-table shared clr-table 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 "-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