-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·95 lines (84 loc) · 1.15 KB
/
test.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
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
88
89
90
91
92
93
94
95
#! /bin/sh
#gcc -Wall -Wextra -pedantic -Werror test.c lexer.c parser.c interpreter.c stack.c -o test || exit 1
gcc test.c lexer.c parser.c interpreter.c stack.c -o test || exit 1
echo FIBONACI TEST:
cat << eof | ./test
int n1 n2 i next
{
asg n2 1
print n1
print n2
while lt i 26 {
asg next add n1 n2
print next
asg n1 n2
asg n2 next
asg i add i 1
}
}
eof
echo TEST TYPE-CHECKING
cat << eof | ./test
int a
float b
{
asg a 1
asg b 0.3
print a
print b
asg a mul a b
}
eof
echo TEST TYPE-CHECKING 2
cat << eof | ./test
int a
float b
{
asg a 1
asg b 0.3
print a
print b
asg a not b
}
eof
echo TEST TYPE-CHECKING 3
cat << eof | ./test
int a
float b
{
asg a 1
asg b 0.3
print a
print b
asg a add a div b 2
}
eof
echo TEST NESTED EXEC BLOCKS
cat << eof | ./test
int a i
float b
{
asg b 0.1
while lt a 20 {
if gt a 3 {
while lt i a {
print mul b i
asg i add i 1
}
} else {
print a
}
asg a add a 1
}
print mul a b
}
eof
#echo TEST INFINITE LOOP
#cat << eof | ./test
#int a b
#{
# asg a 1
# print b
# print a
# while 1 { print a print b }
#eof