-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrclc
executable file
·57 lines (42 loc) · 1.11 KB
/
rclc
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
#!/bin/bash
set -o errexit
set -o nounset
print_this_dir() {
(
cd "$(dirname $0)"
pwd
)
}
get_envvar() {
local name="$1"; shift
local default_value="$1"; shift
if (env | grep "^${name}=" > /dev/null); then
env | grep "^${name}=" | sed -e "s/^${name}=//"
else
echo $default_value
fi
}
__DIR__="$(print_this_dir)"
TMP_DIR=${__DIR__}/tmp/
PRINT_ASM=$(get_envvar "PRINT_ASM" 0)
mkdir -p ${TMP_DIR}
file="$1"
bname=rclc-rb
src_temp=${TMP_DIR}/${bname}.rcl.rb
# TODO check input_max
ruby ${__DIR__}/preproc.rb $file > $src_temp
ruby ${__DIR__}/check.rb gvar-width $src_temp
tokensfile=${TMP_DIR}/${bname}.vgtok.txt
treefile=${TMP_DIR}/${bname}.vgt.json
asmfile=${TMP_DIR}/${bname}.vga.txt
exefile=${TMP_DIR}/${bname}.vge.txt
ruby ${__DIR__}/rcl_lexer.rb $src_temp > $tokensfile
ruby ${__DIR__}/rcl_parser.rb $tokensfile > $treefile
ruby ${__DIR__}/check.rb fn-sig $treefile
ruby ${__DIR__}/check.rb string-size $treefile
if [ $PRINT_ASM -eq 1 ]; then
ruby ${__DIR__}/rcl_codegen.rb $treefile
else
ruby ${__DIR__}/rcl_codegen.rb $treefile > $asmfile
ruby ${__DIR__}/rcl_asm.rb $asmfile
fi