-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompile.sh
executable file
·72 lines (58 loc) · 1.04 KB
/
Compile.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
68
69
70
71
if [ $# -ne 1 ]
then
echo "Please provide one argument with valid file for compilation."
exit 1
fi
if [ ! -f $1 ]
then
echo "Invalid file name!!"
exit 1
fi
filename=`echo "$1" | cut -f 1 -d '.'` # Get filename without extension
extension=`echo "$1" | cut -f 2 -d '.'`
if [ ! $extension == "c" ]
then
echo "Not a C file!!"
exit 1
fi
ext2="_Vars.txt"
ext3="_ICCode.txt"
ext4="_ASMCode.asm"
f2=${filename}${ext2}
f3=${filename}${ext3}
f4=${filename}${ext4}
bison -d --warning=none parse.y
flex lexical.l
gcc -c -w lex.yy.c
gcc -c -w parse.tab.c
gcc parse.tab.o lex.yy.o -o ex
rm lex.yy.c
rm lex.yy.o
rm parse.tab.c
rm parse.tab.h
rm parse.tab.o
./ex $1 $f3 $f2
if [ $? -eq 139 ]; then
echo "Compiler gives segmentation fault!!"
rm $f2
rm "ex"
exit 1
fi
if [ -f "Res.txt" ]
then
a=`cat "Res.txt"`
if [ $a -eq "1" ]
then
python3 mapper.py $f2 $f3> $f4
# spim -file $f4
ans=`spim -file $f4`
finalans=`echo "$ans" | tail -n+6`
echo "Output :"
echo "$finalans"
fi
rm "Res.txt"
else
echo "No result file made!"
fi
rm $f2
rm "ex"