-
Notifications
You must be signed in to change notification settings - Fork 0
/
interpreter
87 lines (77 loc) · 2.01 KB
/
interpreter
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
set -euo pipefail
INTERPRETER_PATH=$(realpath "$0" | xargs dirname)
FAT_JAR="$INTERPRETER_PATH/build/libs/tkom-1.0-SNAPSHOT-all.jar"
FILE="$INTERPRETER_PATH/src/main/resources/query.txt"
MAX_IDENTIFIER_LENGTH=100
MAX_STRING_LENGTH=1000
MAX_EXCEPTIONS=500
MAX_STACK_SIZE=100
help () {
cat 1>&2 << EOF
Usage: $0 [OPTION] [FILE]
-h --help Display this message
-c --clean Re-build project from scratch before running application
-i --identifier [VALUE] Set the maximum number of characters in a identifier
Default: $MAX_IDENTIFIER_LENGTH
-s --string [VALUE] Set the maximum number of characters in a string
Default: $MAX_STRING_LENGTH
-e --exception [VALUE] Set the maximum number of exceptions before stopping execution of a program
Default: $MAX_EXCEPTIONS
-f --function [VALUE] Set the maximum number of nested function calls before stopping execution of program
Default: $MAX_STACK_SIZE
EOF
exit 0;
}
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
help
;;
-c|--clean)
./gradlew clean 1>&2
shift
;;
-i|--identifier)
MAX_IDENTIFIER_LENGTH="$2"
shift
shift
;;
-s|--string)
MAX_STRING_LENGTH="$2"
shift
shift
;;
-e|--exception)
MAX_EXCEPTIONS="$2"
shift
shift
;;
-f|--function)
MAX_STACK_SIZE="$2"
shift
shift
;;
-*)
echo "Unknown option $1" 1>&2
help
exit 1
;;
*)
FILE="$1"
shift
;;
esac
done
if [ ! -f "$FAT_JAR" ]; then
cd "$INTERPRETER_PATH"
./gradlew shadowJar 1>&2
cd - > /dev/null
fi
java \
-Dmax.identifier.length="$MAX_IDENTIFIER_LENGTH" \
-Dmax.string.length="$MAX_STRING_LENGTH" \
-Dmax.exceptions="$MAX_EXCEPTIONS" \
-Dmax.stack.size="$MAX_STACK_SIZE" \
-jar "$FAT_JAR" \
"$FILE"