-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeathoven.sh
More file actions
executable file
·44 lines (38 loc) · 1.14 KB
/
beathoven.sh
File metadata and controls
executable file
·44 lines (38 loc) · 1.14 KB
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
#!/bin/bash
MYDIR="$(dirname "$(which "$0")")"
BEAT_FILE="$MYDIR/src/beathoven"
cp $MYDIR/src/stdlib.bc .
if [ ! -f $BEAT_FILE ]; then
printf "ERROR: not yet compiled, run 'make' first.\n" 1>&2
exit 1
fi
# beathoven.sh (-c ) <BEAT_FILE> <output_file>
if [ "$#" -eq 3 ]; then
if [ "$1" == "-c" ]; then
cat $2 | $BEAT_FILE $1 > $3
exit 0
elif [ "$1" == "-r" ]; then
$BEAT_FILE $1 $3 < $2
exit 0
else
printf "ERROR: invalid arguments supplied for command $0 $1\n" 1>&2
exit 1
fi
fi
# beathoven.sh -s <BEAT_FILE>
if [ "$#" -eq 2 ] && [ "$1" == "-s" ]; then
$BEAT_FILE $1 < $2
exit 0
fi
# beathoven.sh -h
if [ "$#" -eq 1 ] && [ "$1" == "-h" ]; then
$BEAT_FILE $1
exit 0
# printf """Beathoven Usage: beathoven.sh <flag> [input_file] [output_file]\n"
# printf " -c\tCompile beathoven input_file to llvm code in output_file with stdlib\n"
# printf " -h\tDisplay this list of options\n"
# printf " -s\tPrint a json tree of our semantically checked abstract syntax tree\n"
# exit 1
fi
printf "ERROR: invalid arguments. Run $0 -h for usage instructions\n" 1>&2
exit 1