-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexecute.sh
executable file
·34 lines (30 loc) · 1.17 KB
/
execute.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
#!/bin/bash
#
# Execute the generated code
#
# This script takes in the filename of the ORIGINAL program AFTER the codegen has been run
# i.e. programs/3-semantics+codegen/valid/test.min
#
# It MUST then
# (a) Compile the GENERATED file
# i.e. programs/3-semantics+codegen/valid/test.c
# (b) Execute the compiled code
#
# (if no compilation is needed, then only perform step b)
#
# To conform with the verification script, this script MUST:
# (a) Output ONLY the execution
# (b) Exit with status code 0 for success, not 0 otherwise
rm ${1%.*}.out 2> /dev/null
# You MUST replace the following line with the command to compile your generated code
# Note the bash replacement which changes:
# programs/3-semantics+codegen/valid/test.min -> programs/3-semantics+codegen/valid/test.c
# stdout is redirected to /dev/null
FILENAME="${1%.*}.c"
gcc -std=c11 -o ${1%.*}.out $FILENAME > /dev/null
# You MUST replace the following line with the command to execute your compiled code
# Note the bash replacement which changes:
# programs/3-semantics+codegen/valid/test.min -> programs/3-semantics+codegen/valid/test.out
./${1%.*}.out
# Lastly, we propagate the exit code
exit $?