diff options
author | Li Jin <dragon-fly@qq.com> | 2022-09-30 11:29:41 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-09-30 11:29:41 +0800 |
commit | 5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2 (patch) | |
tree | 5c5c0ecdab0d19544652bc05b70d8131e1645337 /spec/outputs/5.1/loops.lua | |
parent | a6b6753fda9745f316f3236462b74794b35b85c9 (diff) | |
download | yuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.tar.gz yuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.tar.bz2 yuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.zip |
fix issue #81, refactor continue with gotos.
Diffstat (limited to 'spec/outputs/5.1/loops.lua')
-rw-r--r-- | spec/outputs/5.1/loops.lua | 381 |
1 files changed, 381 insertions, 0 deletions
diff --git a/spec/outputs/5.1/loops.lua b/spec/outputs/5.1/loops.lua new file mode 100644 index 0000000..a3b9548 --- /dev/null +++ b/spec/outputs/5.1/loops.lua | |||
@@ -0,0 +1,381 @@ | |||
1 | for x = 1, 10 do | ||
2 | print("yeah") | ||
3 | end | ||
4 | for x = 1, #something do | ||
5 | print("yeah") | ||
6 | end | ||
7 | for y = 100, 60, -3 do | ||
8 | print("count down", y) | ||
9 | end | ||
10 | for a = 1, 10 do | ||
11 | print("okay") | ||
12 | end | ||
13 | for a = 1, 10 do | ||
14 | for b = 2, 43 do | ||
15 | print(a, b) | ||
16 | end | ||
17 | end | ||
18 | for i in iter do | ||
19 | for j in yeah do | ||
20 | local x = 343 + i + j | ||
21 | print(i, j) | ||
22 | end | ||
23 | end | ||
24 | local _list_0 = something | ||
25 | for _index_0 = 1, #_list_0 do | ||
26 | local x = _list_0[_index_0] | ||
27 | print(x) | ||
28 | end | ||
29 | for k, v in pairs(hello) do | ||
30 | print(k, v) | ||
31 | end | ||
32 | for x in y, z do | ||
33 | print(x) | ||
34 | end | ||
35 | for x in y, z, k do | ||
36 | print(x) | ||
37 | end | ||
38 | local _list_1 = modules | ||
39 | for _index_0 = 1, #_list_1 do | ||
40 | local name, members = _list_1[_index_0] | ||
41 | print(name, member) | ||
42 | end | ||
43 | local x | ||
44 | x = function() | ||
45 | for x in y do | ||
46 | local _ = y | ||
47 | end | ||
48 | end | ||
49 | local hello = { | ||
50 | 1, | ||
51 | 2, | ||
52 | 3, | ||
53 | 4, | ||
54 | 5 | ||
55 | } | ||
56 | do | ||
57 | local _accum_0 = { } | ||
58 | local _len_0 = 1 | ||
59 | for _index_0 = 1, #hello do | ||
60 | local y = hello[_index_0] | ||
61 | if y % 2 == 0 then | ||
62 | _accum_0[_len_0] = y | ||
63 | end | ||
64 | _len_0 = _len_0 + 1 | ||
65 | end | ||
66 | x = _accum_0 | ||
67 | end | ||
68 | x = function() | ||
69 | for _index_0 = 1, #hello do | ||
70 | local x = hello[_index_0] | ||
71 | local _ = y | ||
72 | end | ||
73 | end | ||
74 | local t | ||
75 | do | ||
76 | local _accum_0 = { } | ||
77 | local _len_0 = 1 | ||
78 | for i = 10, 20 do | ||
79 | _accum_0[_len_0] = i * 2 | ||
80 | _len_0 = _len_0 + 1 | ||
81 | end | ||
82 | t = _accum_0 | ||
83 | end | ||
84 | local hmm = 0 | ||
85 | local y | ||
86 | do | ||
87 | local _accum_0 = { } | ||
88 | local _len_0 = 1 | ||
89 | for j = 3, 30, 8 do | ||
90 | hmm = hmm + 1 | ||
91 | _accum_0[_len_0] = j * hmm | ||
92 | _len_0 = _len_0 + 1 | ||
93 | end | ||
94 | y = _accum_0 | ||
95 | end | ||
96 | local _ | ||
97 | _ = function() | ||
98 | for k = 10, 40 do | ||
99 | _ = "okay" | ||
100 | end | ||
101 | end | ||
102 | _ = function() | ||
103 | local _accum_0 = { } | ||
104 | local _len_0 = 1 | ||
105 | for k = 10, 40 do | ||
106 | _accum_0[_len_0] = "okay" | ||
107 | _len_0 = _len_0 + 1 | ||
108 | end | ||
109 | return _accum_0 | ||
110 | end | ||
111 | while true do | ||
112 | print("name") | ||
113 | end | ||
114 | while 5 + 5 do | ||
115 | print("okay world") | ||
116 | working(man) | ||
117 | end | ||
118 | while also do | ||
119 | i(work(too)) | ||
120 | _ = "okay" | ||
121 | end | ||
122 | local i = 0 | ||
123 | do | ||
124 | local _accum_0 = { } | ||
125 | local _len_0 = 1 | ||
126 | while i < 10 do | ||
127 | i = i + 1 | ||
128 | _len_0 = _len_0 + 1 | ||
129 | end | ||
130 | x = _accum_0 | ||
131 | end | ||
132 | do | ||
133 | local _accum_0 = { } | ||
134 | local _len_0 = 1 | ||
135 | local _list_2 = 3 | ||
136 | for _index_0 = 1, #_list_2 do | ||
137 | local thing = _list_2[_index_0] | ||
138 | y = "hello" | ||
139 | _len_0 = _len_0 + 1 | ||
140 | end | ||
141 | x = _accum_0 | ||
142 | end | ||
143 | do | ||
144 | local _accum_0 = { } | ||
145 | local _len_0 = 1 | ||
146 | for x = 1, 2 do | ||
147 | y = "hello" | ||
148 | _len_0 = _len_0 + 1 | ||
149 | end | ||
150 | x = _accum_0 | ||
151 | end | ||
152 | while true do | ||
153 | local _continue_0 = false | ||
154 | repeat | ||
155 | if false then | ||
156 | _continue_0 = true | ||
157 | break | ||
158 | end | ||
159 | print("yes") | ||
160 | if true then | ||
161 | break | ||
162 | end | ||
163 | print("no") | ||
164 | _continue_0 = true | ||
165 | until true | ||
166 | if not _continue_0 then | ||
167 | break | ||
168 | end | ||
169 | end | ||
170 | for i = 1, 10 do | ||
171 | while true do | ||
172 | local _continue_0 = false | ||
173 | repeat | ||
174 | do | ||
175 | if not true then | ||
176 | _continue_0 = true | ||
177 | break | ||
178 | end | ||
179 | break | ||
180 | end | ||
181 | _continue_0 = true | ||
182 | until true | ||
183 | if not _continue_0 then | ||
184 | break | ||
185 | end | ||
186 | end | ||
187 | end | ||
188 | local a = 1 | ||
189 | repeat | ||
190 | local _cond_0 = false | ||
191 | local _continue_0 = false | ||
192 | repeat | ||
193 | a = a + 1 | ||
194 | if a == 5 then | ||
195 | _cond_0 = a == 10 | ||
196 | _continue_0 = true | ||
197 | break | ||
198 | end | ||
199 | if a == 6 then | ||
200 | break | ||
201 | end | ||
202 | print(a) | ||
203 | _cond_0 = a == 10 | ||
204 | _continue_0 = true | ||
205 | until true | ||
206 | if not _continue_0 then | ||
207 | break | ||
208 | end | ||
209 | until _cond_0 | ||
210 | x = 0 | ||
211 | repeat | ||
212 | local _cond_0 = false | ||
213 | local _continue_0 = false | ||
214 | repeat | ||
215 | x = x + 1 | ||
216 | y = x | ||
217 | if x < 5 then | ||
218 | _cond_0 = y == 10 | ||
219 | _continue_0 = true | ||
220 | break | ||
221 | end | ||
222 | print(y) | ||
223 | _cond_0 = y == 10 | ||
224 | _continue_0 = true | ||
225 | until true | ||
226 | if not _continue_0 then | ||
227 | break | ||
228 | end | ||
229 | until _cond_0 | ||
230 | a = 3 | ||
231 | while not (a == 0) do | ||
232 | a = a - 1 | ||
233 | end | ||
234 | local done = false | ||
235 | while not done do | ||
236 | done = true | ||
237 | end | ||
238 | repeat | ||
239 | print("hello") | ||
240 | until true | ||
241 | while not done do | ||
242 | x = 10 | ||
243 | repeat | ||
244 | x = x - 1 | ||
245 | until x == 0 | ||
246 | end | ||
247 | while not cond do | ||
248 | print("okay") | ||
249 | end | ||
250 | for x = 1, 10 do | ||
251 | local _continue_0 = false | ||
252 | repeat | ||
253 | if x > 3 and x < 7 then | ||
254 | _continue_0 = true | ||
255 | break | ||
256 | end | ||
257 | print(x) | ||
258 | _continue_0 = true | ||
259 | until true | ||
260 | if not _continue_0 then | ||
261 | break | ||
262 | end | ||
263 | end | ||
264 | local list | ||
265 | do | ||
266 | local _accum_0 = { } | ||
267 | local _len_0 = 1 | ||
268 | for x = 1, 10 do | ||
269 | local _continue_0 = false | ||
270 | repeat | ||
271 | if x > 3 and x < 7 then | ||
272 | _continue_0 = true | ||
273 | break | ||
274 | end | ||
275 | _accum_0[_len_0] = x | ||
276 | _len_0 = _len_0 + 1 | ||
277 | _continue_0 = true | ||
278 | until true | ||
279 | if not _continue_0 then | ||
280 | break | ||
281 | end | ||
282 | end | ||
283 | list = _accum_0 | ||
284 | end | ||
285 | local _list_2 = { | ||
286 | 1, | ||
287 | 2, | ||
288 | 3, | ||
289 | 4, | ||
290 | 5, | ||
291 | 6 | ||
292 | } | ||
293 | for _index_0 = 1, #_list_2 do | ||
294 | local a = _list_2[_index_0] | ||
295 | local _continue_0 = false | ||
296 | repeat | ||
297 | if a == 1 then | ||
298 | _continue_0 = true | ||
299 | break | ||
300 | end | ||
301 | if a == 3 then | ||
302 | _continue_0 = true | ||
303 | break | ||
304 | end | ||
305 | print(a) | ||
306 | _continue_0 = true | ||
307 | until true | ||
308 | if not _continue_0 then | ||
309 | break | ||
310 | end | ||
311 | end | ||
312 | for x = 1, 10 do | ||
313 | local _continue_0 = false | ||
314 | repeat | ||
315 | if x % 2 == 0 then | ||
316 | _continue_0 = true | ||
317 | break | ||
318 | end | ||
319 | for y = 2, 12 do | ||
320 | local _continue_1 = false | ||
321 | repeat | ||
322 | if y % 3 == 0 then | ||
323 | _continue_1 = true | ||
324 | break | ||
325 | end | ||
326 | _continue_1 = true | ||
327 | until true | ||
328 | if not _continue_1 then | ||
329 | break | ||
330 | end | ||
331 | end | ||
332 | _continue_0 = true | ||
333 | until true | ||
334 | if not _continue_0 then | ||
335 | break | ||
336 | end | ||
337 | end | ||
338 | while true do | ||
339 | local _continue_0 = false | ||
340 | repeat | ||
341 | do | ||
342 | if false then | ||
343 | _continue_0 = true | ||
344 | break | ||
345 | end | ||
346 | break | ||
347 | end | ||
348 | _continue_0 = true | ||
349 | until true | ||
350 | if not _continue_0 then | ||
351 | break | ||
352 | end | ||
353 | end | ||
354 | while true do | ||
355 | local _continue_0 = false | ||
356 | repeat | ||
357 | if false then | ||
358 | _continue_0 = true | ||
359 | break | ||
360 | end | ||
361 | do | ||
362 | return 22 | ||
363 | end | ||
364 | _continue_0 = true | ||
365 | until true | ||
366 | if not _continue_0 then | ||
367 | break | ||
368 | end | ||
369 | end | ||
370 | do | ||
371 | local xxx = { | ||
372 | 1, | ||
373 | 2, | ||
374 | 3, | ||
375 | 4 | ||
376 | } | ||
377 | for _index_0 = 1, #xxx do | ||
378 | local thing = xxx[_index_0] | ||
379 | print(thing) | ||
380 | end | ||
381 | end | ||