diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-26 15:03:42 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-26 15:03:42 -0600 |
commit | a8e2b9734246599ffea99002fb244905b0819987 (patch) | |
tree | 07a64024b9ff9fd9bd044608423cd33ce8b6879b | |
parent | e33c81c013f78589a01143c36225825c8cf42707 (diff) |
Add new base test script
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | runner.sh | 80 |
2 files changed, 81 insertions, 0 deletions
@@ -9,3 +9,4 @@ /*.dot /test.vaporm /cs132/ +/output/ diff --git a/runner.sh b/runner.sh new file mode 100755 index 0000000..3e56fa3 --- /dev/null +++ b/runner.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +################################################## +# A test script capable of running all phases of # +# compilation when supplied a phase name and a # +# file. # +################################################## + +#### Functions +function run_with_java() { + # run the passed in file with java + ext="class" + if [ ! -f "${filename}.$ext" ]; then + javac -g $1 + fi + java -cp $dirname $filename +} + +function typecheck() { + # typecheck the file + java typecheck < $1 +} + +function boil() { + # boil the file + ext="vapor" + java J2V < $1 > "./output/${filename}.$ext" + java -jar vapor.jar run "./output/${filename}.$ext" +} + +function vaporize() { + # vaporize the file + ext="vaporm" + java V2VM < $1 > "./output/${filename}.$ext" + java -jar vapor.jar run -mips "./output/${filename}.$ext" +} + +function condense() { + # condense the file +} + + + +## Check that $2 is a file +if [ -z "$2" ]; then + echo "Usage: $0 <arg1> <file>" + exit 1 +fi + +if [ ! -f "$2" ]; then + echo "Error: $2 is not a regular file." + exit 1 +fi + +dirname=$(dirname "$2") +filefull=$(basename "$2") +filename=${filefull%.*} + +## Handle passed args +case "$1" in + "java") + run_with_java "$2" + ;; + "typecheck") + typecheck "$2" + ;; + "boil") + boil "$2" + ;; + "vaporize") + vaporize "$2" + ;; + "condense") + condense "$2" + ;; + *) + echo "usage $0 [java|typecheck|boil|vaporize|condense]" + exit 1 + ;; +esac |