diff options
| author | Li Jin <dragon-fly@qq.com> | 2025-06-04 16:53:57 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2025-06-04 16:53:57 +0800 |
| commit | d127557dd0678482e1f91618842f15315f843d5b (patch) | |
| tree | d85d621daacadef49119f47617d82c09fcc78151 /spec/outputs/codes_from_doc_zh.lua | |
| parent | a575de6992cabe0b809e363391563841d6213d4e (diff) | |
| download | yuescript-0.29.0.tar.gz yuescript-0.29.0.tar.bz2 yuescript-0.29.0.zip | |
Updated docs. [skip CI]v0.29.0
Diffstat (limited to 'spec/outputs/codes_from_doc_zh.lua')
| -rw-r--r-- | spec/outputs/codes_from_doc_zh.lua | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua index c6ba43d..bb9af58 100644 --- a/spec/outputs/codes_from_doc_zh.lua +++ b/spec/outputs/codes_from_doc_zh.lua | |||
| @@ -209,6 +209,14 @@ for _key_0, _value_0 in pairs(b) do | |||
| 209 | end | 209 | end |
| 210 | end | 210 | end |
| 211 | merge = _tab_0 | 211 | merge = _tab_0 |
| 212 | print((function() | ||
| 213 | local _item_0 = data.items | ||
| 214 | return _item_0[#_item_0] | ||
| 215 | end)()) | ||
| 216 | print((function() | ||
| 217 | local _item_0 = data.items | ||
| 218 | return _item_0[#_item_0 - 1] | ||
| 219 | end)()) | ||
| 212 | local mt = { } | 220 | local mt = { } |
| 213 | local add | 221 | local add |
| 214 | add = function(self, right) | 222 | add = function(self, right) |
| @@ -587,6 +595,59 @@ end | |||
| 587 | local two, four | 595 | local two, four |
| 588 | local _obj_0 = items | 596 | local _obj_0 = items |
| 589 | two, four = _obj_0[2], _obj_0[4] | 597 | two, four = _obj_0[2], _obj_0[4] |
| 598 | local orders = { | ||
| 599 | "first", | ||
| 600 | "second", | ||
| 601 | "third", | ||
| 602 | "fourth", | ||
| 603 | "last" | ||
| 604 | } | ||
| 605 | local first, bulk, last = orders[1], (function() | ||
| 606 | local _accum_0 = { } | ||
| 607 | local _len_0 = 1 | ||
| 608 | local _max_0 = #orders + -2 + 1 | ||
| 609 | for _index_0 = 2, _max_0 do | ||
| 610 | local _item_0 = orders[_index_0] | ||
| 611 | _accum_0[_len_0] = _item_0 | ||
| 612 | _len_0 = _len_0 + 1 | ||
| 613 | end | ||
| 614 | return _accum_0 | ||
| 615 | end)(), orders[#orders] | ||
| 616 | print(first) | ||
| 617 | print(bulk) | ||
| 618 | print(last) | ||
| 619 | local first, rest | ||
| 620 | do | ||
| 621 | local _obj_0 = orders | ||
| 622 | first, rest = _obj_0[1], (function() | ||
| 623 | local _accum_0 = { } | ||
| 624 | local _len_0 = 1 | ||
| 625 | local _max_0 = #_obj_0 | ||
| 626 | for _index_0 = 2, _max_0 do | ||
| 627 | local _item_0 = _obj_0[_index_0] | ||
| 628 | _accum_0[_len_0] = _item_0 | ||
| 629 | _len_0 = _len_0 + 1 | ||
| 630 | end | ||
| 631 | return _accum_0 | ||
| 632 | end)() | ||
| 633 | end | ||
| 634 | local start, last | ||
| 635 | do | ||
| 636 | local _obj_0 = orders | ||
| 637 | start, last = (function() | ||
| 638 | local _accum_0 = { } | ||
| 639 | local _len_0 = 1 | ||
| 640 | local _max_0 = #_obj_0 + -2 + 1 | ||
| 641 | for _index_0 = 1, _max_0 do | ||
| 642 | local _item_0 = _obj_0[_index_0] | ||
| 643 | _accum_0[_len_0] = _item_0 | ||
| 644 | _len_0 = _len_0 + 1 | ||
| 645 | end | ||
| 646 | return _accum_0 | ||
| 647 | end)(), _obj_0[#_obj_0] | ||
| 648 | end | ||
| 649 | local _obj_0 = orders | ||
| 650 | first, last = _obj_0[1], _obj_0[#_obj_0] | ||
| 590 | local tuples = { | 651 | local tuples = { |
| 591 | { | 652 | { |
| 592 | "hello", | 653 | "hello", |
| @@ -1084,6 +1145,39 @@ for _index_0 = 1, _max_0, 2 do | |||
| 1084 | _len_0 = _len_0 + 1 | 1145 | _len_0 = _len_0 + 1 |
| 1085 | end | 1146 | end |
| 1086 | slice = _accum_0 | 1147 | slice = _accum_0 |
| 1148 | local slice | ||
| 1149 | local _accum_0 = { } | ||
| 1150 | local _len_0 = 1 | ||
| 1151 | local _list_0 = items | ||
| 1152 | local _min_0 = #_list_0 + -4 + 1 | ||
| 1153 | local _max_0 = #_list_0 + -1 + 1 | ||
| 1154 | for _index_0 = _min_0, _max_0 do | ||
| 1155 | local item = _list_0[_index_0] | ||
| 1156 | _accum_0[_len_0] = item | ||
| 1157 | _len_0 = _len_0 + 1 | ||
| 1158 | end | ||
| 1159 | slice = _accum_0 | ||
| 1160 | local reverse_slice | ||
| 1161 | local _accum_0 = { } | ||
| 1162 | local _len_0 = 1 | ||
| 1163 | local _list_0 = items | ||
| 1164 | local _min_0 = #_list_0 + -1 + 1 | ||
| 1165 | for _index_0 = _min_0, 1, -1 do | ||
| 1166 | local item = _list_0[_index_0] | ||
| 1167 | _accum_0[_len_0] = item | ||
| 1168 | _len_0 = _len_0 + 1 | ||
| 1169 | end | ||
| 1170 | reverse_slice = _accum_0 | ||
| 1171 | local sub_list | ||
| 1172 | local _accum_0 = { } | ||
| 1173 | local _len_0 = 1 | ||
| 1174 | local _list_0 = items | ||
| 1175 | for _index_0 = 2, 4 do | ||
| 1176 | local _item_0 = _list_0[_index_0] | ||
| 1177 | _accum_0[_len_0] = _item_0 | ||
| 1178 | _len_0 = _len_0 + 1 | ||
| 1179 | end | ||
| 1180 | sub_list = _accum_0 | ||
| 1087 | for i = 10, 20 do | 1181 | for i = 10, 20 do |
| 1088 | print(i) | 1182 | print(i) |
| 1089 | end | 1183 | end |
| @@ -1535,6 +1629,35 @@ if _tab_0 then | |||
| 1535 | print("匹配成功", fourth) | 1629 | print("匹配成功", fourth) |
| 1536 | end | 1630 | end |
| 1537 | end | 1631 | end |
| 1632 | local segments = { | ||
| 1633 | "admin", | ||
| 1634 | "users", | ||
| 1635 | "logs", | ||
| 1636 | "view" | ||
| 1637 | } | ||
| 1638 | local _type_0 = type(segments) | ||
| 1639 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
| 1640 | if _tab_0 then | ||
| 1641 | local groups | ||
| 1642 | do | ||
| 1643 | local _accum_0 = { } | ||
| 1644 | local _len_0 = 1 | ||
| 1645 | local _max_0 = #segments + -3 + 1 | ||
| 1646 | for _index_0 = 1, _max_0 do | ||
| 1647 | local _item_0 = segments[_index_0] | ||
| 1648 | _accum_0[_len_0] = _item_0 | ||
| 1649 | _len_0 = _len_0 + 1 | ||
| 1650 | end | ||
| 1651 | groups = _accum_0 | ||
| 1652 | end | ||
| 1653 | local resource = segments[#segments - 1] | ||
| 1654 | local action = segments[#segments] | ||
| 1655 | if resource ~= nil and action ~= nil then | ||
| 1656 | print("Group:", groups) | ||
| 1657 | print("Resource:", resource) | ||
| 1658 | print("Action:", action) | ||
| 1659 | end | ||
| 1660 | end | ||
| 1538 | local Inventory | 1661 | local Inventory |
| 1539 | local _class_0 | 1662 | local _class_0 |
| 1540 | local _base_0 = { | 1663 | local _base_0 = { |
| @@ -2474,6 +2597,14 @@ for _key_0, _value_0 in pairs(b) do | |||
| 2474 | end | 2597 | end |
| 2475 | end | 2598 | end |
| 2476 | merge = _tab_0 | 2599 | merge = _tab_0 |
| 2600 | print((function() | ||
| 2601 | local _item_0 = data.items | ||
| 2602 | return _item_0[#_item_0] | ||
| 2603 | end)()) | ||
| 2604 | print((function() | ||
| 2605 | local _item_0 = data.items | ||
| 2606 | return _item_0[#_item_0 - 1] | ||
| 2607 | end)()) | ||
| 2477 | local mt = { } | 2608 | local mt = { } |
| 2478 | local add | 2609 | local add |
| 2479 | add = function(self, right) | 2610 | add = function(self, right) |
| @@ -2852,6 +2983,59 @@ end | |||
| 2852 | local two, four | 2983 | local two, four |
| 2853 | local _obj_0 = items | 2984 | local _obj_0 = items |
| 2854 | two, four = _obj_0[2], _obj_0[4] | 2985 | two, four = _obj_0[2], _obj_0[4] |
| 2986 | local orders = { | ||
| 2987 | "first", | ||
| 2988 | "second", | ||
| 2989 | "third", | ||
| 2990 | "fourth", | ||
| 2991 | "last" | ||
| 2992 | } | ||
| 2993 | local first, bulk, last = orders[1], (function() | ||
| 2994 | local _accum_0 = { } | ||
| 2995 | local _len_0 = 1 | ||
| 2996 | local _max_0 = #orders + -2 + 1 | ||
| 2997 | for _index_0 = 2, _max_0 do | ||
| 2998 | local _item_0 = orders[_index_0] | ||
| 2999 | _accum_0[_len_0] = _item_0 | ||
| 3000 | _len_0 = _len_0 + 1 | ||
| 3001 | end | ||
| 3002 | return _accum_0 | ||
| 3003 | end)(), orders[#orders] | ||
| 3004 | print(first) | ||
| 3005 | print(bulk) | ||
| 3006 | print(last) | ||
| 3007 | local first, rest | ||
| 3008 | do | ||
| 3009 | local _obj_0 = orders | ||
| 3010 | first, rest = _obj_0[1], (function() | ||
| 3011 | local _accum_0 = { } | ||
| 3012 | local _len_0 = 1 | ||
| 3013 | local _max_0 = #_obj_0 | ||
| 3014 | for _index_0 = 2, _max_0 do | ||
| 3015 | local _item_0 = _obj_0[_index_0] | ||
| 3016 | _accum_0[_len_0] = _item_0 | ||
| 3017 | _len_0 = _len_0 + 1 | ||
| 3018 | end | ||
| 3019 | return _accum_0 | ||
| 3020 | end)() | ||
| 3021 | end | ||
| 3022 | local start, last | ||
| 3023 | do | ||
| 3024 | local _obj_0 = orders | ||
| 3025 | start, last = (function() | ||
| 3026 | local _accum_0 = { } | ||
| 3027 | local _len_0 = 1 | ||
| 3028 | local _max_0 = #_obj_0 + -2 + 1 | ||
| 3029 | for _index_0 = 1, _max_0 do | ||
| 3030 | local _item_0 = _obj_0[_index_0] | ||
| 3031 | _accum_0[_len_0] = _item_0 | ||
| 3032 | _len_0 = _len_0 + 1 | ||
| 3033 | end | ||
| 3034 | return _accum_0 | ||
| 3035 | end)(), _obj_0[#_obj_0] | ||
| 3036 | end | ||
| 3037 | local _obj_0 = orders | ||
| 3038 | first, last = _obj_0[1], _obj_0[#_obj_0] | ||
| 2855 | local tuples = { | 3039 | local tuples = { |
| 2856 | { | 3040 | { |
| 2857 | "hello", | 3041 | "hello", |
| @@ -3348,6 +3532,39 @@ for _index_0 = 1, _max_0, 2 do | |||
| 3348 | _len_0 = _len_0 + 1 | 3532 | _len_0 = _len_0 + 1 |
| 3349 | end | 3533 | end |
| 3350 | slice = _accum_0 | 3534 | slice = _accum_0 |
| 3535 | local slice | ||
| 3536 | local _accum_0 = { } | ||
| 3537 | local _len_0 = 1 | ||
| 3538 | local _list_0 = items | ||
| 3539 | local _min_0 = #_list_0 + -4 + 1 | ||
| 3540 | local _max_0 = #_list_0 + -1 + 1 | ||
| 3541 | for _index_0 = _min_0, _max_0 do | ||
| 3542 | local item = _list_0[_index_0] | ||
| 3543 | _accum_0[_len_0] = item | ||
| 3544 | _len_0 = _len_0 + 1 | ||
| 3545 | end | ||
| 3546 | slice = _accum_0 | ||
| 3547 | local reverse_slice | ||
| 3548 | local _accum_0 = { } | ||
| 3549 | local _len_0 = 1 | ||
| 3550 | local _list_0 = items | ||
| 3551 | local _min_0 = #_list_0 + -1 + 1 | ||
| 3552 | for _index_0 = _min_0, 1, -1 do | ||
| 3553 | local item = _list_0[_index_0] | ||
| 3554 | _accum_0[_len_0] = item | ||
| 3555 | _len_0 = _len_0 + 1 | ||
| 3556 | end | ||
| 3557 | reverse_slice = _accum_0 | ||
| 3558 | local sub_list | ||
| 3559 | local _accum_0 = { } | ||
| 3560 | local _len_0 = 1 | ||
| 3561 | local _list_0 = items | ||
| 3562 | for _index_0 = 2, 4 do | ||
| 3563 | local _item_0 = _list_0[_index_0] | ||
| 3564 | _accum_0[_len_0] = _item_0 | ||
| 3565 | _len_0 = _len_0 + 1 | ||
| 3566 | end | ||
| 3567 | sub_list = _accum_0 | ||
| 3351 | for i = 10, 20 do | 3568 | for i = 10, 20 do |
| 3352 | print(i) | 3569 | print(i) |
| 3353 | end | 3570 | end |
| @@ -3799,6 +4016,35 @@ if _tab_0 then | |||
| 3799 | print("匹配成功", fourth) | 4016 | print("匹配成功", fourth) |
| 3800 | end | 4017 | end |
| 3801 | end | 4018 | end |
| 4019 | local segments = { | ||
| 4020 | "admin", | ||
| 4021 | "users", | ||
| 4022 | "logs", | ||
| 4023 | "view" | ||
| 4024 | } | ||
| 4025 | local _type_0 = type(segments) | ||
| 4026 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
| 4027 | if _tab_0 then | ||
| 4028 | local groups | ||
| 4029 | do | ||
| 4030 | local _accum_0 = { } | ||
| 4031 | local _len_0 = 1 | ||
| 4032 | local _max_0 = #segments + -3 + 1 | ||
| 4033 | for _index_0 = 1, _max_0 do | ||
| 4034 | local _item_0 = segments[_index_0] | ||
| 4035 | _accum_0[_len_0] = _item_0 | ||
| 4036 | _len_0 = _len_0 + 1 | ||
| 4037 | end | ||
| 4038 | groups = _accum_0 | ||
| 4039 | end | ||
| 4040 | local resource = segments[#segments - 1] | ||
| 4041 | local action = segments[#segments] | ||
| 4042 | if resource ~= nil and action ~= nil then | ||
| 4043 | print("Group:", groups) | ||
| 4044 | print("Resource:", resource) | ||
| 4045 | print("Action:", action) | ||
| 4046 | end | ||
| 4047 | end | ||
| 3802 | local Inventory | 4048 | local Inventory |
| 3803 | local _class_0 | 4049 | local _class_0 |
| 3804 | local _base_0 = { | 4050 | local _base_0 = { |
