From a8e2b9734246599ffea99002fb244905b0819987 Mon Sep 17 00:00:00 2001 From: bd-912 Date: Fri, 26 Apr 2024 15:03:42 -0600 Subject: Add new base test script --- .gitignore | 1 + runner.sh | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100755 runner.sh diff --git a/.gitignore b/.gitignore index c9ee4cc..6282035 100644 --- a/.gitignore +++ b/.gitignore @@ -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 " + 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 -- cgit v1.2.3