-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathastsample.txt
169 lines (164 loc) · 2.83 KB
/
astsample.txt
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Random program
(B (FUNCDEF fun3 (FHEADER (FPARAM x )(FPARAM y )(FPARAM z )) (BLOCK (DECLSTAT (LVARDEF a ) (LVARDEF b ) (LVARDEF c ) (MOV (VAR a)(INT 2)) ) (MOV (VAR b)(INT 3)) (MOV (VAR c)(ADD (VAR a)(VAR b)) ) ) ) (FUNCDEF main (FHEADER ) (BLOCK (DECLSTAT (LVARDEF a ) (LVARDEF b ) (LVARDEF c ) (MOV (VAR a)(INT 1)) ) (MOV (VAR b)(INT 2)) (MOV (VAR c)(INT 3)) (FUNCCALL (VAR fun3)(ARG (VAR a)) (ARG (VAR b)) (ARG (VAR c)) ) (MOV (VAR a)(INT 2)) (MOV (VAR b)(INT 1)) (FUNCCALL (VAR fun3)(ARG (INT 1)) (ARG (VAR b)) (ARG (INT 2)) ) (FUNCCALL (VAR fun3)(ARG (INT 1)) (ARG (VAR b)) (ARG (STRING `"123123"`)) ) ) ) )
# Post increment
(B (FUNCDEF main (FHEADER ) (BLOCK (DECLSTAT (LVARDEF i ) (MOV (VAR i)(ONUMBER 0)) ) (POSTINC (VAR i)) (FUNCCALL (VAR printf)(ARG (STRING `"%d\n"`)) (ARG (VAR i)) ) ) ) )
# Functiona call
B
FUNCDEF f
FHEADER
FPARAM a
FPARAM b
FPARAM c
BLOCK
FUNCDEF main
FHEADER
BLOCK
# Fast Pow
B
FUNCDEF f
FHEADER
FUNCDEF base
FUNCDEF exp
BLOCK
IF
EQU
VAR exp
INT 0
BLOCK
RETURNPARAM
INT 1
IF
EQU
VAR exp
INT 1
BLOCK
RETURNPARAM
VAR base
IFELSE
EQU
MOD
VAR exp
INT 2
INT 0
BLOCK
DECLSTAT
LVARDEF t
MOV
VAR t
FUNCCALL
VAR f
ARG
VAR base
ARG
DIV
VAR exp
INT 2
RETURNPARAM
MUL
VAR t
VAR t
BLOCK
RETURNPARAM
FUNCCALL
VAR f
ARG
VAR base
ARG
SUB
VAR exp
INT 1
FUNCDEF main
FHEADER
BLOCK
FUNCCALL
VAR printf
ARG
STRING "%d\n"
ARG
FUNCCALL
VAR f
ARG
INT 2
ARG
INT 10
# Guessing game
B
FUNCDEF main
FHEADER
BLOCK
DECLSTAT
LVARDEF left
LVARDEF right
LVARDEF guessCmp
LVARDEF cnt
MOV
VAR cnt
INT 1
MOV
VAR left
INT 1
MOV
VAR right
INT 100
FUNCCALL
VAR printf
ARG
STRING "Da li je tvoj broj %d?\n"
ARG
DIV
ADD
VAR left
VAR right
INT 2
FUNCCALL
VAR scanf
ARG
STRING "%d"
ARG
ADDROF
VAR guessCmp
WHILE
NEQU
VAR guessCmp
INT 0
BLOCK
FUNCCALL
VAR printf
ARG
STRING "Da li je tvoj broj %d?\n"
ARG
DIV
ADD
VAR left
VAR right
INT 2
IFELSE
LESSTHAN
VAR guessCmp
INT 0
BLOCK
MOV
VAR right
DIV
ADD
VAR left
VAR right
INT 2
BLOCK
MOV
VAR left
DIV
ADD
VAR left
VAR right
INT 2
POSTINC
VAR cnt
FUNCCALL
VAR printf
ARG
STRING "Trebalo mi je %d pokusaja da pogodim broj"
ARG
VAR cnt
RETURN
INT 0