aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/codes_from_doc_zh.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/outputs/codes_from_doc_zh.lua')
-rw-r--r--spec/outputs/codes_from_doc_zh.lua844
1 files changed, 824 insertions, 20 deletions
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua
index ffa0483..b54d6d7 100644
--- a/spec/outputs/codes_from_doc_zh.lua
+++ b/spec/outputs/codes_from_doc_zh.lua
@@ -20,6 +20,38 @@ local inventory = {
20 } 20 }
21 } 21 }
22} 22}
23local map
24map = function(arr, action)
25 local _accum_0 = { }
26 local _len_0 = 1
27 for _index_0 = 1, #arr do
28 local item = arr[_index_0]
29 _accum_0[_len_0] = action(item)
30 _len_0 = _len_0 + 1
31 end
32 return _accum_0
33end
34local filter
35filter = function(arr, cond)
36 local _accum_0 = { }
37 local _len_0 = 1
38 for _index_0 = 1, #arr do
39 local item = arr[_index_0]
40 if cond(item) then
41 _accum_0[_len_0] = item
42 _len_0 = _len_0 + 1
43 end
44 end
45 return _accum_0
46end
47local reduce
48reduce = function(arr, init, action)
49 for _index_0 = 1, #arr do
50 local item = arr[_index_0]
51 init = action(init, item)
52 end
53 return init
54end
23print(reduce(filter(map({ 55print(reduce(filter(map({
24 1, 56 1,
25 2, 57 2,
@@ -77,6 +109,12 @@ end
77print("yuescript") 109print("yuescript")
78print(3) 110print(3)
79print("有效的枚举类型:", "Static") 111print("有效的枚举类型:", "Static")
112do
113 print(123, "hello")
114end
115do
116 print(123, "hello")
117end
80if tb ~= nil then 118if tb ~= nil then
81 tb:func() 119 tb:func()
82end 120end
@@ -177,6 +215,16 @@ for _key_0, _value_0 in pairs(b) do
177 end 215 end
178end 216end
179merge = _tab_0 217merge = _tab_0
218local last
219do
220 local _item_0 = data.items
221 last = _item_0[#_item_0]
222end
223local second_last
224do
225 local _item_0 = data.items
226 second_last = _item_0[#_item_0 - 1]
227end
180local mt = { } 228local mt = { }
181local add 229local add
182add = function(self, right) 230add = function(self, right)
@@ -307,6 +355,14 @@ func({
307 2, 355 2,
308 3 356 3
309}) 357})
358local f
359f = function()
360 return {
361 1,
362 2,
363 3
364 }
365end
310local tb = { 366local tb = {
311 name = "abc", 367 name = "abc",
312 values = { 368 values = {
@@ -547,6 +603,59 @@ end
547local two, four 603local two, four
548local _obj_0 = items 604local _obj_0 = items
549two, four = _obj_0[2], _obj_0[4] 605two, four = _obj_0[2], _obj_0[4]
606local orders = {
607 "first",
608 "second",
609 "third",
610 "fourth",
611 "last"
612}
613local first, bulk, last = orders[1], (function()
614 local _accum_0 = { }
615 local _len_0 = 1
616 local _max_0 = #orders + -2 + 1
617 for _index_0 = 2, _max_0 do
618 local _item_0 = orders[_index_0]
619 _accum_0[_len_0] = _item_0
620 _len_0 = _len_0 + 1
621 end
622 return _accum_0
623end)(), orders[#orders]
624print(first)
625print(bulk)
626print(last)
627local first, rest
628do
629 local _obj_0 = orders
630 first, rest = _obj_0[1], (function()
631 local _accum_0 = { }
632 local _len_0 = 1
633 local _max_0 = #_obj_0
634 for _index_0 = 2, _max_0 do
635 local _item_0 = _obj_0[_index_0]
636 _accum_0[_len_0] = _item_0
637 _len_0 = _len_0 + 1
638 end
639 return _accum_0
640 end)()
641end
642local start, last
643do
644 local _obj_0 = orders
645 start, last = (function()
646 local _accum_0 = { }
647 local _len_0 = 1
648 local _max_0 = #_obj_0 + -2 + 1
649 for _index_0 = 1, _max_0 do
650 local _item_0 = _obj_0[_index_0]
651 _accum_0[_len_0] = _item_0
652 _len_0 = _len_0 + 1
653 end
654 return _accum_0
655 end)(), _obj_0[#_obj_0]
656end
657local _obj_0 = orders
658first, last = _obj_0[1], _obj_0[#_obj_0]
550local tuples = { 659local tuples = {
551 { 660 {
552 "hello", 661 "hello",
@@ -648,6 +757,56 @@ end)
648if success then 757if success then
649 print(result) 758 print(result)
650end 759end
760local a, b, c
761do
762 local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function()
763 return func()
764 end)
765 if _ok_0 then
766 a, b, c = _ret_0, _ret_1, _ret_2
767 end
768end
769do
770 local _exp_0 = ((function()
771 return (function(_arg_0, ...)
772 local _ok_0 = _arg_0
773 if _ok_0 then
774 return ...
775 end
776 end)(pcall(function()
777 return func()
778 end))
779 end)())
780 if _exp_0 ~= nil then
781 a = _exp_0
782 else
783 a = "default"
784 end
785end
786f((function()
787 return (function(_arg_0, ...)
788 local _ok_0 = _arg_0
789 if _ok_0 then
790 return ...
791 end
792 end)(pcall(function()
793 return func()
794 end))
795end)())
796f((function()
797 return (function(_arg_0, ...)
798 local _ok_0 = _arg_0
799 if _ok_0 then
800 return ...
801 end
802 end)(xpcall(function()
803 print(123)
804 return func()
805 end, function(e)
806 print(e)
807 return e
808 end))
809end)())
651local a <const> = 123 810local a <const> = 123
652local _ <close> = setmetatable({ }, { 811local _ <close> = setmetatable({ }, {
653 __close = function() 812 __close = function()
@@ -657,10 +816,19 @@ local _ <close> = setmetatable({ }, {
657local a, b, c, d 816local a, b, c, d
658local _obj_0 = tb 817local _obj_0 = tb
659a, b, c, d = _obj_0.a, _obj_0.b, _obj_0[1], _obj_0[2] 818a, b, c, d = _obj_0.a, _obj_0.b, _obj_0[1], _obj_0[2]
819Constant = 123
660local some_string = "这是一个字符串\n 并包括一个换行。" 820local some_string = "这是一个字符串\n 并包括一个换行。"
661print("我有" .. tostring(math.random() * 100) .. "%的把握。") 821print("我有" .. tostring(math.random() * 100) .. "%的把握。")
662local integer = 1000000 822local integer = 1000000
663local hex = 0xEFBBBF 823local hex = 0xEFBBBF
824local binary = 19
825local str = "key: value\nlist:\n - item1\n - " .. tostring(expr)
826local fn
827fn = function()
828 local str = "foo:\n bar: baz"
829 return str
830end
831local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'"
664local my_function 832local my_function
665my_function = function() end 833my_function = function() end
666my_function() 834my_function()
@@ -854,11 +1022,10 @@ for i, item in ipairs(items) do
854 _len_0 = _len_0 + 1 1022 _len_0 = _len_0 + 1
855end 1023end
856doubled = _accum_0 1024doubled = _accum_0
857local iter = ipairs(items)
858local slice 1025local slice
859local _accum_0 = { } 1026local _accum_0 = { }
860local _len_0 = 1 1027local _len_0 = 1
861for i, item in iter do 1028for i, item in ipairs(items) do
862 if i > 1 and i < 3 then 1029 if i > 1 and i < 3 then
863 _accum_0[_len_0] = item 1030 _accum_0[_len_0] = item
864 _len_0 = _len_0 + 1 1031 _len_0 = _len_0 + 1
@@ -965,8 +1132,7 @@ local slice
965local _accum_0 = { } 1132local _accum_0 = { }
966local _len_0 = 1 1133local _len_0 = 1
967local _list_0 = items 1134local _list_0 = items
968local _max_0 = 5 1135for _index_0 = 1, 5 do
969for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
970 local item = _list_0[_index_0] 1136 local item = _list_0[_index_0]
971 _accum_0[_len_0] = item 1137 _accum_0[_len_0] = item
972 _len_0 = _len_0 + 1 1138 _len_0 = _len_0 + 1
@@ -976,7 +1142,8 @@ local slice
976local _accum_0 = { } 1142local _accum_0 = { }
977local _len_0 = 1 1143local _len_0 = 1
978local _list_0 = items 1144local _list_0 = items
979for _index_0 = 2, #_list_0 do 1145local _max_0 = #_list_0
1146for _index_0 = 2, _max_0 do
980 local item = _list_0[_index_0] 1147 local item = _list_0[_index_0]
981 _accum_0[_len_0] = item 1148 _accum_0[_len_0] = item
982 _len_0 = _len_0 + 1 1149 _len_0 = _len_0 + 1
@@ -986,12 +1153,46 @@ local slice
986local _accum_0 = { } 1153local _accum_0 = { }
987local _len_0 = 1 1154local _len_0 = 1
988local _list_0 = items 1155local _list_0 = items
989for _index_0 = 1, #_list_0, 2 do 1156local _max_0 = #_list_0
1157for _index_0 = 1, _max_0, 2 do
990 local item = _list_0[_index_0] 1158 local item = _list_0[_index_0]
991 _accum_0[_len_0] = item 1159 _accum_0[_len_0] = item
992 _len_0 = _len_0 + 1 1160 _len_0 = _len_0 + 1
993end 1161end
994slice = _accum_0 1162slice = _accum_0
1163local slice
1164local _accum_0 = { }
1165local _len_0 = 1
1166local _list_0 = items
1167local _min_0 = #_list_0 + -4 + 1
1168local _max_0 = #_list_0 + -1 + 1
1169for _index_0 = _min_0, _max_0 do
1170 local item = _list_0[_index_0]
1171 _accum_0[_len_0] = item
1172 _len_0 = _len_0 + 1
1173end
1174slice = _accum_0
1175local reverse_slice
1176local _accum_0 = { }
1177local _len_0 = 1
1178local _list_0 = items
1179local _min_0 = #_list_0 + -1 + 1
1180for _index_0 = _min_0, 1, -1 do
1181 local item = _list_0[_index_0]
1182 _accum_0[_len_0] = item
1183 _len_0 = _len_0 + 1
1184end
1185reverse_slice = _accum_0
1186local sub_list
1187local _accum_0 = { }
1188local _len_0 = 1
1189local _list_0 = items
1190for _index_0 = 2, 4 do
1191 local _item_0 = _list_0[_index_0]
1192 _accum_0[_len_0] = _item_0
1193 _len_0 = _len_0 + 1
1194end
1195sub_list = _accum_0
995for i = 10, 20 do 1196for i = 10, 20 do
996 print(i) 1197 print(i)
997end 1198end
@@ -1002,8 +1203,7 @@ for key, value in pairs(object) do
1002 print(key, value) 1203 print(key, value)
1003end 1204end
1004local _list_0 = items 1205local _list_0 = items
1005local _max_0 = 4 1206for _index_0 = 2, 4 do
1006for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
1007 local item = _list_0[_index_0] 1207 local item = _list_0[_index_0]
1008 print(item) 1208 print(item)
1009end 1209end
@@ -1021,12 +1221,24 @@ local _len_0 = 1
1021for i = 1, 20 do 1221for i = 1, 20 do
1022 if i % 2 == 0 then 1222 if i % 2 == 0 then
1023 _accum_0[_len_0] = i * 2 1223 _accum_0[_len_0] = i * 2
1224 _len_0 = _len_0 + 1
1024 else 1225 else
1025 _accum_0[_len_0] = i 1226 _accum_0[_len_0] = i
1227 _len_0 = _len_0 + 1
1026 end 1228 end
1027 _len_0 = _len_0 + 1
1028end 1229end
1029doubled_evens = _accum_0 1230doubled_evens = _accum_0
1231local first_large
1232local _accum_0
1233local _list_0 = numbers
1234for _index_0 = 1, #_list_0 do
1235 local n = _list_0[_index_0]
1236 if n > 10 then
1237 _accum_0 = n
1238 break
1239 end
1240end
1241first_large = _accum_0
1030local func_a 1242local func_a
1031func_a = function() 1243func_a = function()
1032 for i = 1, 10 do 1244 for i = 1, 10 do
@@ -1175,7 +1387,7 @@ if "Robert" == name then
1175elseif "Dan" == name or "Daniel" == name then 1387elseif "Dan" == name or "Daniel" == name then
1176 print("你的名字是Dan") 1388 print("你的名字是Dan")
1177else 1389else
1178 print("我不知道你的名字") 1390 print("我不认识,你的名字" .. tostring(name))
1179end 1391end
1180local b = 1 1392local b = 1
1181local next_number 1393local next_number
@@ -1275,6 +1487,192 @@ if _tab_0 then
1275 end 1487 end
1276 print("Vec2 " .. tostring(x) .. ", " .. tostring(y)) 1488 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
1277end 1489end
1490local _exp_0 = tb
1491local _type_0 = type(_exp_0)
1492local _tab_0 = "table" == _type_0 or "userdata" == _type_0
1493local _match_0 = false
1494if _tab_0 then
1495 if 1 == _exp_0[1] and 2 == _exp_0[2] and 3 == _exp_0[3] then
1496 _match_0 = true
1497 print("1, 2, 3")
1498 end
1499end
1500if not _match_0 then
1501 local _match_1 = false
1502 if _tab_0 then
1503 local b = _exp_0[2]
1504 if 1 == _exp_0[1] and b ~= nil and 3 == _exp_0[3] then
1505 _match_1 = true
1506 print("1, " .. tostring(b) .. ", 3")
1507 end
1508 end
1509 if not _match_1 then
1510 if _tab_0 then
1511 local b = _exp_0[3]
1512 if b == nil then
1513 b = 3
1514 end
1515 if 1 == _exp_0[1] and 2 == _exp_0[2] then
1516 print("1, 2, " .. tostring(b))
1517 end
1518 end
1519 end
1520end
1521local _exp_0 = tb
1522local _type_0 = type(_exp_0)
1523local _tab_0 = "table" == _type_0 or "userdata" == _type_0
1524local _match_0 = false
1525if _tab_0 then
1526 local result = _exp_0.result
1527 if true == _exp_0.success and result ~= nil then
1528 _match_0 = true
1529 print("成功", result)
1530 end
1531end
1532if not _match_0 then
1533 local _match_1 = false
1534 if _tab_0 then
1535 if false == _exp_0.success then
1536 _match_1 = true
1537 print("失败", result)
1538 end
1539 end
1540 if not _match_1 then
1541 print("无效值")
1542 end
1543end
1544local _exp_0 = tb
1545local _type_0 = type(_exp_0)
1546local _tab_0 = "table" == _type_0 or "userdata" == _type_0
1547local _match_0 = false
1548if _tab_0 then
1549 local content
1550 do
1551 local _obj_0 = _exp_0.data
1552 local _type_1 = type(_obj_0)
1553 if "table" == _type_1 or "userdata" == _type_1 then
1554 content = _obj_0.content
1555 end
1556 end
1557 local _val_0
1558 do
1559 local _obj_0 = _exp_0.data
1560 if _obj_0 ~= nil then
1561 _val_0 = _obj_0.type
1562 end
1563 end
1564 if "success" == _val_0 and content ~= nil then
1565 _match_0 = true
1566 print("成功", content)
1567 end
1568end
1569if not _match_0 then
1570 local _match_1 = false
1571 if _tab_0 then
1572 local content
1573 do
1574 local _obj_0 = _exp_0.data
1575 local _type_1 = type(_obj_0)
1576 if "table" == _type_1 or "userdata" == _type_1 then
1577 content = _obj_0.content
1578 end
1579 end
1580 local _val_0
1581 do
1582 local _obj_0 = _exp_0.data
1583 if _obj_0 ~= nil then
1584 _val_0 = _obj_0.type
1585 end
1586 end
1587 if "error" == _val_0 and content ~= nil then
1588 _match_1 = true
1589 print("失败", content)
1590 end
1591 end
1592 if not _match_1 then
1593 print("无效值")
1594 end
1595end
1596local _exp_0 = tb
1597local _type_0 = type(_exp_0)
1598local _tab_0 = "table" == _type_0 or "userdata" == _type_0
1599if _tab_0 then
1600 local fourth = _exp_0[4]
1601 local _val_0
1602 do
1603 local _obj_0 = _exp_0[1]
1604 if _obj_0 ~= nil then
1605 _val_0 = _obj_0.a
1606 end
1607 end
1608 local _val_1
1609 do
1610 local _obj_0 = _exp_0[1]
1611 if _obj_0 ~= nil then
1612 _val_1 = _obj_0.b
1613 end
1614 end
1615 local _val_2
1616 do
1617 local _obj_0 = _exp_0[2]
1618 if _obj_0 ~= nil then
1619 _val_2 = _obj_0.a
1620 end
1621 end
1622 local _val_3
1623 do
1624 local _obj_0 = _exp_0[2]
1625 if _obj_0 ~= nil then
1626 _val_3 = _obj_0.b
1627 end
1628 end
1629 local _val_4
1630 do
1631 local _obj_0 = _exp_0[3]
1632 if _obj_0 ~= nil then
1633 _val_4 = _obj_0.a
1634 end
1635 end
1636 local _val_5
1637 do
1638 local _obj_0 = _exp_0[3]
1639 if _obj_0 ~= nil then
1640 _val_5 = _obj_0.b
1641 end
1642 end
1643 if 1 == _val_0 and 2 == _val_1 and 3 == _val_2 and 4 == _val_3 and 5 == _val_4 and 6 == _val_5 and fourth ~= nil then
1644 print("匹配成功", fourth)
1645 end
1646end
1647local segments = {
1648 "admin",
1649 "users",
1650 "logs",
1651 "view"
1652}
1653local _type_0 = type(segments)
1654local _tab_0 = "table" == _type_0 or "userdata" == _type_0
1655if _tab_0 then
1656 local groups
1657 do
1658 local _accum_0 = { }
1659 local _len_0 = 1
1660 local _max_0 = #segments + -3 + 1
1661 for _index_0 = 1, _max_0 do
1662 local _item_0 = segments[_index_0]
1663 _accum_0[_len_0] = _item_0
1664 _len_0 = _len_0 + 1
1665 end
1666 groups = _accum_0
1667 end
1668 local resource = segments[#segments - 1]
1669 local action = segments[#segments]
1670 if resource ~= nil and action ~= nil then
1671 print("Group:", groups)
1672 print("Resource:", resource)
1673 print("Action:", action)
1674 end
1675end
1278local Inventory 1676local Inventory
1279local _class_0 1677local _class_0
1280local _base_0 = { 1678local _base_0 = {
@@ -1931,6 +2329,10 @@ do
1931 _with_1["key-name"] = value 2329 _with_1["key-name"] = value
1932end 2330end
1933_with_0[#_with_0 + 1] = "abc" 2331_with_0[#_with_0 + 1] = "abc"
2332local _with_0 = obj
2333if _with_0 ~= nil then
2334 print(obj.name)
2335end
1934do 2336do
1935 local var = "hello" 2337 local var = "hello"
1936 print(var) 2338 print(var)
@@ -2021,6 +2423,38 @@ local inventory = {
2021 } 2423 }
2022 } 2424 }
2023} 2425}
2426local map
2427map = function(arr, action)
2428 local _accum_0 = { }
2429 local _len_0 = 1
2430 for _index_0 = 1, #arr do
2431 local item = arr[_index_0]
2432 _accum_0[_len_0] = action(item)
2433 _len_0 = _len_0 + 1
2434 end
2435 return _accum_0
2436end
2437local filter
2438filter = function(arr, cond)
2439 local _accum_0 = { }
2440 local _len_0 = 1
2441 for _index_0 = 1, #arr do
2442 local item = arr[_index_0]
2443 if cond(item) then
2444 _accum_0[_len_0] = item
2445 _len_0 = _len_0 + 1
2446 end
2447 end
2448 return _accum_0
2449end
2450local reduce
2451reduce = function(arr, init, action)
2452 for _index_0 = 1, #arr do
2453 local item = arr[_index_0]
2454 init = action(init, item)
2455 end
2456 return init
2457end
2024print(reduce(filter(map({ 2458print(reduce(filter(map({
2025 1, 2459 1,
2026 2, 2460 2,
@@ -2078,6 +2512,12 @@ end
2078print("yuescript") 2512print("yuescript")
2079print(3) 2513print(3)
2080print("有效的枚举类型:", "Static") 2514print("有效的枚举类型:", "Static")
2515do
2516 print(123, "hello")
2517end
2518do
2519 print(123, "hello")
2520end
2081if tb ~= nil then 2521if tb ~= nil then
2082 tb:func() 2522 tb:func()
2083end 2523end
@@ -2178,6 +2618,16 @@ for _key_0, _value_0 in pairs(b) do
2178 end 2618 end
2179end 2619end
2180merge = _tab_0 2620merge = _tab_0
2621local last
2622do
2623 local _item_0 = data.items
2624 last = _item_0[#_item_0]
2625end
2626local second_last
2627do
2628 local _item_0 = data.items
2629 second_last = _item_0[#_item_0 - 1]
2630end
2181local mt = { } 2631local mt = { }
2182local add 2632local add
2183add = function(self, right) 2633add = function(self, right)
@@ -2308,6 +2758,14 @@ func({
2308 2, 2758 2,
2309 3 2759 3
2310}) 2760})
2761local f
2762f = function()
2763 return {
2764 1,
2765 2,
2766 3
2767 }
2768end
2311local tb = { 2769local tb = {
2312 name = "abc", 2770 name = "abc",
2313 values = { 2771 values = {
@@ -2548,6 +3006,59 @@ end
2548local two, four 3006local two, four
2549local _obj_0 = items 3007local _obj_0 = items
2550two, four = _obj_0[2], _obj_0[4] 3008two, four = _obj_0[2], _obj_0[4]
3009local orders = {
3010 "first",
3011 "second",
3012 "third",
3013 "fourth",
3014 "last"
3015}
3016local first, bulk, last = orders[1], (function()
3017 local _accum_0 = { }
3018 local _len_0 = 1
3019 local _max_0 = #orders + -2 + 1
3020 for _index_0 = 2, _max_0 do
3021 local _item_0 = orders[_index_0]
3022 _accum_0[_len_0] = _item_0
3023 _len_0 = _len_0 + 1
3024 end
3025 return _accum_0
3026end)(), orders[#orders]
3027print(first)
3028print(bulk)
3029print(last)
3030local first, rest
3031do
3032 local _obj_0 = orders
3033 first, rest = _obj_0[1], (function()
3034 local _accum_0 = { }
3035 local _len_0 = 1
3036 local _max_0 = #_obj_0
3037 for _index_0 = 2, _max_0 do
3038 local _item_0 = _obj_0[_index_0]
3039 _accum_0[_len_0] = _item_0
3040 _len_0 = _len_0 + 1
3041 end
3042 return _accum_0
3043 end)()
3044end
3045local start, last
3046do
3047 local _obj_0 = orders
3048 start, last = (function()
3049 local _accum_0 = { }
3050 local _len_0 = 1
3051 local _max_0 = #_obj_0 + -2 + 1
3052 for _index_0 = 1, _max_0 do
3053 local _item_0 = _obj_0[_index_0]
3054 _accum_0[_len_0] = _item_0
3055 _len_0 = _len_0 + 1
3056 end
3057 return _accum_0
3058 end)(), _obj_0[#_obj_0]
3059end
3060local _obj_0 = orders
3061first, last = _obj_0[1], _obj_0[#_obj_0]
2551local tuples = { 3062local tuples = {
2552 { 3063 {
2553 "hello", 3064 "hello",
@@ -2649,6 +3160,56 @@ end)
2649if success then 3160if success then
2650 print(result) 3161 print(result)
2651end 3162end
3163local a, b, c
3164do
3165 local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function()
3166 return func()
3167 end)
3168 if _ok_0 then
3169 a, b, c = _ret_0, _ret_1, _ret_2
3170 end
3171end
3172do
3173 local _exp_0 = ((function()
3174 return (function(_arg_0, ...)
3175 local _ok_0 = _arg_0
3176 if _ok_0 then
3177 return ...
3178 end
3179 end)(pcall(function()
3180 return func()
3181 end))
3182 end)())
3183 if _exp_0 ~= nil then
3184 a = _exp_0
3185 else
3186 a = "default"
3187 end
3188end
3189f((function()
3190 return (function(_arg_0, ...)
3191 local _ok_0 = _arg_0
3192 if _ok_0 then
3193 return ...
3194 end
3195 end)(pcall(function()
3196 return func()
3197 end))
3198end)())
3199f((function()
3200 return (function(_arg_0, ...)
3201 local _ok_0 = _arg_0
3202 if _ok_0 then
3203 return ...
3204 end
3205 end)(xpcall(function()
3206 print(123)
3207 return func()
3208 end, function(e)
3209 print(e)
3210 return e
3211 end))
3212end)())
2652local a <const> = 123 3213local a <const> = 123
2653local _ <close> = setmetatable({ }, { 3214local _ <close> = setmetatable({ }, {
2654 __close = function() 3215 __close = function()
@@ -2658,10 +3219,19 @@ local _ <close> = setmetatable({ }, {
2658local a, b, c, d 3219local a, b, c, d
2659local _obj_0 = tb 3220local _obj_0 = tb
2660a, b, c, d = _obj_0.a, _obj_0.b, _obj_0[1], _obj_0[2] 3221a, b, c, d = _obj_0.a, _obj_0.b, _obj_0[1], _obj_0[2]
3222Constant = 123
2661local some_string = "这是一个字符串\n 并包括一个换行。" 3223local some_string = "这是一个字符串\n 并包括一个换行。"
2662print("我有" .. tostring(math.random() * 100) .. "%的把握。") 3224print("我有" .. tostring(math.random() * 100) .. "%的把握。")
2663local integer = 1000000 3225local integer = 1000000
2664local hex = 0xEFBBBF 3226local hex = 0xEFBBBF
3227local binary = 19
3228local str = "key: value\nlist:\n - item1\n - " .. tostring(expr)
3229local fn
3230fn = function()
3231 local str = "foo:\n bar: baz"
3232 return str
3233end
3234local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'"
2665local my_function 3235local my_function
2666my_function = function() end 3236my_function = function() end
2667my_function() 3237my_function()
@@ -2855,11 +3425,10 @@ for i, item in ipairs(items) do
2855 _len_0 = _len_0 + 1 3425 _len_0 = _len_0 + 1
2856end 3426end
2857doubled = _accum_0 3427doubled = _accum_0
2858local iter = ipairs(items)
2859local slice 3428local slice
2860local _accum_0 = { } 3429local _accum_0 = { }
2861local _len_0 = 1 3430local _len_0 = 1
2862for i, item in iter do 3431for i, item in ipairs(items) do
2863 if i > 1 and i < 3 then 3432 if i > 1 and i < 3 then
2864 _accum_0[_len_0] = item 3433 _accum_0[_len_0] = item
2865 _len_0 = _len_0 + 1 3434 _len_0 = _len_0 + 1
@@ -2966,8 +3535,7 @@ local slice
2966local _accum_0 = { } 3535local _accum_0 = { }
2967local _len_0 = 1 3536local _len_0 = 1
2968local _list_0 = items 3537local _list_0 = items
2969local _max_0 = 5 3538for _index_0 = 1, 5 do
2970for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
2971 local item = _list_0[_index_0] 3539 local item = _list_0[_index_0]
2972 _accum_0[_len_0] = item 3540 _accum_0[_len_0] = item
2973 _len_0 = _len_0 + 1 3541 _len_0 = _len_0 + 1
@@ -2977,7 +3545,8 @@ local slice
2977local _accum_0 = { } 3545local _accum_0 = { }
2978local _len_0 = 1 3546local _len_0 = 1
2979local _list_0 = items 3547local _list_0 = items
2980for _index_0 = 2, #_list_0 do 3548local _max_0 = #_list_0
3549for _index_0 = 2, _max_0 do
2981 local item = _list_0[_index_0] 3550 local item = _list_0[_index_0]
2982 _accum_0[_len_0] = item 3551 _accum_0[_len_0] = item
2983 _len_0 = _len_0 + 1 3552 _len_0 = _len_0 + 1
@@ -2987,12 +3556,46 @@ local slice
2987local _accum_0 = { } 3556local _accum_0 = { }
2988local _len_0 = 1 3557local _len_0 = 1
2989local _list_0 = items 3558local _list_0 = items
2990for _index_0 = 1, #_list_0, 2 do 3559local _max_0 = #_list_0
3560for _index_0 = 1, _max_0, 2 do
2991 local item = _list_0[_index_0] 3561 local item = _list_0[_index_0]
2992 _accum_0[_len_0] = item 3562 _accum_0[_len_0] = item
2993 _len_0 = _len_0 + 1 3563 _len_0 = _len_0 + 1
2994end 3564end
2995slice = _accum_0 3565slice = _accum_0
3566local slice
3567local _accum_0 = { }
3568local _len_0 = 1
3569local _list_0 = items
3570local _min_0 = #_list_0 + -4 + 1
3571local _max_0 = #_list_0 + -1 + 1
3572for _index_0 = _min_0, _max_0 do
3573 local item = _list_0[_index_0]
3574 _accum_0[_len_0] = item
3575 _len_0 = _len_0 + 1
3576end
3577slice = _accum_0
3578local reverse_slice
3579local _accum_0 = { }
3580local _len_0 = 1
3581local _list_0 = items
3582local _min_0 = #_list_0 + -1 + 1
3583for _index_0 = _min_0, 1, -1 do
3584 local item = _list_0[_index_0]
3585 _accum_0[_len_0] = item
3586 _len_0 = _len_0 + 1
3587end
3588reverse_slice = _accum_0
3589local sub_list
3590local _accum_0 = { }
3591local _len_0 = 1
3592local _list_0 = items
3593for _index_0 = 2, 4 do
3594 local _item_0 = _list_0[_index_0]
3595 _accum_0[_len_0] = _item_0
3596 _len_0 = _len_0 + 1
3597end
3598sub_list = _accum_0
2996for i = 10, 20 do 3599for i = 10, 20 do
2997 print(i) 3600 print(i)
2998end 3601end
@@ -3003,8 +3606,7 @@ for key, value in pairs(object) do
3003 print(key, value) 3606 print(key, value)
3004end 3607end
3005local _list_0 = items 3608local _list_0 = items
3006local _max_0 = 4 3609for _index_0 = 2, 4 do
3007for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
3008 local item = _list_0[_index_0] 3610 local item = _list_0[_index_0]
3009 print(item) 3611 print(item)
3010end 3612end
@@ -3022,12 +3624,24 @@ local _len_0 = 1
3022for i = 1, 20 do 3624for i = 1, 20 do
3023 if i % 2 == 0 then 3625 if i % 2 == 0 then
3024 _accum_0[_len_0] = i * 2 3626 _accum_0[_len_0] = i * 2
3627 _len_0 = _len_0 + 1
3025 else 3628 else
3026 _accum_0[_len_0] = i 3629 _accum_0[_len_0] = i
3630 _len_0 = _len_0 + 1
3027 end 3631 end
3028 _len_0 = _len_0 + 1
3029end 3632end
3030doubled_evens = _accum_0 3633doubled_evens = _accum_0
3634local first_large
3635local _accum_0
3636local _list_0 = numbers
3637for _index_0 = 1, #_list_0 do
3638 local n = _list_0[_index_0]
3639 if n > 10 then
3640 _accum_0 = n
3641 break
3642 end
3643end
3644first_large = _accum_0
3031local func_a 3645local func_a
3032func_a = function() 3646func_a = function()
3033 for i = 1, 10 do 3647 for i = 1, 10 do
@@ -3176,7 +3790,7 @@ if "Robert" == name then
3176elseif "Dan" == name or "Daniel" == name then 3790elseif "Dan" == name or "Daniel" == name then
3177 print("你的名字是Dan") 3791 print("你的名字是Dan")
3178else 3792else
3179 print("我不知道你的名字") 3793 print("我不认识,你的名字" .. tostring(name))
3180end 3794end
3181local b = 1 3795local b = 1
3182local next_number 3796local next_number
@@ -3276,6 +3890,192 @@ if _tab_0 then
3276 end 3890 end
3277 print("Vec2 " .. tostring(x) .. ", " .. tostring(y)) 3891 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3278end 3892end
3893local _exp_0 = tb
3894local _type_0 = type(_exp_0)
3895local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3896local _match_0 = false
3897if _tab_0 then
3898 if 1 == _exp_0[1] and 2 == _exp_0[2] and 3 == _exp_0[3] then
3899 _match_0 = true
3900 print("1, 2, 3")
3901 end
3902end
3903if not _match_0 then
3904 local _match_1 = false
3905 if _tab_0 then
3906 local b = _exp_0[2]
3907 if 1 == _exp_0[1] and b ~= nil and 3 == _exp_0[3] then
3908 _match_1 = true
3909 print("1, " .. tostring(b) .. ", 3")
3910 end
3911 end
3912 if not _match_1 then
3913 if _tab_0 then
3914 local b = _exp_0[3]
3915 if b == nil then
3916 b = 3
3917 end
3918 if 1 == _exp_0[1] and 2 == _exp_0[2] then
3919 print("1, 2, " .. tostring(b))
3920 end
3921 end
3922 end
3923end
3924local _exp_0 = tb
3925local _type_0 = type(_exp_0)
3926local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3927local _match_0 = false
3928if _tab_0 then
3929 local result = _exp_0.result
3930 if true == _exp_0.success and result ~= nil then
3931 _match_0 = true
3932 print("成功", result)
3933 end
3934end
3935if not _match_0 then
3936 local _match_1 = false
3937 if _tab_0 then
3938 if false == _exp_0.success then
3939 _match_1 = true
3940 print("失败", result)
3941 end
3942 end
3943 if not _match_1 then
3944 print("无效值")
3945 end
3946end
3947local _exp_0 = tb
3948local _type_0 = type(_exp_0)
3949local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3950local _match_0 = false
3951if _tab_0 then
3952 local content
3953 do
3954 local _obj_0 = _exp_0.data
3955 local _type_1 = type(_obj_0)
3956 if "table" == _type_1 or "userdata" == _type_1 then
3957 content = _obj_0.content
3958 end
3959 end
3960 local _val_0
3961 do
3962 local _obj_0 = _exp_0.data
3963 if _obj_0 ~= nil then
3964 _val_0 = _obj_0.type
3965 end
3966 end
3967 if "success" == _val_0 and content ~= nil then
3968 _match_0 = true
3969 print("成功", content)
3970 end
3971end
3972if not _match_0 then
3973 local _match_1 = false
3974 if _tab_0 then
3975 local content
3976 do
3977 local _obj_0 = _exp_0.data
3978 local _type_1 = type(_obj_0)
3979 if "table" == _type_1 or "userdata" == _type_1 then
3980 content = _obj_0.content
3981 end
3982 end
3983 local _val_0
3984 do
3985 local _obj_0 = _exp_0.data
3986 if _obj_0 ~= nil then
3987 _val_0 = _obj_0.type
3988 end
3989 end
3990 if "error" == _val_0 and content ~= nil then
3991 _match_1 = true
3992 print("失败", content)
3993 end
3994 end
3995 if not _match_1 then
3996 print("无效值")
3997 end
3998end
3999local _exp_0 = tb
4000local _type_0 = type(_exp_0)
4001local _tab_0 = "table" == _type_0 or "userdata" == _type_0
4002if _tab_0 then
4003 local fourth = _exp_0[4]
4004 local _val_0
4005 do
4006 local _obj_0 = _exp_0[1]
4007 if _obj_0 ~= nil then
4008 _val_0 = _obj_0.a
4009 end
4010 end
4011 local _val_1
4012 do
4013 local _obj_0 = _exp_0[1]
4014 if _obj_0 ~= nil then
4015 _val_1 = _obj_0.b
4016 end
4017 end
4018 local _val_2
4019 do
4020 local _obj_0 = _exp_0[2]
4021 if _obj_0 ~= nil then
4022 _val_2 = _obj_0.a
4023 end
4024 end
4025 local _val_3
4026 do
4027 local _obj_0 = _exp_0[2]
4028 if _obj_0 ~= nil then
4029 _val_3 = _obj_0.b
4030 end
4031 end
4032 local _val_4
4033 do
4034 local _obj_0 = _exp_0[3]
4035 if _obj_0 ~= nil then
4036 _val_4 = _obj_0.a
4037 end
4038 end
4039 local _val_5
4040 do
4041 local _obj_0 = _exp_0[3]
4042 if _obj_0 ~= nil then
4043 _val_5 = _obj_0.b
4044 end
4045 end
4046 if 1 == _val_0 and 2 == _val_1 and 3 == _val_2 and 4 == _val_3 and 5 == _val_4 and 6 == _val_5 and fourth ~= nil then
4047 print("匹配成功", fourth)
4048 end
4049end
4050local segments = {
4051 "admin",
4052 "users",
4053 "logs",
4054 "view"
4055}
4056local _type_0 = type(segments)
4057local _tab_0 = "table" == _type_0 or "userdata" == _type_0
4058if _tab_0 then
4059 local groups
4060 do
4061 local _accum_0 = { }
4062 local _len_0 = 1
4063 local _max_0 = #segments + -3 + 1
4064 for _index_0 = 1, _max_0 do
4065 local _item_0 = segments[_index_0]
4066 _accum_0[_len_0] = _item_0
4067 _len_0 = _len_0 + 1
4068 end
4069 groups = _accum_0
4070 end
4071 local resource = segments[#segments - 1]
4072 local action = segments[#segments]
4073 if resource ~= nil and action ~= nil then
4074 print("Group:", groups)
4075 print("Resource:", resource)
4076 print("Action:", action)
4077 end
4078end
3279local Inventory 4079local Inventory
3280local _class_0 4080local _class_0
3281local _base_0 = { 4081local _base_0 = {
@@ -3932,6 +4732,10 @@ do
3932 _with_1["key-name"] = value 4732 _with_1["key-name"] = value
3933end 4733end
3934_with_0[#_with_0 + 1] = "abc" 4734_with_0[#_with_0 + 1] = "abc"
4735local _with_0 = obj
4736if _with_0 ~= nil then
4737 print(obj.name)
4738end
3935do 4739do
3936 local var = "hello" 4740 local var = "hello"
3937 print(var) 4741 print(var)