aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/loops.lua
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-09-30 11:29:41 +0800
committerLi Jin <dragon-fly@qq.com>2022-09-30 11:29:41 +0800
commit5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2 (patch)
tree5c5c0ecdab0d19544652bc05b70d8131e1645337 /spec/outputs/loops.lua
parenta6b6753fda9745f316f3236462b74794b35b85c9 (diff)
downloadyuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.tar.gz
yuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.tar.bz2
yuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.zip
fix issue #81, refactor continue with gotos.
Diffstat (limited to 'spec/outputs/loops.lua')
-rw-r--r--spec/outputs/loops.lua204
1 files changed, 59 insertions, 145 deletions
diff --git a/spec/outputs/loops.lua b/spec/outputs/loops.lua
index e5c189e..9c16ee4 100644
--- a/spec/outputs/loops.lua
+++ b/spec/outputs/loops.lua
@@ -150,83 +150,47 @@ do
150 x = _accum_0 150 x = _accum_0
151end 151end
152while true do 152while true do
153 local _continue_0 = false 153 if false then
154 repeat 154 goto _continue_0
155 if false then 155 end
156 _continue_0 = true 156 print("yes")
157 break 157 if true then
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 158 break
168 end 159 end
160 print("no")
161 ::_continue_0::
169end 162end
170for i = 1, 10 do 163for i = 1, 10 do
171 while true do 164 while true do
172 local _continue_0 = false 165 if not true then
173 repeat 166 goto _continue_1
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 167 end
168 break
169 ::_continue_1::
186 end 170 end
187end 171end
188local a = 1 172local a = 1
189repeat 173repeat
190 local _cond_0 = false 174 a = a + 1
191 local _continue_0 = false 175 if a == 5 then
192 repeat 176 goto _continue_2
193 a = a + 1 177 end
194 if a == 5 then 178 if a == 6 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 179 break
208 end 180 end
209until _cond_0 181 print(a)
182 ::_continue_2::
183until a == 10
210x = 0 184x = 0
211repeat 185repeat
212 local _cond_0 = false 186 x = x + 1
213 local _continue_0 = false 187 y = x
214 repeat 188 if x < 5 then
215 x = x + 1 189 goto _continue_3
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 190 end
229until _cond_0 191 print(y)
192 ::_continue_3::
193until y == 10
230a = 3 194a = 3
231while not (a == 0) do 195while not (a == 0) do
232 a = a - 1 196 a = a - 1
@@ -248,37 +212,23 @@ while not cond do
248 print("okay") 212 print("okay")
249end 213end
250for x = 1, 10 do 214for x = 1, 10 do
251 local _continue_0 = false 215 if x > 3 and x < 7 then
252 repeat 216 goto _continue_4
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 217 end
218 print(x)
219 ::_continue_4::
263end 220end
264local list 221local list
265do 222do
266 local _accum_0 = { } 223 local _accum_0 = { }
267 local _len_0 = 1 224 local _len_0 = 1
268 for x = 1, 10 do 225 for x = 1, 10 do
269 local _continue_0 = false 226 if x > 3 and x < 7 then
270 repeat 227 goto _continue_5
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 228 end
229 _accum_0[_len_0] = x
230 _len_0 = _len_0 + 1
231 ::_continue_5::
282 end 232 end
283 list = _accum_0 233 list = _accum_0
284end 234end
@@ -292,78 +242,42 @@ local _list_2 = {
292} 242}
293for _index_0 = 1, #_list_2 do 243for _index_0 = 1, #_list_2 do
294 local a = _list_2[_index_0] 244 local a = _list_2[_index_0]
295 local _continue_0 = false 245 if a == 1 then
296 repeat 246 goto _continue_6
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 247 end
248 if a == 3 then
249 goto _continue_6
250 end
251 print(a)
252 ::_continue_6::
311end 253end
312for x = 1, 10 do 254for x = 1, 10 do
313 local _continue_0 = false 255 if x % 2 == 0 then
314 repeat 256 goto _continue_7
315 if x % 2 == 0 then 257 end
316 _continue_0 = true 258 for y = 2, 12 do
317 break 259 if y % 3 == 0 then
318 end 260 goto _continue_8
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 261 end
332 _continue_0 = true 262 ::_continue_8::
333 until true
334 if not _continue_0 then
335 break
336 end 263 end
264 ::_continue_7::
337end 265end
338while true do 266while true do
339 local _continue_0 = false 267 if false then
340 repeat 268 goto _continue_9
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 269 end
270 break
271 ::_continue_9::
353end 272end
354while true do 273while true do
355 local _continue_0 = false 274 if false then
356 repeat 275 goto _continue_10
357 if false then 276 end
358 _continue_0 = true 277 do
359 break
360 end
361 return 22 278 return 22
362 _continue_0 = true
363 until true
364 if not _continue_0 then
365 break
366 end 279 end
280 ::_continue_10::
367end 281end
368do 282do
369 local xxx = { 283 local xxx = {