Skip to content

Commit 5a4b86a

Browse files
committed
modify pretty print tree and update testcases
1 parent b9f1c9e commit 5a4b86a

File tree

11 files changed

+1480
-630
lines changed

11 files changed

+1480
-630
lines changed
Lines changed: 138 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,138 @@
1-
program
2-
class Main <empty>
3-
static func main voidtype
4-
formals
5-
stmtblock
6-
vardef i inttype
7-
vardef F classtype Fibonacci
8-
assign
9-
varref F
10-
newobj Fibonacci
11-
assign
12-
varref i
13-
intconst 0
14-
while
15-
les
16-
varref i
17-
intconst 10
18-
stmtblock
19-
print
20-
call get
21-
varref F
22-
varref i
23-
stringconst "\n"
24-
assign
25-
varref i
26-
add
27-
varref i
28-
intconst 1
29-
assign
30-
varref i
31-
readint
32-
print
33-
call get
34-
varref F
35-
varref i
36-
stringconst "\n"
37-
class Fibonacci <empty>
38-
func get inttype
39-
formals
40-
vardef index inttype
41-
stmtblock
42-
if
43-
les
44-
varref index
45-
intconst 2
46-
stmtblock
47-
return
48-
intconst 1
49-
return
50-
add
51-
call get
52-
<empty>
53-
sub
54-
varref index
55-
intconst 1
56-
call get
57-
<empty>
58-
sub
59-
varref index
60-
intconst 2
1+
TopLevel @ (3,1)
2+
List
3+
ClassDef @ (3,1)
4+
Main
5+
<none>
6+
List
7+
MethodDef @ (6,17)
8+
main
9+
List
10+
<empty>
11+
TVoid @ (6,12)
12+
Block @ (6,24)
13+
List
14+
LocalVarDef @ (7,13)
15+
TInt @ (7,9)
16+
i
17+
LocalVarDef @ (8,25)
18+
TClass @ (8,9)
19+
Fibonacci
20+
F
21+
Assign @ (10,11)
22+
VarSel @ (10,9)
23+
<none>
24+
F
25+
NewClass @ (10,13)
26+
Fibonacci
27+
Assign @ (11,11)
28+
VarSel @ (11,9)
29+
<none>
30+
i
31+
IntLit @ (11,13)
32+
0
33+
While @ (12,9)
34+
BinaryExpr @ (12,18)
35+
<
36+
VarSel @ (12,16)
37+
<none>
38+
i
39+
IntLit @ (12,20)
40+
10
41+
Block @ (12,24)
42+
List
43+
Print @ (13,13)
44+
List
45+
Call @ (13,22)
46+
VarSel @ (13,20)
47+
<none>
48+
F
49+
get
50+
List
51+
VarSel @ (13,26)
52+
<none>
53+
i
54+
StringLit @ (13,30)
55+
"\n"
56+
Assign @ (14,15)
57+
VarSel @ (14,13)
58+
<none>
59+
i
60+
BinaryExpr @ (14,19)
61+
+
62+
VarSel @ (14,17)
63+
<none>
64+
i
65+
IntLit @ (14,21)
66+
1
67+
Assign @ (17,11)
68+
VarSel @ (17,9)
69+
<none>
70+
i
71+
ReadInt @ (17,13)
72+
Print @ (18,9)
73+
List
74+
Call @ (18,18)
75+
VarSel @ (18,16)
76+
<none>
77+
F
78+
get
79+
List
80+
VarSel @ (18,22)
81+
<none>
82+
i
83+
StringLit @ (18,26)
84+
"\n"
85+
true
86+
ClassDef @ (22,1)
87+
Fibonacci
88+
<none>
89+
List
90+
MethodDef @ (25,9)
91+
get
92+
List
93+
LocalVarDef @ (25,17)
94+
TInt @ (25,13)
95+
index
96+
TInt @ (25,5)
97+
Block @ (25,24)
98+
List
99+
If @ (26,9)
100+
BinaryExpr @ (26,19)
101+
<
102+
VarSel @ (26,13)
103+
<none>
104+
index
105+
IntLit @ (26,21)
106+
2
107+
Block @ (26,24)
108+
List
109+
Return @ (27,13)
110+
IntLit @ (27,20)
111+
1
112+
<none>
113+
Return @ (29,9)
114+
BinaryExpr @ (29,31)
115+
+
116+
Call @ (29,16)
117+
<none>
118+
get
119+
List
120+
BinaryExpr @ (29,26)
121+
-
122+
VarSel @ (29,20)
123+
<none>
124+
index
125+
IntLit @ (29,28)
126+
1
127+
Call @ (29,33)
128+
<none>
129+
get
130+
List
131+
BinaryExpr @ (29,43)
132+
-
133+
VarSel @ (29,37)
134+
<none>
135+
index
136+
IntLit @ (29,45)
137+
2
138+
false

0 commit comments

Comments
 (0)