-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoosc
executable file
·63 lines (54 loc) · 1.36 KB
/
joosc
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
#!/bin/bash
# Check for whitespace
for FILE; do
if [[ $FILE = *[[:space:]]* ]]; then
echo "Error: filename contains whitespace"
exit 42
fi
done
# Check extensions.
for FILE; do
echo "$FILE" | grep '\.java$'; ret="$?"
if [ "$ret" != 0 ]; then
echo "Invalid filename"
exit 42
fi
done
# Tokenize and parse files individually.
for FILE; do
TOKENS="${FILE%.java}.tokens"
PARSE="${FILE%.java}.parse"
CLASSNAME="$(basename "$FILE" .java)"
# Reuse existing stdlib parse if the flag is set.
if [ "$SKIP_STDLIB" != "" ] && [[ "$FILE" == test/stdlib/* ]]; then
continue
fi
# Lexer
bin/lexer "$FILE" > "$TOKENS"; ret="$?"
case "$ret" in
0) ;;
42) exit 42; ;;
*) echo "Exiting due to lexer error"; exit $ret; ;;
esac
# Parser
bin/parser "$TOKENS" > "$PARSE"; ret="$?"
case "$ret" in
0) ;;
42) exit 42; ;;
*) echo "Exiting due to parser error"; exit $ret; ;;
esac
# Weeder
bin/weeder "$CLASSNAME" "$FILE" "$TOKENS" "$PARSE"; ret="$?"
case "$ret" in
0) ;;
42) exit 42; ;;
*) echo "Exiting due to weeder error"; exit $ret; ;;
esac
done
bin/compiler "$@"; ret="$?"
case "$ret" in
0) ;;
42) exit 42; ;;
*) echo "Exiting due to compiler error"; exit 42; ;;
esac
cp def/fixed.s output