-
Notifications
You must be signed in to change notification settings - Fork 3
/
run
executable file
·41 lines (36 loc) · 873 Bytes
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh -f
#
# run
# Usage: run decaf-file
#
# Compiles decaf-file and executes (spim).
#
SPIM=/usr/class/cs143/bin/spim
COMPILER=dcc
if [ $# -lt 1 ]; then
echo "Run script error: The run script takes one argument, the path to a Decaf file."
exit 1;
fi
if [ ! -x $COMPILER ]; then
echo "Run script error: Cannot find $COMPILER executable!"
echo "(You must run this script from the directory containing your $COMPILER executable.)"
exit 1;
fi
if [ ! -r $1 ]; then
echo "Run script error: Cannot find Decaf input file named '$1'."
exit 1;
fi
echo "-- $COMPILER <$1 >tmp.asm"
./$COMPILER < $1 > tmp.asm 2>tmp.errors
if [ $? -ne 0 -o -s tmp.errors ]; then
echo "Run script error: errors reported from $COMPILER compiling '$1'."
echo " "
cat tmp.errors
exit 1;
fi
echo "-- spim -file tmp.asm"
echo " "
$SPIM -file tmp.asm
echo " "
echo " "
exit 0;