-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrace_compiler.sh
executable file
·67 lines (63 loc) · 1.33 KB
/
grace_compiler.sh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# example: %>./script.sh examples/general/primes.grace [--no-rebuil] [--upto-ir]
if [ $# -eq 0 ] # if no arguments were supplied
then
echo "ERROR! No arguments supplied!"
exit -1
elif [ $# -eq 1 ]
then
mvn clean package
java -cp target/compiler-1.0-SNAPSHOT.jar compiler.Main $1
gcc -m32 -o executable g.s
./executable
rm executable
elif [ $# -eq 2 ]
then
if [ $2 = "--no-rebuild" ]
then
java -cp target/compiler-1.0-SNAPSHOT.jar compiler.Main $1
gcc -m32 -o executable g.s
./executable
rm executable
elif [ $2 = "--upto-ir" ]
then
java -cp target/compiler-1.0-SNAPSHOT.jar compiler.Main $1
else
echo "Unsupported second argument!"
exit -2
fi
elif [ $# -eq 3 ]
then
rebFlag=0
irFlag=0
if [ $2 = "--no-rebuild" ]
then
let "rebFlag = rebFlag+1"
elif [ $2 = "--upto-ir" ]
then
let "irFlag = irFlag+1"
else
echo "Unsupported second argument!"
exit -2
fi
if [ $2 = "--upto-ir" ]
then
let "rebFlag = rebFlag+1"
elif [ $2 = "--no-rebuild" ]
then
let "irFlag = irFlag+1"
else
echo "Unsupported second argument!"
exit -2
fi
if (( rebFlag != 1 )) || (( irFlag != 1 )) # if there is a flag missing
then
echo "ERROR! Bad patamerers!"
exit -1
else
java -cp target/compiler-1.0-SNAPSHOT.jar compiler.Main $1
fi
else
echo "ERROR! Too many arguments!"
exit -3
fi