diff options
| author | Li Jin <dragon-fly@qq.com> | 2025-05-21 11:44:54 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2025-05-21 11:44:54 +0800 |
| commit | 0603800a4114ed8b4c9572a7d7852995c9b9f334 (patch) | |
| tree | 456524685562bcd0d874530e3ddc2a0fc0731525 /spec/outputs/5.1/loops.lua | |
| parent | ff137ac73d999a5849f02706cfd52f4659b025ef (diff) | |
| download | yuescript-0603800a4114ed8b4c9572a7d7852995c9b9f334.tar.gz yuescript-0603800a4114ed8b4c9572a7d7852995c9b9f334.tar.bz2 yuescript-0603800a4114ed8b4c9572a7d7852995c9b9f334.zip | |
Added break with value syntax.
Diffstat (limited to 'spec/outputs/5.1/loops.lua')
| -rw-r--r-- | spec/outputs/5.1/loops.lua | 104 |
1 files changed, 101 insertions, 3 deletions
diff --git a/spec/outputs/5.1/loops.lua b/spec/outputs/5.1/loops.lua index 57b19be..bc720f6 100644 --- a/spec/outputs/5.1/loops.lua +++ b/spec/outputs/5.1/loops.lua | |||
| @@ -60,8 +60,8 @@ do | |||
| 60 | local y = hello[_index_0] | 60 | local y = hello[_index_0] |
| 61 | if y % 2 == 0 then | 61 | if y % 2 == 0 then |
| 62 | _accum_0[_len_0] = y | 62 | _accum_0[_len_0] = y |
| 63 | _len_0 = _len_0 + 1 | ||
| 63 | end | 64 | end |
| 64 | _len_0 = _len_0 + 1 | ||
| 65 | end | 65 | end |
| 66 | x = _accum_0 | 66 | x = _accum_0 |
| 67 | end | 67 | end |
| @@ -132,13 +132,11 @@ do | |||
| 132 | end | 132 | end |
| 133 | do | 133 | do |
| 134 | local _accum_0 = { } | 134 | local _accum_0 = { } |
| 135 | local _len_0 = 1 | ||
| 136 | local _list_2 = 3 | 135 | local _list_2 = 3 |
| 137 | for _index_0 = 1, #_list_2 do | 136 | for _index_0 = 1, #_list_2 do |
| 138 | local thing = _list_2[_index_0] | 137 | local thing = _list_2[_index_0] |
| 139 | y = "hello" | 138 | y = "hello" |
| 140 | break | 139 | break |
| 141 | _len_0 = _len_0 + 1 | ||
| 142 | end | 140 | end |
| 143 | x = _accum_0 | 141 | x = _accum_0 |
| 144 | end | 142 | end |
| @@ -489,3 +487,103 @@ do | |||
| 489 | end | 487 | end |
| 490 | until false | 488 | until false |
| 491 | end | 489 | end |
| 490 | local _anon_func_0 = function(i, tb) | ||
| 491 | local _accum_0 = { } | ||
| 492 | local _len_0 = 1 | ||
| 493 | while tb[i] do | ||
| 494 | i = i + 1 | ||
| 495 | _accum_0[_len_0] = i - 1 | ||
| 496 | _len_0 = _len_0 + 1 | ||
| 497 | end | ||
| 498 | return _accum_0 | ||
| 499 | end | ||
| 500 | do | ||
| 501 | local index | ||
| 502 | do | ||
| 503 | local _accum_0 | ||
| 504 | for i = 1, #tb do | ||
| 505 | if tb[i] then | ||
| 506 | _accum_0 = i | ||
| 507 | break | ||
| 508 | end | ||
| 509 | end | ||
| 510 | index = _accum_0 | ||
| 511 | end | ||
| 512 | f((function() | ||
| 513 | local _accum_0 | ||
| 514 | for i = 1, #tb do | ||
| 515 | if tb[i] then | ||
| 516 | _accum_0 = i | ||
| 517 | break | ||
| 518 | end | ||
| 519 | end | ||
| 520 | return _accum_0 | ||
| 521 | end)()) | ||
| 522 | f((function() | ||
| 523 | local _accum_0 = { } | ||
| 524 | local _len_0 = 1 | ||
| 525 | for i = 1, #tb do | ||
| 526 | if tb[i] then | ||
| 527 | _accum_0[_len_0] = i | ||
| 528 | _len_0 = _len_0 + 1 | ||
| 529 | end | ||
| 530 | end | ||
| 531 | return _accum_0 | ||
| 532 | end)()) | ||
| 533 | i = 1 | ||
| 534 | local ids | ||
| 535 | do | ||
| 536 | local _accum_0 = { } | ||
| 537 | local _len_0 = 1 | ||
| 538 | while tb[i] do | ||
| 539 | i = i + 1 | ||
| 540 | _accum_0[_len_0] = i - 1 | ||
| 541 | _len_0 = _len_0 + 1 | ||
| 542 | end | ||
| 543 | ids = _accum_0 | ||
| 544 | end | ||
| 545 | i = 1 | ||
| 546 | local idx | ||
| 547 | do | ||
| 548 | local _accum_0 | ||
| 549 | while tb[i] do | ||
| 550 | i = i + 1 | ||
| 551 | _accum_0 = i - 1 | ||
| 552 | break | ||
| 553 | end | ||
| 554 | idx = _accum_0 | ||
| 555 | end | ||
| 556 | local f1 | ||
| 557 | f1 = function() | ||
| 558 | i = 1 | ||
| 559 | return f(_anon_func_0(i, tb)) | ||
| 560 | end | ||
| 561 | i = 1 | ||
| 562 | f((function() | ||
| 563 | local _accum_0 | ||
| 564 | while tb[i] do | ||
| 565 | i = i + 1 | ||
| 566 | _accum_0 = i - 1 | ||
| 567 | break | ||
| 568 | end | ||
| 569 | return _accum_0 | ||
| 570 | end)()) | ||
| 571 | local _accum_0 = { } | ||
| 572 | local _len_0 = 1 | ||
| 573 | local _list_3 = items | ||
| 574 | for _index_0 = 1, #_list_3 do | ||
| 575 | local item = _list_3[_index_0] | ||
| 576 | local _type_0 = type(item) | ||
| 577 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
| 578 | if _tab_0 then | ||
| 579 | local value = item.value | ||
| 580 | if "A" == item.type and value ~= nil then | ||
| 581 | if value > 5 then | ||
| 582 | _accum_0[_len_0] = item | ||
| 583 | _len_0 = _len_0 + 1 | ||
| 584 | end | ||
| 585 | end | ||
| 586 | end | ||
| 587 | end | ||
| 588 | list = _accum_0 | ||
| 589 | end | ||
