Extract parser and add x64 assembly emission
This commit is contained in:
26
build.sh
26
build.sh
@@ -1,4 +1,20 @@
|
||||
set -euo pipefail
|
||||
# set -euo pipefail
|
||||
|
||||
assert_eq() {
|
||||
expected="$1"
|
||||
actual="$2"
|
||||
if [ "$expected" != "$actual" ]; then
|
||||
echo "assert failed: expected '$expected', got '$actual'"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
verify_expr() {
|
||||
./main "$1"
|
||||
clang out.s -o test
|
||||
./test
|
||||
assert_eq $? $2
|
||||
}
|
||||
|
||||
if [[ ! -e build ]]; then
|
||||
mkdir build
|
||||
@@ -7,4 +23,10 @@ cd build
|
||||
clang -o meta $(realpath ../meta.c) -g -Wall -Wextra -Wshadow -fdiagnostics-absolute-paths
|
||||
./meta > ../meta_gen.c
|
||||
clang -o main $(realpath ../main.c) -g -Wall -Wextra -Wshadow -fdiagnostics-absolute-paths
|
||||
./main
|
||||
|
||||
./main
|
||||
verify_expr "2+1-1" 2
|
||||
verify_expr "(2+1-1)*3" 6
|
||||
|
||||
|
||||
echo done
|
||||
Reference in New Issue
Block a user