From d63779ec0a6f00854f53b48b0f6a67707879b6d1 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 12 Feb 2026 10:29:07 +0800 Subject: Updated docs. --- spec/outputs/codes_from_doc_de.lua | 834 +++++++++++++++++++--------------- spec/outputs/codes_from_doc_en.lua | 834 +++++++++++++++++++--------------- spec/outputs/codes_from_doc_id-id.lua | 834 +++++++++++++++++++--------------- spec/outputs/codes_from_doc_pt-br.lua | 834 +++++++++++++++++++--------------- spec/outputs/codes_from_doc_zh.lua | 834 +++++++++++++++++++--------------- spec/outputs/compile_doc.lua | 2 +- 6 files changed, 2316 insertions(+), 1856 deletions(-) (limited to 'spec/outputs') diff --git a/spec/outputs/codes_from_doc_de.lua b/spec/outputs/codes_from_doc_de.lua index 7de1a35..428f788 100644 --- a/spec/outputs/codes_from_doc_de.lua +++ b/spec/outputs/codes_from_doc_de.lua @@ -3,6 +3,18 @@ do print(var) end print(var) +local status, value +do + repeat + local n = 12 + if n > 10 then + status, value = "large", n + break + end + status, value = "small", n + break + until true +end local counter do local i = 0 @@ -24,6 +36,18 @@ do print(var) end print(var) +local status, value +do + repeat + local n = 12 + if n > 10 then + status, value = "large", n + break + end + status, value = "small", n + break + until true +end local counter do local i = 0 @@ -146,385 +170,123 @@ end do print(123, "hallo") end -do - local insert, concat = table.insert, table.concat - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local x, y, z - do - local _obj_0 = require('mymodule') - x, y, z = _obj_0.x, _obj_0.y, _obj_0.z - end - local a, b, c - local _obj_0 = require('module') - a, b, c = _obj_0.a, _obj_0.b, _obj_0.c -end -do - local module = require('module') - local module_x = require('module_x') - local d_a_s_h_e_s = require("d-a-s-h-e-s") - local part = require("module.part") +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +local success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return yue.traceback(err) +end) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +success, result = pcall(function() + return func(1, 2, 3) +end) +pcall(function() + print("Versuche") + return func(1, 2, 3) +end) +success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +if success then + print(result) end +local a, b, c do - local PlayerModule = require("player") - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() + return func() + end) + if _ok_0 then + a, b, c = _ret_0, _ret_1, _ret_2 end - local one, two, ch - local _obj_0 = require("export") - one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] -end -do - local tostring = tostring - local concat = table.concat - print(concat({ - "a", - tostring(1) - })) end do - local print = print - local math = math - print("hallo") - math.random(3) -end -do - local print = print - print(FLAG) - FLAG = 123 -end -local _module_0 = { } -local a, b, c = 1, 2, 3 -_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c -local cool = "Katze" -_module_0["cool"] = cool -local What -if this then - What = "abc" -else - What = "def" -end -_module_0["What"] = What -local y -y = function() - local hallo = 3434 -end -_module_0["y"] = y -local Something -local _class_0 -local _base_0 = { - umm = "cool" -} -if _base_0.__index == nil then - _base_0.__index = _base_0 -end -_class_0 = setmetatable({ - __init = function() end, - __base = _base_0, - __name = "Something" -}, { - __index = _base_0, - __call = function(cls, ...) - local _self_0 = setmetatable({ }, _base_0) - cls.__init(_self_0, ...) - return _self_0 + local _exp_0 = ((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(pcall(function() + return func() + end)) + end)()) + if _exp_0 ~= nil then + a = _exp_0 + else + a = "Standardwert" end -}) -_base_0.__class = _class_0 -Something = _class_0 -_module_0["Something"] = Something -return _module_0 -local _module_0 = { } -local loadstring, tolua -do - local _obj_0 = yue - loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua -end -_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua -local fieldA = tb.itemA.fieldA -if fieldA == nil then - fieldA = 'default' -end -_module_0["fieldA"] = fieldA -return _module_0 -local _module_0 = setmetatable({ }, { }) -_module_0.itemA = tb -getmetatable(_module_0).__index = items -_module_0["a-b-c"] = 123 -return _module_0 -local _module_0 = { } -local d, e, f = 3, 2, 1 -_module_0[#_module_0 + 1] = d -_module_0[#_module_0 + 1] = e -_module_0[#_module_0 + 1] = f -if this then - _module_0[#_module_0 + 1] = 123 -else - _module_0[#_module_0 + 1] = 456 end -local _with_0 = tmp -local j = 2000 -_module_0[#_module_0 + 1] = _with_0 -return _module_0 -local _module_0 = nil -_module_0 = function() - print("hallo") - return 123 +f((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(pcall(function() + return func() + end)) +end)()) +f((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(xpcall(function() + print(123) + return func() + end, function(e) + print(e) + return e + end)) +end)()) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +local success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return yue.traceback(err) +end) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +success, result = pcall(function() + return func(1, 2, 3) +end) +pcall(function() + print("Versuche") + return func(1, 2, 3) +end) +success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +if success then + print(result) end -return _module_0 +local a, b, c do - local insert, concat = table.insert, table.concat - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local x, y, z - do - local _obj_0 = require('mymodule') - x, y, z = _obj_0.x, _obj_0.y, _obj_0.z - end - local a, b, c - local _obj_0 = require('module') - a, b, c = _obj_0.a, _obj_0.b, _obj_0.c -end -do - local module = require('module') - local module_x = require('module_x') - local d_a_s_h_e_s = require("d-a-s-h-e-s") - local part = require("module.part") -end -do - local PlayerModule = require("player") - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local one, two, ch - local _obj_0 = require("export") - one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] -end -do - local tostring = tostring - local concat = table.concat - print(concat({ - "a", - tostring(1) - })) -end -do - local print = print - local math = math - print("hallo") - math.random(3) -end -do - local print = print - print(FLAG) - FLAG = 123 -end -local _module_0 = { } -local a, b, c = 1, 2, 3 -_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c -local cool = "Katze" -_module_0["cool"] = cool -local What -if this then - What = "abc" -else - What = "def" -end -_module_0["What"] = What -local y -y = function() - local hallo = 3434 -end -_module_0["y"] = y -local Something -local _class_0 -local _base_0 = { - umm = "cool" -} -if _base_0.__index == nil then - _base_0.__index = _base_0 -end -_class_0 = setmetatable({ - __init = function() end, - __base = _base_0, - __name = "Something" -}, { - __index = _base_0, - __call = function(cls, ...) - local _self_0 = setmetatable({ }, _base_0) - cls.__init(_self_0, ...) - return _self_0 - end -}) -_base_0.__class = _class_0 -Something = _class_0 -_module_0["Something"] = Something -return _module_0 -local _module_0 = { } -local loadstring, tolua -do - local _obj_0 = yue - loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua -end -_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua -local fieldA = tb.itemA.fieldA -if fieldA == nil then - fieldA = 'default' -end -_module_0["fieldA"] = fieldA -return _module_0 -local _module_0 = setmetatable({ }, { }) -_module_0.itemA = tb -getmetatable(_module_0).__index = items -_module_0["a-b-c"] = 123 -return _module_0 -local _module_0 = { } -local d, e, f = 3, 2, 1 -_module_0[#_module_0 + 1] = d -_module_0[#_module_0 + 1] = e -_module_0[#_module_0 + 1] = f -if this then - _module_0[#_module_0 + 1] = 123 -else - _module_0[#_module_0 + 1] = 456 -end -local _with_0 = tmp -local j = 2000 -_module_0[#_module_0 + 1] = _with_0 -return _module_0 -local _module_0 = nil -_module_0 = function() - print("hallo") - return 123 -end -return _module_0 -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -local success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return yue.traceback(err) -end) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -success, result = pcall(function() - return func(1, 2, 3) -end) -pcall(function() - print("Versuche") - return func(1, 2, 3) -end) -success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -if success then - print(result) -end -local a, b, c -do - local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() - return func() - end) - if _ok_0 then - a, b, c = _ret_0, _ret_1, _ret_2 - end -end -do - local _exp_0 = ((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(pcall(function() - return func() - end)) - end)()) - if _exp_0 ~= nil then - a = _exp_0 - else - a = "Standardwert" - end -end -f((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(pcall(function() - return func() - end)) -end)()) -f((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(xpcall(function() - print(123) - return func() - end, function(e) - print(e) - return e - end)) -end)()) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -local success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return yue.traceback(err) -end) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -success, result = pcall(function() - return func(1, 2, 3) -end) -pcall(function() - print("Versuche") - return func(1, 2, 3) -end) -success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -if success then - print(result) -end -local a, b, c -do - local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() - return func() - end) - if _ok_0 then - a, b, c = _ret_0, _ret_1, _ret_2 + local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() + return func() + end) + if _ok_0 then + a, b, c = _ret_0, _ret_1, _ret_2 end end do @@ -2395,6 +2157,12 @@ local file local _with_0 = File("Lieblingsessen.txt") _with_0:set_encoding("utf8") file = _with_0 +local result +local _with_0 = obj +repeat + result = _with_0.value + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -2435,6 +2203,12 @@ local file local _with_0 = File("Lieblingsessen.txt") _with_0:set_encoding("utf8") file = _with_0 +local result +local _with_0 = obj +repeat + result = _with_0.value + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -3268,6 +3042,13 @@ for _index_0 = 1, #_list_0 do break end end +local key, score +for k, v in pairs(data) do + if k == "target" then + key, score = k, v * 10 + break + end +end local func_a func_a = function() for i = 1, 10 do @@ -3330,6 +3111,13 @@ for _index_0 = 1, #_list_0 do break end end +local key, score +for k, v in pairs(data) do + if k == "target" then + key, score = k, v * 10 + break + end +end local func_a func_a = function() for i = 1, 10 do @@ -4008,11 +3796,32 @@ end while not (running == false) do my_function() end +local value, doubled +local _val_0, _val_1 +while true do + local n = get_next() + if n > 10 then + _val_0, _val_1 = n, n * 2 + break + end +end +value, doubled = _val_0, _val_1 local i = 10 repeat print(i) i = i - 1 until i == 0 +local i = 1 +local value, scaled +local _val_0, _val_1 +repeat + if i > 3 then + _val_0, _val_1 = i, i * 100 + break + end + i = i + 1 +until false +value, scaled = _val_0, _val_1 local i = 10 while i > 0 do print(i) @@ -4029,12 +3838,33 @@ end while not (running == false) do my_function() end +local value, doubled +local _val_0, _val_1 +while true do + local n = get_next() + if n > 10 then + _val_0, _val_1 = n, n * 2 + break + end +end +value, doubled = _val_0, _val_1 local i = 10 repeat print(i) i = i - 1 until i == 0 -local my_object = { +local i = 1 +local value, scaled +local _val_0, _val_1 +repeat + if i > 3 then + _val_0, _val_1 = i, i * 100 + break + end + i = i + 1 +until false +value, scaled = _val_0, _val_1 +local my_object = { value = 1000, write = function(self) return print("der Wert:", self.value) @@ -5136,3 +4966,265 @@ fn = function() return str end local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" +do + local insert, concat = table.insert, table.concat + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local x, y, z + do + local _obj_0 = require('mymodule') + x, y, z = _obj_0.x, _obj_0.y, _obj_0.z + end + local a, b, c + local _obj_0 = require('module') + a, b, c = _obj_0.a, _obj_0.b, _obj_0.c +end +do + local module = require('module') + local module_x = require('module_x') + local d_a_s_h_e_s = require("d-a-s-h-e-s") + local part = require("module.part") +end +do + local PlayerModule = require("player") + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local one, two, ch + local _obj_0 = require("export") + one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] +end +do + local tostring = tostring + local concat = table.concat + print(concat({ + "a", + tostring(1) + })) +end +do + local print = print + local math = math + print("hallo") + math.random(3) +end +do + local print = print + print(FLAG) + FLAG = 123 +end +local _module_0 = { } +local a, b, c = 1, 2, 3 +_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c +local cool = "Katze" +_module_0["cool"] = cool +local What +if this then + What = "abc" +else + What = "def" +end +_module_0["What"] = What +local y +y = function() + local hallo = 3434 +end +_module_0["y"] = y +local Something +local _class_0 +local _base_0 = { + umm = "cool" +} +if _base_0.__index == nil then + _base_0.__index = _base_0 +end +_class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "Something" +}, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({ }, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end +}) +_base_0.__class = _class_0 +Something = _class_0 +_module_0["Something"] = Something +return _module_0 +local _module_0 = { } +local loadstring, tolua +do + local _obj_0 = yue + loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua +end +_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua +local fieldA = tb.itemA.fieldA +if fieldA == nil then + fieldA = 'default' +end +_module_0["fieldA"] = fieldA +return _module_0 +local _module_0 = setmetatable({ }, { }) +_module_0.itemA = tb +getmetatable(_module_0).__index = items +_module_0["a-b-c"] = 123 +return _module_0 +local _module_0 = { } +local d, e, f = 3, 2, 1 +_module_0[#_module_0 + 1] = d +_module_0[#_module_0 + 1] = e +_module_0[#_module_0 + 1] = f +if this then + _module_0[#_module_0 + 1] = 123 +else + _module_0[#_module_0 + 1] = 456 +end +local _with_0 = tmp +local j = 2000 +_module_0[#_module_0 + 1] = _with_0 +return _module_0 +local _module_0 = nil +_module_0 = function() + print("hallo") + return 123 +end +return _module_0 +do + local insert, concat = table.insert, table.concat + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local x, y, z + do + local _obj_0 = require('mymodule') + x, y, z = _obj_0.x, _obj_0.y, _obj_0.z + end + local a, b, c + local _obj_0 = require('module') + a, b, c = _obj_0.a, _obj_0.b, _obj_0.c +end +do + local module = require('module') + local module_x = require('module_x') + local d_a_s_h_e_s = require("d-a-s-h-e-s") + local part = require("module.part") +end +do + local PlayerModule = require("player") + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local one, two, ch + local _obj_0 = require("export") + one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] +end +do + local tostring = tostring + local concat = table.concat + print(concat({ + "a", + tostring(1) + })) +end +do + local print = print + local math = math + print("hallo") + math.random(3) +end +do + local print = print + print(FLAG) + FLAG = 123 +end +local _module_0 = { } +local a, b, c = 1, 2, 3 +_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c +local cool = "Katze" +_module_0["cool"] = cool +local What +if this then + What = "abc" +else + What = "def" +end +_module_0["What"] = What +local y +y = function() + local hallo = 3434 +end +_module_0["y"] = y +local Something +local _class_0 +local _base_0 = { + umm = "cool" +} +if _base_0.__index == nil then + _base_0.__index = _base_0 +end +_class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "Something" +}, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({ }, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end +}) +_base_0.__class = _class_0 +Something = _class_0 +_module_0["Something"] = Something +return _module_0 +local _module_0 = { } +local loadstring, tolua +do + local _obj_0 = yue + loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua +end +_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua +local fieldA = tb.itemA.fieldA +if fieldA == nil then + fieldA = 'default' +end +_module_0["fieldA"] = fieldA +return _module_0 +local _module_0 = setmetatable({ }, { }) +_module_0.itemA = tb +getmetatable(_module_0).__index = items +_module_0["a-b-c"] = 123 +return _module_0 +local _module_0 = { } +local d, e, f = 3, 2, 1 +_module_0[#_module_0 + 1] = d +_module_0[#_module_0 + 1] = e +_module_0[#_module_0 + 1] = f +if this then + _module_0[#_module_0 + 1] = 123 +else + _module_0[#_module_0 + 1] = 456 +end +local _with_0 = tmp +local j = 2000 +_module_0[#_module_0 + 1] = _with_0 +return _module_0 +local _module_0 = nil +_module_0 = function() + print("hallo") + return 123 +end +return _module_0 diff --git a/spec/outputs/codes_from_doc_en.lua b/spec/outputs/codes_from_doc_en.lua index cd83bbf..4006605 100644 --- a/spec/outputs/codes_from_doc_en.lua +++ b/spec/outputs/codes_from_doc_en.lua @@ -3,6 +3,18 @@ do print(var) end print(var) +local status, value +do + repeat + local n = 12 + if n > 10 then + status, value = "large", n + break + end + status, value = "small", n + break + until true +end local counter do local i = 0 @@ -24,6 +36,18 @@ do print(var) end print(var) +local status, value +do + repeat + local n = 12 + if n > 10 then + status, value = "large", n + break + end + status, value = "small", n + break + until true +end local counter do local i = 0 @@ -146,385 +170,123 @@ end do print(123, "hello") end -do - local insert, concat = table.insert, table.concat - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local x, y, z - do - local _obj_0 = require('mymodule') - x, y, z = _obj_0.x, _obj_0.y, _obj_0.z - end - local a, b, c - local _obj_0 = require('module') - a, b, c = _obj_0.a, _obj_0.b, _obj_0.c -end -do - local module = require('module') - local module_x = require('module_x') - local d_a_s_h_e_s = require("d-a-s-h-e-s") - local part = require("module.part") +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +local success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return yue.traceback(err) +end) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +success, result = pcall(function() + return func(1, 2, 3) +end) +pcall(function() + print("trying") + return func(1, 2, 3) +end) +success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +if success then + print(result) end +local a, b, c do - local PlayerModule = require("player") - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() + return func() + end) + if _ok_0 then + a, b, c = _ret_0, _ret_1, _ret_2 end - local one, two, ch - local _obj_0 = require("export") - one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] -end -do - local tostring = tostring - local concat = table.concat - print(concat({ - "a", - tostring(1) - })) end do - local print = print - local math = math - print("hello") - math.random(3) -end -do - local print = print - print(FLAG) - FLAG = 123 -end -local _module_0 = { } -local a, b, c = 1, 2, 3 -_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c -local cool = "cat" -_module_0["cool"] = cool -local What -if this then - What = "abc" -else - What = "def" -end -_module_0["What"] = What -local y -y = function() - local hallo = 3434 -end -_module_0["y"] = y -local Something -local _class_0 -local _base_0 = { - umm = "cool" -} -if _base_0.__index == nil then - _base_0.__index = _base_0 -end -_class_0 = setmetatable({ - __init = function() end, - __base = _base_0, - __name = "Something" -}, { - __index = _base_0, - __call = function(cls, ...) - local _self_0 = setmetatable({ }, _base_0) - cls.__init(_self_0, ...) - return _self_0 + local _exp_0 = ((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(pcall(function() + return func() + end)) + end)()) + if _exp_0 ~= nil then + a = _exp_0 + else + a = "default" end -}) -_base_0.__class = _class_0 -Something = _class_0 -_module_0["Something"] = Something -return _module_0 -local _module_0 = { } -local loadstring, tolua -do - local _obj_0 = yue - loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua -end -_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua -local fieldA = tb.itemA.fieldA -if fieldA == nil then - fieldA = 'default' -end -_module_0["fieldA"] = fieldA -return _module_0 -local _module_0 = setmetatable({ }, { }) -_module_0.itemA = tb -getmetatable(_module_0).__index = items -_module_0["a-b-c"] = 123 -return _module_0 -local _module_0 = { } -local d, e, f = 3, 2, 1 -_module_0[#_module_0 + 1] = d -_module_0[#_module_0 + 1] = e -_module_0[#_module_0 + 1] = f -if this then - _module_0[#_module_0 + 1] = 123 -else - _module_0[#_module_0 + 1] = 456 end -local _with_0 = tmp -local j = 2000 -_module_0[#_module_0 + 1] = _with_0 -return _module_0 -local _module_0 = nil -_module_0 = function() - print("hello") - return 123 +f((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(pcall(function() + return func() + end)) +end)()) +f((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(xpcall(function() + print(123) + return func() + end, function(e) + print(e) + return e + end)) +end)()) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +local success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return yue.traceback(err) +end) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +success, result = pcall(function() + return func(1, 2, 3) +end) +pcall(function() + print("trying") + return func(1, 2, 3) +end) +success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +if success then + print(result) end -return _module_0 +local a, b, c do - local insert, concat = table.insert, table.concat - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local x, y, z - do - local _obj_0 = require('mymodule') - x, y, z = _obj_0.x, _obj_0.y, _obj_0.z - end - local a, b, c - local _obj_0 = require('module') - a, b, c = _obj_0.a, _obj_0.b, _obj_0.c -end -do - local module = require('module') - local module_x = require('module_x') - local d_a_s_h_e_s = require("d-a-s-h-e-s") - local part = require("module.part") -end -do - local PlayerModule = require("player") - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local one, two, ch - local _obj_0 = require("export") - one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] -end -do - local tostring = tostring - local concat = table.concat - print(concat({ - "a", - tostring(1) - })) -end -do - local print = print - local math = math - print("hello") - math.random(3) -end -do - local print = print - print(FLAG) - FLAG = 123 -end -local _module_0 = { } -local a, b, c = 1, 2, 3 -_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c -local cool = "cat" -_module_0["cool"] = cool -local What -if this then - What = "abc" -else - What = "def" -end -_module_0["What"] = What -local y -y = function() - local hallo = 3434 -end -_module_0["y"] = y -local Something -local _class_0 -local _base_0 = { - umm = "cool" -} -if _base_0.__index == nil then - _base_0.__index = _base_0 -end -_class_0 = setmetatable({ - __init = function() end, - __base = _base_0, - __name = "Something" -}, { - __index = _base_0, - __call = function(cls, ...) - local _self_0 = setmetatable({ }, _base_0) - cls.__init(_self_0, ...) - return _self_0 - end -}) -_base_0.__class = _class_0 -Something = _class_0 -_module_0["Something"] = Something -return _module_0 -local _module_0 = { } -local loadstring, tolua -do - local _obj_0 = yue - loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua -end -_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua -local fieldA = tb.itemA.fieldA -if fieldA == nil then - fieldA = 'default' -end -_module_0["fieldA"] = fieldA -return _module_0 -local _module_0 = setmetatable({ }, { }) -_module_0.itemA = tb -getmetatable(_module_0).__index = items -_module_0["a-b-c"] = 123 -return _module_0 -local _module_0 = { } -local d, e, f = 3, 2, 1 -_module_0[#_module_0 + 1] = d -_module_0[#_module_0 + 1] = e -_module_0[#_module_0 + 1] = f -if this then - _module_0[#_module_0 + 1] = 123 -else - _module_0[#_module_0 + 1] = 456 -end -local _with_0 = tmp -local j = 2000 -_module_0[#_module_0 + 1] = _with_0 -return _module_0 -local _module_0 = nil -_module_0 = function() - print("hello") - return 123 -end -return _module_0 -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -local success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return yue.traceback(err) -end) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -success, result = pcall(function() - return func(1, 2, 3) -end) -pcall(function() - print("trying") - return func(1, 2, 3) -end) -success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -if success then - print(result) -end -local a, b, c -do - local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() - return func() - end) - if _ok_0 then - a, b, c = _ret_0, _ret_1, _ret_2 - end -end -do - local _exp_0 = ((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(pcall(function() - return func() - end)) - end)()) - if _exp_0 ~= nil then - a = _exp_0 - else - a = "default" - end -end -f((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(pcall(function() - return func() - end)) -end)()) -f((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(xpcall(function() - print(123) - return func() - end, function(e) - print(e) - return e - end)) -end)()) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -local success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return yue.traceback(err) -end) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -success, result = pcall(function() - return func(1, 2, 3) -end) -pcall(function() - print("trying") - return func(1, 2, 3) -end) -success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -if success then - print(result) -end -local a, b, c -do - local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() - return func() - end) - if _ok_0 then - a, b, c = _ret_0, _ret_1, _ret_2 + local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() + return func() + end) + if _ok_0 then + a, b, c = _ret_0, _ret_1, _ret_2 end end do @@ -2395,6 +2157,12 @@ local file local _with_0 = File("favorite_foods.txt") _with_0:set_encoding("utf8") file = _with_0 +local result +local _with_0 = obj +repeat + result = _with_0.value + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -2435,6 +2203,12 @@ local file local _with_0 = File("favorite_foods.txt") _with_0:set_encoding("utf8") file = _with_0 +local result +local _with_0 = obj +repeat + result = _with_0.value + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -3268,6 +3042,13 @@ for _index_0 = 1, #_list_0 do break end end +local key, score +for k, v in pairs(data) do + if k == "target" then + key, score = k, v * 10 + break + end +end local func_a func_a = function() for i = 1, 10 do @@ -3330,6 +3111,13 @@ for _index_0 = 1, #_list_0 do break end end +local key, score +for k, v in pairs(data) do + if k == "target" then + key, score = k, v * 10 + break + end +end local func_a func_a = function() for i = 1, 10 do @@ -4008,11 +3796,32 @@ end while not (running == false) do my_function() end +local value, doubled +local _val_0, _val_1 +while true do + local n = get_next() + if n > 10 then + _val_0, _val_1 = n, n * 2 + break + end +end +value, doubled = _val_0, _val_1 local i = 10 repeat print(i) i = i - 1 until i == 0 +local i = 1 +local value, scaled +local _val_0, _val_1 +repeat + if i > 3 then + _val_0, _val_1 = i, i * 100 + break + end + i = i + 1 +until false +value, scaled = _val_0, _val_1 local i = 10 while i > 0 do print(i) @@ -4029,12 +3838,33 @@ end while not (running == false) do my_function() end +local value, doubled +local _val_0, _val_1 +while true do + local n = get_next() + if n > 10 then + _val_0, _val_1 = n, n * 2 + break + end +end +value, doubled = _val_0, _val_1 local i = 10 repeat print(i) i = i - 1 until i == 0 -local my_object = { +local i = 1 +local value, scaled +local _val_0, _val_1 +repeat + if i > 3 then + _val_0, _val_1 = i, i * 100 + break + end + i = i + 1 +until false +value, scaled = _val_0, _val_1 +local my_object = { value = 1000, write = function(self) return print("the value:", self.value) @@ -5136,3 +4966,265 @@ fn = function() return str end local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" +do + local insert, concat = table.insert, table.concat + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local x, y, z + do + local _obj_0 = require('mymodule') + x, y, z = _obj_0.x, _obj_0.y, _obj_0.z + end + local a, b, c + local _obj_0 = require('module') + a, b, c = _obj_0.a, _obj_0.b, _obj_0.c +end +do + local module = require('module') + local module_x = require('module_x') + local d_a_s_h_e_s = require("d-a-s-h-e-s") + local part = require("module.part") +end +do + local PlayerModule = require("player") + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local one, two, ch + local _obj_0 = require("export") + one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] +end +do + local tostring = tostring + local concat = table.concat + print(concat({ + "a", + tostring(1) + })) +end +do + local print = print + local math = math + print("hello") + math.random(3) +end +do + local print = print + print(FLAG) + FLAG = 123 +end +local _module_0 = { } +local a, b, c = 1, 2, 3 +_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c +local cool = "cat" +_module_0["cool"] = cool +local What +if this then + What = "abc" +else + What = "def" +end +_module_0["What"] = What +local y +y = function() + local hallo = 3434 +end +_module_0["y"] = y +local Something +local _class_0 +local _base_0 = { + umm = "cool" +} +if _base_0.__index == nil then + _base_0.__index = _base_0 +end +_class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "Something" +}, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({ }, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end +}) +_base_0.__class = _class_0 +Something = _class_0 +_module_0["Something"] = Something +return _module_0 +local _module_0 = { } +local loadstring, tolua +do + local _obj_0 = yue + loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua +end +_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua +local fieldA = tb.itemA.fieldA +if fieldA == nil then + fieldA = 'default' +end +_module_0["fieldA"] = fieldA +return _module_0 +local _module_0 = setmetatable({ }, { }) +_module_0.itemA = tb +getmetatable(_module_0).__index = items +_module_0["a-b-c"] = 123 +return _module_0 +local _module_0 = { } +local d, e, f = 3, 2, 1 +_module_0[#_module_0 + 1] = d +_module_0[#_module_0 + 1] = e +_module_0[#_module_0 + 1] = f +if this then + _module_0[#_module_0 + 1] = 123 +else + _module_0[#_module_0 + 1] = 456 +end +local _with_0 = tmp +local j = 2000 +_module_0[#_module_0 + 1] = _with_0 +return _module_0 +local _module_0 = nil +_module_0 = function() + print("hello") + return 123 +end +return _module_0 +do + local insert, concat = table.insert, table.concat + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local x, y, z + do + local _obj_0 = require('mymodule') + x, y, z = _obj_0.x, _obj_0.y, _obj_0.z + end + local a, b, c + local _obj_0 = require('module') + a, b, c = _obj_0.a, _obj_0.b, _obj_0.c +end +do + local module = require('module') + local module_x = require('module_x') + local d_a_s_h_e_s = require("d-a-s-h-e-s") + local part = require("module.part") +end +do + local PlayerModule = require("player") + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local one, two, ch + local _obj_0 = require("export") + one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] +end +do + local tostring = tostring + local concat = table.concat + print(concat({ + "a", + tostring(1) + })) +end +do + local print = print + local math = math + print("hello") + math.random(3) +end +do + local print = print + print(FLAG) + FLAG = 123 +end +local _module_0 = { } +local a, b, c = 1, 2, 3 +_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c +local cool = "cat" +_module_0["cool"] = cool +local What +if this then + What = "abc" +else + What = "def" +end +_module_0["What"] = What +local y +y = function() + local hallo = 3434 +end +_module_0["y"] = y +local Something +local _class_0 +local _base_0 = { + umm = "cool" +} +if _base_0.__index == nil then + _base_0.__index = _base_0 +end +_class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "Something" +}, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({ }, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end +}) +_base_0.__class = _class_0 +Something = _class_0 +_module_0["Something"] = Something +return _module_0 +local _module_0 = { } +local loadstring, tolua +do + local _obj_0 = yue + loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua +end +_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua +local fieldA = tb.itemA.fieldA +if fieldA == nil then + fieldA = 'default' +end +_module_0["fieldA"] = fieldA +return _module_0 +local _module_0 = setmetatable({ }, { }) +_module_0.itemA = tb +getmetatable(_module_0).__index = items +_module_0["a-b-c"] = 123 +return _module_0 +local _module_0 = { } +local d, e, f = 3, 2, 1 +_module_0[#_module_0 + 1] = d +_module_0[#_module_0 + 1] = e +_module_0[#_module_0 + 1] = f +if this then + _module_0[#_module_0 + 1] = 123 +else + _module_0[#_module_0 + 1] = 456 +end +local _with_0 = tmp +local j = 2000 +_module_0[#_module_0 + 1] = _with_0 +return _module_0 +local _module_0 = nil +_module_0 = function() + print("hello") + return 123 +end +return _module_0 diff --git a/spec/outputs/codes_from_doc_id-id.lua b/spec/outputs/codes_from_doc_id-id.lua index b024989..7d95eaa 100644 --- a/spec/outputs/codes_from_doc_id-id.lua +++ b/spec/outputs/codes_from_doc_id-id.lua @@ -3,6 +3,18 @@ do print(var) end print(var) +local status, value +do + repeat + local n = 12 + if n > 10 then + status, value = "large", n + break + end + status, value = "small", n + break + until true +end local counter do local i = 0 @@ -24,6 +36,18 @@ do print(var) end print(var) +local status, value +do + repeat + local n = 12 + if n > 10 then + status, value = "large", n + break + end + status, value = "small", n + break + until true +end local counter do local i = 0 @@ -146,385 +170,123 @@ end do print(123, "hello") end -do - local insert, concat = table.insert, table.concat - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local x, y, z - do - local _obj_0 = require('mymodule') - x, y, z = _obj_0.x, _obj_0.y, _obj_0.z - end - local a, b, c - local _obj_0 = require('module') - a, b, c = _obj_0.a, _obj_0.b, _obj_0.c -end -do - local module = require('module') - local module_x = require('module_x') - local d_a_s_h_e_s = require("d-a-s-h-e-s") - local part = require("module.part") +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +local success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return yue.traceback(err) +end) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +success, result = pcall(function() + return func(1, 2, 3) +end) +pcall(function() + print("trying") + return func(1, 2, 3) +end) +success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +if success then + print(result) end +local a, b, c do - local PlayerModule = require("player") - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() + return func() + end) + if _ok_0 then + a, b, c = _ret_0, _ret_1, _ret_2 end - local one, two, ch - local _obj_0 = require("export") - one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] -end -do - local tostring = tostring - local concat = table.concat - print(concat({ - "a", - tostring(1) - })) end do - local print = print - local math = math - print("hello") - math.random(3) -end -do - local print = print - print(FLAG) - FLAG = 123 -end -local _module_0 = { } -local a, b, c = 1, 2, 3 -_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c -local cool = "cat" -_module_0["cool"] = cool -local What -if this then - What = "abc" -else - What = "def" -end -_module_0["What"] = What -local y -y = function() - local hallo = 3434 -end -_module_0["y"] = y -local Something -local _class_0 -local _base_0 = { - umm = "cool" -} -if _base_0.__index == nil then - _base_0.__index = _base_0 -end -_class_0 = setmetatable({ - __init = function() end, - __base = _base_0, - __name = "Something" -}, { - __index = _base_0, - __call = function(cls, ...) - local _self_0 = setmetatable({ }, _base_0) - cls.__init(_self_0, ...) - return _self_0 + local _exp_0 = ((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(pcall(function() + return func() + end)) + end)()) + if _exp_0 ~= nil then + a = _exp_0 + else + a = "default" end -}) -_base_0.__class = _class_0 -Something = _class_0 -_module_0["Something"] = Something -return _module_0 -local _module_0 = { } -local loadstring, tolua -do - local _obj_0 = yue - loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua -end -_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua -local fieldA = tb.itemA.fieldA -if fieldA == nil then - fieldA = 'default' -end -_module_0["fieldA"] = fieldA -return _module_0 -local _module_0 = setmetatable({ }, { }) -_module_0.itemA = tb -getmetatable(_module_0).__index = items -_module_0["a-b-c"] = 123 -return _module_0 -local _module_0 = { } -local d, e, f = 3, 2, 1 -_module_0[#_module_0 + 1] = d -_module_0[#_module_0 + 1] = e -_module_0[#_module_0 + 1] = f -if this then - _module_0[#_module_0 + 1] = 123 -else - _module_0[#_module_0 + 1] = 456 end -local _with_0 = tmp -local j = 2000 -_module_0[#_module_0 + 1] = _with_0 -return _module_0 -local _module_0 = nil -_module_0 = function() - print("hello") - return 123 +f((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(pcall(function() + return func() + end)) +end)()) +f((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(xpcall(function() + print(123) + return func() + end, function(e) + print(e) + return e + end)) +end)()) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +local success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return yue.traceback(err) +end) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +success, result = pcall(function() + return func(1, 2, 3) +end) +pcall(function() + print("trying") + return func(1, 2, 3) +end) +success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +if success then + print(result) end -return _module_0 +local a, b, c do - local insert, concat = table.insert, table.concat - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local x, y, z - do - local _obj_0 = require('mymodule') - x, y, z = _obj_0.x, _obj_0.y, _obj_0.z - end - local a, b, c - local _obj_0 = require('module') - a, b, c = _obj_0.a, _obj_0.b, _obj_0.c -end -do - local module = require('module') - local module_x = require('module_x') - local d_a_s_h_e_s = require("d-a-s-h-e-s") - local part = require("module.part") -end -do - local PlayerModule = require("player") - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local one, two, ch - local _obj_0 = require("export") - one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] -end -do - local tostring = tostring - local concat = table.concat - print(concat({ - "a", - tostring(1) - })) -end -do - local print = print - local math = math - print("hello") - math.random(3) -end -do - local print = print - print(FLAG) - FLAG = 123 -end -local _module_0 = { } -local a, b, c = 1, 2, 3 -_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c -local cool = "cat" -_module_0["cool"] = cool -local What -if this then - What = "abc" -else - What = "def" -end -_module_0["What"] = What -local y -y = function() - local hallo = 3434 -end -_module_0["y"] = y -local Something -local _class_0 -local _base_0 = { - umm = "cool" -} -if _base_0.__index == nil then - _base_0.__index = _base_0 -end -_class_0 = setmetatable({ - __init = function() end, - __base = _base_0, - __name = "Something" -}, { - __index = _base_0, - __call = function(cls, ...) - local _self_0 = setmetatable({ }, _base_0) - cls.__init(_self_0, ...) - return _self_0 - end -}) -_base_0.__class = _class_0 -Something = _class_0 -_module_0["Something"] = Something -return _module_0 -local _module_0 = { } -local loadstring, tolua -do - local _obj_0 = yue - loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua -end -_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua -local fieldA = tb.itemA.fieldA -if fieldA == nil then - fieldA = 'default' -end -_module_0["fieldA"] = fieldA -return _module_0 -local _module_0 = setmetatable({ }, { }) -_module_0.itemA = tb -getmetatable(_module_0).__index = items -_module_0["a-b-c"] = 123 -return _module_0 -local _module_0 = { } -local d, e, f = 3, 2, 1 -_module_0[#_module_0 + 1] = d -_module_0[#_module_0 + 1] = e -_module_0[#_module_0 + 1] = f -if this then - _module_0[#_module_0 + 1] = 123 -else - _module_0[#_module_0 + 1] = 456 -end -local _with_0 = tmp -local j = 2000 -_module_0[#_module_0 + 1] = _with_0 -return _module_0 -local _module_0 = nil -_module_0 = function() - print("hello") - return 123 -end -return _module_0 -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -local success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return yue.traceback(err) -end) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -success, result = pcall(function() - return func(1, 2, 3) -end) -pcall(function() - print("trying") - return func(1, 2, 3) -end) -success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -if success then - print(result) -end -local a, b, c -do - local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() - return func() - end) - if _ok_0 then - a, b, c = _ret_0, _ret_1, _ret_2 - end -end -do - local _exp_0 = ((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(pcall(function() - return func() - end)) - end)()) - if _exp_0 ~= nil then - a = _exp_0 - else - a = "default" - end -end -f((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(pcall(function() - return func() - end)) -end)()) -f((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(xpcall(function() - print(123) - return func() - end, function(e) - print(e) - return e - end)) -end)()) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -local success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return yue.traceback(err) -end) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -success, result = pcall(function() - return func(1, 2, 3) -end) -pcall(function() - print("trying") - return func(1, 2, 3) -end) -success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -if success then - print(result) -end -local a, b, c -do - local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() - return func() - end) - if _ok_0 then - a, b, c = _ret_0, _ret_1, _ret_2 + local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() + return func() + end) + if _ok_0 then + a, b, c = _ret_0, _ret_1, _ret_2 end end do @@ -2395,6 +2157,12 @@ local file local _with_0 = File("favorite_foods.txt") _with_0:set_encoding("utf8") file = _with_0 +local result +local _with_0 = obj +repeat + result = _with_0.value + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -2435,6 +2203,12 @@ local file local _with_0 = File("favorite_foods.txt") _with_0:set_encoding("utf8") file = _with_0 +local result +local _with_0 = obj +repeat + result = _with_0.value + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -3268,6 +3042,13 @@ for _index_0 = 1, #_list_0 do break end end +local key, score +for k, v in pairs(data) do + if k == "target" then + key, score = k, v * 10 + break + end +end local func_a func_a = function() for i = 1, 10 do @@ -3330,6 +3111,13 @@ for _index_0 = 1, #_list_0 do break end end +local key, score +for k, v in pairs(data) do + if k == "target" then + key, score = k, v * 10 + break + end +end local func_a func_a = function() for i = 1, 10 do @@ -4008,11 +3796,32 @@ end while not (running == false) do my_function() end +local value, doubled +local _val_0, _val_1 +while true do + local n = get_next() + if n > 10 then + _val_0, _val_1 = n, n * 2 + break + end +end +value, doubled = _val_0, _val_1 local i = 10 repeat print(i) i = i - 1 until i == 0 +local i = 1 +local value, scaled +local _val_0, _val_1 +repeat + if i > 3 then + _val_0, _val_1 = i, i * 100 + break + end + i = i + 1 +until false +value, scaled = _val_0, _val_1 local i = 10 while i > 0 do print(i) @@ -4029,12 +3838,33 @@ end while not (running == false) do my_function() end +local value, doubled +local _val_0, _val_1 +while true do + local n = get_next() + if n > 10 then + _val_0, _val_1 = n, n * 2 + break + end +end +value, doubled = _val_0, _val_1 local i = 10 repeat print(i) i = i - 1 until i == 0 -local my_object = { +local i = 1 +local value, scaled +local _val_0, _val_1 +repeat + if i > 3 then + _val_0, _val_1 = i, i * 100 + break + end + i = i + 1 +until false +value, scaled = _val_0, _val_1 +local my_object = { value = 1000, write = function(self) return print("the value:", self.value) @@ -5136,3 +4966,265 @@ fn = function() return str end local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" +do + local insert, concat = table.insert, table.concat + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local x, y, z + do + local _obj_0 = require('mymodule') + x, y, z = _obj_0.x, _obj_0.y, _obj_0.z + end + local a, b, c + local _obj_0 = require('module') + a, b, c = _obj_0.a, _obj_0.b, _obj_0.c +end +do + local module = require('module') + local module_x = require('module_x') + local d_a_s_h_e_s = require("d-a-s-h-e-s") + local part = require("module.part") +end +do + local PlayerModule = require("player") + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local one, two, ch + local _obj_0 = require("export") + one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] +end +do + local tostring = tostring + local concat = table.concat + print(concat({ + "a", + tostring(1) + })) +end +do + local print = print + local math = math + print("hello") + math.random(3) +end +do + local print = print + print(FLAG) + FLAG = 123 +end +local _module_0 = { } +local a, b, c = 1, 2, 3 +_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c +local cool = "cat" +_module_0["cool"] = cool +local What +if this then + What = "abc" +else + What = "def" +end +_module_0["What"] = What +local y +y = function() + local hallo = 3434 +end +_module_0["y"] = y +local Something +local _class_0 +local _base_0 = { + umm = "cool" +} +if _base_0.__index == nil then + _base_0.__index = _base_0 +end +_class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "Something" +}, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({ }, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end +}) +_base_0.__class = _class_0 +Something = _class_0 +_module_0["Something"] = Something +return _module_0 +local _module_0 = { } +local loadstring, tolua +do + local _obj_0 = yue + loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua +end +_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua +local fieldA = tb.itemA.fieldA +if fieldA == nil then + fieldA = 'default' +end +_module_0["fieldA"] = fieldA +return _module_0 +local _module_0 = setmetatable({ }, { }) +_module_0.itemA = tb +getmetatable(_module_0).__index = items +_module_0["a-b-c"] = 123 +return _module_0 +local _module_0 = { } +local d, e, f = 3, 2, 1 +_module_0[#_module_0 + 1] = d +_module_0[#_module_0 + 1] = e +_module_0[#_module_0 + 1] = f +if this then + _module_0[#_module_0 + 1] = 123 +else + _module_0[#_module_0 + 1] = 456 +end +local _with_0 = tmp +local j = 2000 +_module_0[#_module_0 + 1] = _with_0 +return _module_0 +local _module_0 = nil +_module_0 = function() + print("hello") + return 123 +end +return _module_0 +do + local insert, concat = table.insert, table.concat + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local x, y, z + do + local _obj_0 = require('mymodule') + x, y, z = _obj_0.x, _obj_0.y, _obj_0.z + end + local a, b, c + local _obj_0 = require('module') + a, b, c = _obj_0.a, _obj_0.b, _obj_0.c +end +do + local module = require('module') + local module_x = require('module_x') + local d_a_s_h_e_s = require("d-a-s-h-e-s") + local part = require("module.part") +end +do + local PlayerModule = require("player") + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local one, two, ch + local _obj_0 = require("export") + one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] +end +do + local tostring = tostring + local concat = table.concat + print(concat({ + "a", + tostring(1) + })) +end +do + local print = print + local math = math + print("hello") + math.random(3) +end +do + local print = print + print(FLAG) + FLAG = 123 +end +local _module_0 = { } +local a, b, c = 1, 2, 3 +_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c +local cool = "cat" +_module_0["cool"] = cool +local What +if this then + What = "abc" +else + What = "def" +end +_module_0["What"] = What +local y +y = function() + local hallo = 3434 +end +_module_0["y"] = y +local Something +local _class_0 +local _base_0 = { + umm = "cool" +} +if _base_0.__index == nil then + _base_0.__index = _base_0 +end +_class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "Something" +}, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({ }, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end +}) +_base_0.__class = _class_0 +Something = _class_0 +_module_0["Something"] = Something +return _module_0 +local _module_0 = { } +local loadstring, tolua +do + local _obj_0 = yue + loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua +end +_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua +local fieldA = tb.itemA.fieldA +if fieldA == nil then + fieldA = 'default' +end +_module_0["fieldA"] = fieldA +return _module_0 +local _module_0 = setmetatable({ }, { }) +_module_0.itemA = tb +getmetatable(_module_0).__index = items +_module_0["a-b-c"] = 123 +return _module_0 +local _module_0 = { } +local d, e, f = 3, 2, 1 +_module_0[#_module_0 + 1] = d +_module_0[#_module_0 + 1] = e +_module_0[#_module_0 + 1] = f +if this then + _module_0[#_module_0 + 1] = 123 +else + _module_0[#_module_0 + 1] = 456 +end +local _with_0 = tmp +local j = 2000 +_module_0[#_module_0 + 1] = _with_0 +return _module_0 +local _module_0 = nil +_module_0 = function() + print("hello") + return 123 +end +return _module_0 diff --git a/spec/outputs/codes_from_doc_pt-br.lua b/spec/outputs/codes_from_doc_pt-br.lua index f5643c8..caa15d6 100644 --- a/spec/outputs/codes_from_doc_pt-br.lua +++ b/spec/outputs/codes_from_doc_pt-br.lua @@ -3,6 +3,18 @@ do print(var) end print(var) +local status, value +do + repeat + local n = 12 + if n > 10 then + status, value = "large", n + break + end + status, value = "small", n + break + until true +end local counter do local i = 0 @@ -24,6 +36,18 @@ do print(var) end print(var) +local status, value +do + repeat + local n = 12 + if n > 10 then + status, value = "large", n + break + end + status, value = "small", n + break + until true +end local counter do local i = 0 @@ -146,385 +170,123 @@ end do print(123, "hello") end -do - local insert, concat = table.insert, table.concat - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local x, y, z - do - local _obj_0 = require('mymodule') - x, y, z = _obj_0.x, _obj_0.y, _obj_0.z - end - local a, b, c - local _obj_0 = require('module') - a, b, c = _obj_0.a, _obj_0.b, _obj_0.c -end -do - local module = require('module') - local module_x = require('module_x') - local d_a_s_h_e_s = require("d-a-s-h-e-s") - local part = require("module.part") +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +local success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return yue.traceback(err) +end) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +success, result = pcall(function() + return func(1, 2, 3) +end) +pcall(function() + print("trying") + return func(1, 2, 3) +end) +success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +if success then + print(result) end +local a, b, c do - local PlayerModule = require("player") - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() + return func() + end) + if _ok_0 then + a, b, c = _ret_0, _ret_1, _ret_2 end - local one, two, ch - local _obj_0 = require("export") - one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] -end -do - local tostring = tostring - local concat = table.concat - print(concat({ - "a", - tostring(1) - })) end do - local print = print - local math = math - print("hello") - math.random(3) -end -do - local print = print - print(FLAG) - FLAG = 123 -end -local _module_0 = { } -local a, b, c = 1, 2, 3 -_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c -local cool = "cat" -_module_0["cool"] = cool -local What -if this then - What = "abc" -else - What = "def" -end -_module_0["What"] = What -local y -y = function() - local hallo = 3434 -end -_module_0["y"] = y -local Something -local _class_0 -local _base_0 = { - umm = "cool" -} -if _base_0.__index == nil then - _base_0.__index = _base_0 -end -_class_0 = setmetatable({ - __init = function() end, - __base = _base_0, - __name = "Something" -}, { - __index = _base_0, - __call = function(cls, ...) - local _self_0 = setmetatable({ }, _base_0) - cls.__init(_self_0, ...) - return _self_0 + local _exp_0 = ((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(pcall(function() + return func() + end)) + end)()) + if _exp_0 ~= nil then + a = _exp_0 + else + a = "default" end -}) -_base_0.__class = _class_0 -Something = _class_0 -_module_0["Something"] = Something -return _module_0 -local _module_0 = { } -local loadstring, tolua -do - local _obj_0 = yue - loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua -end -_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua -local fieldA = tb.itemA.fieldA -if fieldA == nil then - fieldA = 'default' -end -_module_0["fieldA"] = fieldA -return _module_0 -local _module_0 = setmetatable({ }, { }) -_module_0.itemA = tb -getmetatable(_module_0).__index = items -_module_0["a-b-c"] = 123 -return _module_0 -local _module_0 = { } -local d, e, f = 3, 2, 1 -_module_0[#_module_0 + 1] = d -_module_0[#_module_0 + 1] = e -_module_0[#_module_0 + 1] = f -if this then - _module_0[#_module_0 + 1] = 123 -else - _module_0[#_module_0 + 1] = 456 end -local _with_0 = tmp -local j = 2000 -_module_0[#_module_0 + 1] = _with_0 -return _module_0 -local _module_0 = nil -_module_0 = function() - print("hello") - return 123 +f((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(pcall(function() + return func() + end)) +end)()) +f((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(xpcall(function() + print(123) + return func() + end, function(e) + print(e) + return e + end)) +end)()) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +local success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return yue.traceback(err) +end) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +success, result = pcall(function() + return func(1, 2, 3) +end) +pcall(function() + print("trying") + return func(1, 2, 3) +end) +success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +if success then + print(result) end -return _module_0 +local a, b, c do - local insert, concat = table.insert, table.concat - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local x, y, z - do - local _obj_0 = require('mymodule') - x, y, z = _obj_0.x, _obj_0.y, _obj_0.z - end - local a, b, c - local _obj_0 = require('module') - a, b, c = _obj_0.a, _obj_0.b, _obj_0.c -end -do - local module = require('module') - local module_x = require('module_x') - local d_a_s_h_e_s = require("d-a-s-h-e-s") - local part = require("module.part") -end -do - local PlayerModule = require("player") - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local one, two, ch - local _obj_0 = require("export") - one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] -end -do - local tostring = tostring - local concat = table.concat - print(concat({ - "a", - tostring(1) - })) -end -do - local print = print - local math = math - print("hello") - math.random(3) -end -do - local print = print - print(FLAG) - FLAG = 123 -end -local _module_0 = { } -local a, b, c = 1, 2, 3 -_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c -local cool = "cat" -_module_0["cool"] = cool -local What -if this then - What = "abc" -else - What = "def" -end -_module_0["What"] = What -local y -y = function() - local hallo = 3434 -end -_module_0["y"] = y -local Something -local _class_0 -local _base_0 = { - umm = "cool" -} -if _base_0.__index == nil then - _base_0.__index = _base_0 -end -_class_0 = setmetatable({ - __init = function() end, - __base = _base_0, - __name = "Something" -}, { - __index = _base_0, - __call = function(cls, ...) - local _self_0 = setmetatable({ }, _base_0) - cls.__init(_self_0, ...) - return _self_0 - end -}) -_base_0.__class = _class_0 -Something = _class_0 -_module_0["Something"] = Something -return _module_0 -local _module_0 = { } -local loadstring, tolua -do - local _obj_0 = yue - loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua -end -_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua -local fieldA = tb.itemA.fieldA -if fieldA == nil then - fieldA = 'default' -end -_module_0["fieldA"] = fieldA -return _module_0 -local _module_0 = setmetatable({ }, { }) -_module_0.itemA = tb -getmetatable(_module_0).__index = items -_module_0["a-b-c"] = 123 -return _module_0 -local _module_0 = { } -local d, e, f = 3, 2, 1 -_module_0[#_module_0 + 1] = d -_module_0[#_module_0 + 1] = e -_module_0[#_module_0 + 1] = f -if this then - _module_0[#_module_0 + 1] = 123 -else - _module_0[#_module_0 + 1] = 456 -end -local _with_0 = tmp -local j = 2000 -_module_0[#_module_0 + 1] = _with_0 -return _module_0 -local _module_0 = nil -_module_0 = function() - print("hello") - return 123 -end -return _module_0 -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -local success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return yue.traceback(err) -end) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -success, result = pcall(function() - return func(1, 2, 3) -end) -pcall(function() - print("trying") - return func(1, 2, 3) -end) -success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -if success then - print(result) -end -local a, b, c -do - local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() - return func() - end) - if _ok_0 then - a, b, c = _ret_0, _ret_1, _ret_2 - end -end -do - local _exp_0 = ((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(pcall(function() - return func() - end)) - end)()) - if _exp_0 ~= nil then - a = _exp_0 - else - a = "default" - end -end -f((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(pcall(function() - return func() - end)) -end)()) -f((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(xpcall(function() - print(123) - return func() - end, function(e) - print(e) - return e - end)) -end)()) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -local success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return yue.traceback(err) -end) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -success, result = pcall(function() - return func(1, 2, 3) -end) -pcall(function() - print("trying") - return func(1, 2, 3) -end) -success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -if success then - print(result) -end -local a, b, c -do - local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() - return func() - end) - if _ok_0 then - a, b, c = _ret_0, _ret_1, _ret_2 + local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() + return func() + end) + if _ok_0 then + a, b, c = _ret_0, _ret_1, _ret_2 end end do @@ -2395,6 +2157,12 @@ local file local _with_0 = File("favorite_foods.txt") _with_0:set_encoding("utf8") file = _with_0 +local result +local _with_0 = obj +repeat + result = _with_0.value + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -2435,6 +2203,12 @@ local file local _with_0 = File("favorite_foods.txt") _with_0:set_encoding("utf8") file = _with_0 +local result +local _with_0 = obj +repeat + result = _with_0.value + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -3268,6 +3042,13 @@ for _index_0 = 1, #_list_0 do break end end +local key, score +for k, v in pairs(data) do + if k == "target" then + key, score = k, v * 10 + break + end +end local func_a func_a = function() for i = 1, 10 do @@ -3330,6 +3111,13 @@ for _index_0 = 1, #_list_0 do break end end +local key, score +for k, v in pairs(data) do + if k == "target" then + key, score = k, v * 10 + break + end +end local func_a func_a = function() for i = 1, 10 do @@ -4008,11 +3796,32 @@ end while not (running == false) do my_function() end +local value, doubled +local _val_0, _val_1 +while true do + local n = get_next() + if n > 10 then + _val_0, _val_1 = n, n * 2 + break + end +end +value, doubled = _val_0, _val_1 local i = 10 repeat print(i) i = i - 1 until i == 0 +local i = 1 +local value, scaled +local _val_0, _val_1 +repeat + if i > 3 then + _val_0, _val_1 = i, i * 100 + break + end + i = i + 1 +until false +value, scaled = _val_0, _val_1 local i = 10 while i > 0 do print(i) @@ -4029,12 +3838,33 @@ end while not (running == false) do my_function() end +local value, doubled +local _val_0, _val_1 +while true do + local n = get_next() + if n > 10 then + _val_0, _val_1 = n, n * 2 + break + end +end +value, doubled = _val_0, _val_1 local i = 10 repeat print(i) i = i - 1 until i == 0 -local my_object = { +local i = 1 +local value, scaled +local _val_0, _val_1 +repeat + if i > 3 then + _val_0, _val_1 = i, i * 100 + break + end + i = i + 1 +until false +value, scaled = _val_0, _val_1 +local my_object = { value = 1000, write = function(self) return print("the value:", self.value) @@ -5136,3 +4966,265 @@ fn = function() return str end local str = "path: \"C:\\Program Files\\App\"\nnote: 'Ele disse: \"" .. tostring(Hello) .. "!\"'" +do + local insert, concat = table.insert, table.concat + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local x, y, z + do + local _obj_0 = require('mymodule') + x, y, z = _obj_0.x, _obj_0.y, _obj_0.z + end + local a, b, c + local _obj_0 = require('module') + a, b, c = _obj_0.a, _obj_0.b, _obj_0.c +end +do + local module = require('module') + local module_x = require('module_x') + local d_a_s_h_e_s = require("d-a-s-h-e-s") + local part = require("module.part") +end +do + local PlayerModule = require("player") + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local one, two, ch + local _obj_0 = require("export") + one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] +end +do + local tostring = tostring + local concat = table.concat + print(concat({ + "a", + tostring(1) + })) +end +do + local print = print + local math = math + print("hello") + math.random(3) +end +do + local print = print + print(FLAG) + FLAG = 123 +end +local _module_0 = { } +local a, b, c = 1, 2, 3 +_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c +local cool = "cat" +_module_0["cool"] = cool +local What +if this then + What = "abc" +else + What = "def" +end +_module_0["What"] = What +local y +y = function() + local hallo = 3434 +end +_module_0["y"] = y +local Something +local _class_0 +local _base_0 = { + umm = "cool" +} +if _base_0.__index == nil then + _base_0.__index = _base_0 +end +_class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "Something" +}, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({ }, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end +}) +_base_0.__class = _class_0 +Something = _class_0 +_module_0["Something"] = Something +return _module_0 +local _module_0 = { } +local loadstring, tolua +do + local _obj_0 = yue + loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua +end +_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua +local fieldA = tb.itemA.fieldA +if fieldA == nil then + fieldA = 'default' +end +_module_0["fieldA"] = fieldA +return _module_0 +local _module_0 = setmetatable({ }, { }) +_module_0.itemA = tb +getmetatable(_module_0).__index = items +_module_0["a-b-c"] = 123 +return _module_0 +local _module_0 = { } +local d, e, f = 3, 2, 1 +_module_0[#_module_0 + 1] = d +_module_0[#_module_0 + 1] = e +_module_0[#_module_0 + 1] = f +if this then + _module_0[#_module_0 + 1] = 123 +else + _module_0[#_module_0 + 1] = 456 +end +local _with_0 = tmp +local j = 2000 +_module_0[#_module_0 + 1] = _with_0 +return _module_0 +local _module_0 = nil +_module_0 = function() + print("hello") + return 123 +end +return _module_0 +do + local insert, concat = table.insert, table.concat + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local x, y, z + do + local _obj_0 = require('mymodule') + x, y, z = _obj_0.x, _obj_0.y, _obj_0.z + end + local a, b, c + local _obj_0 = require('module') + a, b, c = _obj_0.a, _obj_0.b, _obj_0.c +end +do + local module = require('module') + local module_x = require('module_x') + local d_a_s_h_e_s = require("d-a-s-h-e-s") + local part = require("module.part") +end +do + local PlayerModule = require("player") + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local one, two, ch + local _obj_0 = require("export") + one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] +end +do + local tostring = tostring + local concat = table.concat + print(concat({ + "a", + tostring(1) + })) +end +do + local print = print + local math = math + print("hello") + math.random(3) +end +do + local print = print + print(FLAG) + FLAG = 123 +end +local _module_0 = { } +local a, b, c = 1, 2, 3 +_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c +local cool = "cat" +_module_0["cool"] = cool +local What +if this then + What = "abc" +else + What = "def" +end +_module_0["What"] = What +local y +y = function() + local hallo = 3434 +end +_module_0["y"] = y +local Something +local _class_0 +local _base_0 = { + umm = "cool" +} +if _base_0.__index == nil then + _base_0.__index = _base_0 +end +_class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "Something" +}, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({ }, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end +}) +_base_0.__class = _class_0 +Something = _class_0 +_module_0["Something"] = Something +return _module_0 +local _module_0 = { } +local loadstring, tolua +do + local _obj_0 = yue + loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua +end +_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua +local fieldA = tb.itemA.fieldA +if fieldA == nil then + fieldA = 'default' +end +_module_0["fieldA"] = fieldA +return _module_0 +local _module_0 = setmetatable({ }, { }) +_module_0.itemA = tb +getmetatable(_module_0).__index = items +_module_0["a-b-c"] = 123 +return _module_0 +local _module_0 = { } +local d, e, f = 3, 2, 1 +_module_0[#_module_0 + 1] = d +_module_0[#_module_0 + 1] = e +_module_0[#_module_0 + 1] = f +if this then + _module_0[#_module_0 + 1] = 123 +else + _module_0[#_module_0 + 1] = 456 +end +local _with_0 = tmp +local j = 2000 +_module_0[#_module_0 + 1] = _with_0 +return _module_0 +local _module_0 = nil +_module_0 = function() + print("hello") + return 123 +end +return _module_0 diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua index 087782e..4ff3866 100644 --- a/spec/outputs/codes_from_doc_zh.lua +++ b/spec/outputs/codes_from_doc_zh.lua @@ -3,6 +3,18 @@ do print(var) end print(var) +local status, value +do + repeat + local n = 12 + if n > 10 then + status, value = "large", n + break + end + status, value = "small", n + break + until true +end local counter do local i = 0 @@ -24,6 +36,18 @@ do print(var) end print(var) +local status, value +do + repeat + local n = 12 + if n > 10 then + status, value = "large", n + break + end + status, value = "small", n + break + until true +end local counter do local i = 0 @@ -146,385 +170,123 @@ end do print(123, "hello") end -do - local insert, concat = table.insert, table.concat - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local x, y, z - do - local _obj_0 = require('mymodule') - x, y, z = _obj_0.x, _obj_0.y, _obj_0.z - end - local a, b, c - local _obj_0 = require('module') - a, b, c = _obj_0.a, _obj_0.b, _obj_0.c -end -do - local module = require('module') - local module_x = require('module_x') - local d_a_s_h_e_s = require("d-a-s-h-e-s") - local part = require("module.part") +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +local success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return yue.traceback(err) +end) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +success, result = pcall(function() + return func(1, 2, 3) +end) +pcall(function() + print("尝试中") + return func(1, 2, 3) +end) +success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +if success then + print(result) end +local a, b, c do - local PlayerModule = require("player") - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() + return func() + end) + if _ok_0 then + a, b, c = _ret_0, _ret_1, _ret_2 end - local one, two, ch - local _obj_0 = require("export") - one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] -end -do - local tostring = tostring - local concat = table.concat - print(concat({ - "a", - tostring(1) - })) end do - local print = print - local math = math - print("hello") - math.random(3) -end -do - local print = print - print(FLAG) - FLAG = 123 -end -local _module_0 = { } -local a, b, c = 1, 2, 3 -_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c -local cool = "cat" -_module_0["cool"] = cool -local What -if this then - What = "abc" -else - What = "def" -end -_module_0["What"] = What -local y -y = function() - local hallo = 3434 -end -_module_0["y"] = y -local Something -local _class_0 -local _base_0 = { - umm = "cool" -} -if _base_0.__index == nil then - _base_0.__index = _base_0 -end -_class_0 = setmetatable({ - __init = function() end, - __base = _base_0, - __name = "Something" -}, { - __index = _base_0, - __call = function(cls, ...) - local _self_0 = setmetatable({ }, _base_0) - cls.__init(_self_0, ...) - return _self_0 + local _exp_0 = ((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(pcall(function() + return func() + end)) + end)()) + if _exp_0 ~= nil then + a = _exp_0 + else + a = "default" end -}) -_base_0.__class = _class_0 -Something = _class_0 -_module_0["Something"] = Something -return _module_0 -local _module_0 = { } -local loadstring, tolua -do - local _obj_0 = yue - loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua -end -_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua -local fieldA = tb.itemA.fieldA -if fieldA == nil then - fieldA = '默认值' -end -_module_0["fieldA"] = fieldA -return _module_0 -local _module_0 = setmetatable({ }, { }) -_module_0.itemA = tb -getmetatable(_module_0).__index = items -_module_0["a-b-c"] = 123 -return _module_0 -local _module_0 = { } -local d, e, f = 3, 2, 1 -_module_0[#_module_0 + 1] = d -_module_0[#_module_0 + 1] = e -_module_0[#_module_0 + 1] = f -if this then - _module_0[#_module_0 + 1] = 123 -else - _module_0[#_module_0 + 1] = 456 end -local _with_0 = tmp -local j = 2000 -_module_0[#_module_0 + 1] = _with_0 -return _module_0 -local _module_0 = nil -_module_0 = function() - print("你好") - return 123 +f((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(pcall(function() + return func() + end)) +end)()) +f((function() + return (function(_arg_0, ...) + local _ok_0 = _arg_0 + if _ok_0 then + return ... + end + end)(xpcall(function() + print(123) + return func() + end, function(e) + print(e) + return e + end)) +end)()) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +local success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return yue.traceback(err) +end) +xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +success, result = pcall(function() + return func(1, 2, 3) +end) +pcall(function() + print("尝试中") + return func(1, 2, 3) +end) +success, result = xpcall(function() + return func(1, 2, 3) +end, function(err) + return print(yue.traceback(err)) +end) +if success then + print(result) end -return _module_0 +local a, b, c do - local insert, concat = table.insert, table.concat - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local x, y, z - do - local _obj_0 = require('mymodule') - x, y, z = _obj_0.x, _obj_0.y, _obj_0.z - end - local a, b, c - local _obj_0 = require('module') - a, b, c = _obj_0.a, _obj_0.b, _obj_0.c -end -do - local module = require('module') - local module_x = require('module_x') - local d_a_s_h_e_s = require("d-a-s-h-e-s") - local part = require("module.part") -end -do - local PlayerModule = require("player") - local C, Ct, Cmt - do - local _obj_0 = require("lpeg") - C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt - end - local one, two, ch - local _obj_0 = require("export") - one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] -end -do - local tostring = tostring - local concat = table.concat - print(concat({ - "a", - tostring(1) - })) -end -do - local print = print - local math = math - print("hello") - math.random(3) -end -do - local print = print - print(FLAG) - FLAG = 123 -end -local _module_0 = { } -local a, b, c = 1, 2, 3 -_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c -local cool = "cat" -_module_0["cool"] = cool -local What -if this then - What = "abc" -else - What = "def" -end -_module_0["What"] = What -local y -y = function() - local hallo = 3434 -end -_module_0["y"] = y -local Something -local _class_0 -local _base_0 = { - umm = "cool" -} -if _base_0.__index == nil then - _base_0.__index = _base_0 -end -_class_0 = setmetatable({ - __init = function() end, - __base = _base_0, - __name = "Something" -}, { - __index = _base_0, - __call = function(cls, ...) - local _self_0 = setmetatable({ }, _base_0) - cls.__init(_self_0, ...) - return _self_0 - end -}) -_base_0.__class = _class_0 -Something = _class_0 -_module_0["Something"] = Something -return _module_0 -local _module_0 = { } -local loadstring, tolua -do - local _obj_0 = yue - loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua -end -_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua -local fieldA = tb.itemA.fieldA -if fieldA == nil then - fieldA = '默认值' -end -_module_0["fieldA"] = fieldA -return _module_0 -local _module_0 = setmetatable({ }, { }) -_module_0.itemA = tb -getmetatable(_module_0).__index = items -_module_0["a-b-c"] = 123 -return _module_0 -local _module_0 = { } -local d, e, f = 3, 2, 1 -_module_0[#_module_0 + 1] = d -_module_0[#_module_0 + 1] = e -_module_0[#_module_0 + 1] = f -if this then - _module_0[#_module_0 + 1] = 123 -else - _module_0[#_module_0 + 1] = 456 -end -local _with_0 = tmp -local j = 2000 -_module_0[#_module_0 + 1] = _with_0 -return _module_0 -local _module_0 = nil -_module_0 = function() - print("你好") - return 123 -end -return _module_0 -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -local success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return yue.traceback(err) -end) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -success, result = pcall(function() - return func(1, 2, 3) -end) -pcall(function() - print("尝试中") - return func(1, 2, 3) -end) -success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -if success then - print(result) -end -local a, b, c -do - local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() - return func() - end) - if _ok_0 then - a, b, c = _ret_0, _ret_1, _ret_2 - end -end -do - local _exp_0 = ((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(pcall(function() - return func() - end)) - end)()) - if _exp_0 ~= nil then - a = _exp_0 - else - a = "default" - end -end -f((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(pcall(function() - return func() - end)) -end)()) -f((function() - return (function(_arg_0, ...) - local _ok_0 = _arg_0 - if _ok_0 then - return ... - end - end)(xpcall(function() - print(123) - return func() - end, function(e) - print(e) - return e - end)) -end)()) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -local success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return yue.traceback(err) -end) -xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -success, result = pcall(function() - return func(1, 2, 3) -end) -pcall(function() - print("尝试中") - return func(1, 2, 3) -end) -success, result = xpcall(function() - return func(1, 2, 3) -end, function(err) - return print(yue.traceback(err)) -end) -if success then - print(result) -end -local a, b, c -do - local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() - return func() - end) - if _ok_0 then - a, b, c = _ret_0, _ret_1, _ret_2 + local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() + return func() + end) + if _ok_0 then + a, b, c = _ret_0, _ret_1, _ret_2 end end do @@ -2395,6 +2157,12 @@ local file local _with_0 = File("favorite_foods.txt") _with_0:set_encoding("utf8") file = _with_0 +local result +local _with_0 = obj +repeat + result = _with_0.value + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -2435,6 +2203,12 @@ local file local _with_0 = File("favorite_foods.txt") _with_0:set_encoding("utf8") file = _with_0 +local result +local _with_0 = obj +repeat + result = _with_0.value + break +until true local create_person create_person = function(name, relatives) local _with_0 = Person() @@ -3268,6 +3042,13 @@ for _index_0 = 1, #_list_0 do break end end +local key, score +for k, v in pairs(data) do + if k == "target" then + key, score = k, v * 10 + break + end +end local func_a func_a = function() for i = 1, 10 do @@ -3330,6 +3111,13 @@ for _index_0 = 1, #_list_0 do break end end +local key, score +for k, v in pairs(data) do + if k == "target" then + key, score = k, v * 10 + break + end +end local func_a func_a = function() for i = 1, 10 do @@ -4008,11 +3796,32 @@ end while not (running == false) do my_function() end +local value, doubled +local _val_0, _val_1 +while true do + local n = get_next() + if n > 10 then + _val_0, _val_1 = n, n * 2 + break + end +end +value, doubled = _val_0, _val_1 local i = 10 repeat print(i) i = i - 1 until i == 0 +local i = 1 +local value, scaled +local _val_0, _val_1 +repeat + if i > 3 then + _val_0, _val_1 = i, i * 100 + break + end + i = i + 1 +until false +value, scaled = _val_0, _val_1 local i = 10 while i > 0 do print(i) @@ -4029,12 +3838,33 @@ end while not (running == false) do my_function() end +local value, doubled +local _val_0, _val_1 +while true do + local n = get_next() + if n > 10 then + _val_0, _val_1 = n, n * 2 + break + end +end +value, doubled = _val_0, _val_1 local i = 10 repeat print(i) i = i - 1 until i == 0 -local my_object = { +local i = 1 +local value, scaled +local _val_0, _val_1 +repeat + if i > 3 then + _val_0, _val_1 = i, i * 100 + break + end + i = i + 1 +until false +value, scaled = _val_0, _val_1 +local my_object = { value = 1000, write = function(self) return print("值为:", self.value) @@ -5136,3 +4966,265 @@ fn = function() return str end local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" +do + local insert, concat = table.insert, table.concat + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local x, y, z + do + local _obj_0 = require('mymodule') + x, y, z = _obj_0.x, _obj_0.y, _obj_0.z + end + local a, b, c + local _obj_0 = require('module') + a, b, c = _obj_0.a, _obj_0.b, _obj_0.c +end +do + local module = require('module') + local module_x = require('module_x') + local d_a_s_h_e_s = require("d-a-s-h-e-s") + local part = require("module.part") +end +do + local PlayerModule = require("player") + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local one, two, ch + local _obj_0 = require("export") + one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] +end +do + local tostring = tostring + local concat = table.concat + print(concat({ + "a", + tostring(1) + })) +end +do + local print = print + local math = math + print("hello") + math.random(3) +end +do + local print = print + print(FLAG) + FLAG = 123 +end +local _module_0 = { } +local a, b, c = 1, 2, 3 +_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c +local cool = "cat" +_module_0["cool"] = cool +local What +if this then + What = "abc" +else + What = "def" +end +_module_0["What"] = What +local y +y = function() + local hallo = 3434 +end +_module_0["y"] = y +local Something +local _class_0 +local _base_0 = { + umm = "cool" +} +if _base_0.__index == nil then + _base_0.__index = _base_0 +end +_class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "Something" +}, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({ }, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end +}) +_base_0.__class = _class_0 +Something = _class_0 +_module_0["Something"] = Something +return _module_0 +local _module_0 = { } +local loadstring, tolua +do + local _obj_0 = yue + loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua +end +_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua +local fieldA = tb.itemA.fieldA +if fieldA == nil then + fieldA = '默认值' +end +_module_0["fieldA"] = fieldA +return _module_0 +local _module_0 = setmetatable({ }, { }) +_module_0.itemA = tb +getmetatable(_module_0).__index = items +_module_0["a-b-c"] = 123 +return _module_0 +local _module_0 = { } +local d, e, f = 3, 2, 1 +_module_0[#_module_0 + 1] = d +_module_0[#_module_0 + 1] = e +_module_0[#_module_0 + 1] = f +if this then + _module_0[#_module_0 + 1] = 123 +else + _module_0[#_module_0 + 1] = 456 +end +local _with_0 = tmp +local j = 2000 +_module_0[#_module_0 + 1] = _with_0 +return _module_0 +local _module_0 = nil +_module_0 = function() + print("你好") + return 123 +end +return _module_0 +do + local insert, concat = table.insert, table.concat + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local x, y, z + do + local _obj_0 = require('mymodule') + x, y, z = _obj_0.x, _obj_0.y, _obj_0.z + end + local a, b, c + local _obj_0 = require('module') + a, b, c = _obj_0.a, _obj_0.b, _obj_0.c +end +do + local module = require('module') + local module_x = require('module_x') + local d_a_s_h_e_s = require("d-a-s-h-e-s") + local part = require("module.part") +end +do + local PlayerModule = require("player") + local C, Ct, Cmt + do + local _obj_0 = require("lpeg") + C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt + end + local one, two, ch + local _obj_0 = require("export") + one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] +end +do + local tostring = tostring + local concat = table.concat + print(concat({ + "a", + tostring(1) + })) +end +do + local print = print + local math = math + print("hello") + math.random(3) +end +do + local print = print + print(FLAG) + FLAG = 123 +end +local _module_0 = { } +local a, b, c = 1, 2, 3 +_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c +local cool = "cat" +_module_0["cool"] = cool +local What +if this then + What = "abc" +else + What = "def" +end +_module_0["What"] = What +local y +y = function() + local hallo = 3434 +end +_module_0["y"] = y +local Something +local _class_0 +local _base_0 = { + umm = "cool" +} +if _base_0.__index == nil then + _base_0.__index = _base_0 +end +_class_0 = setmetatable({ + __init = function() end, + __base = _base_0, + __name = "Something" +}, { + __index = _base_0, + __call = function(cls, ...) + local _self_0 = setmetatable({ }, _base_0) + cls.__init(_self_0, ...) + return _self_0 + end +}) +_base_0.__class = _class_0 +Something = _class_0 +_module_0["Something"] = Something +return _module_0 +local _module_0 = { } +local loadstring, tolua +do + local _obj_0 = yue + loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua +end +_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua +local fieldA = tb.itemA.fieldA +if fieldA == nil then + fieldA = '默认值' +end +_module_0["fieldA"] = fieldA +return _module_0 +local _module_0 = setmetatable({ }, { }) +_module_0.itemA = tb +getmetatable(_module_0).__index = items +_module_0["a-b-c"] = 123 +return _module_0 +local _module_0 = { } +local d, e, f = 3, 2, 1 +_module_0[#_module_0 + 1] = d +_module_0[#_module_0 + 1] = e +_module_0[#_module_0 + 1] = f +if this then + _module_0[#_module_0 + 1] = 123 +else + _module_0[#_module_0 + 1] = 456 +end +local _with_0 = tmp +local j = 2000 +_module_0[#_module_0 + 1] = _with_0 +return _module_0 +local _module_0 = nil +_module_0 = function() + print("你好") + return 123 +end +return _module_0 diff --git a/spec/outputs/compile_doc.lua b/spec/outputs/compile_doc.lua index 6a5efd5..8d5c11a 100644 --- a/spec/outputs/compile_doc.lua +++ b/spec/outputs/compile_doc.lua @@ -11,7 +11,6 @@ getFiles = function(locale) "doc/docs/" .. tostring(locale) .. "doc/advanced/do.md", "doc/docs/" .. tostring(locale) .. "doc/advanced/line-decorators.md", "doc/docs/" .. tostring(locale) .. "doc/advanced/macro.md", - "doc/docs/" .. tostring(locale) .. "doc/advanced/module.md", "doc/docs/" .. tostring(locale) .. "doc/advanced/try.md", "doc/docs/" .. tostring(locale) .. "doc/data-structures/table-literals.md", "doc/docs/" .. tostring(locale) .. "doc/data-structures/comprehensions.md", @@ -38,6 +37,7 @@ getFiles = function(locale) "doc/docs/" .. tostring(locale) .. "doc/language-basics/attributes.md", "doc/docs/" .. tostring(locale) .. "doc/language-basics/operator.md", "doc/docs/" .. tostring(locale) .. "doc/language-basics/literals.md", + "doc/docs/" .. tostring(locale) .. "doc/language-basics/module.md", "doc/docs/" .. tostring(locale) .. "doc/reference/license-mit.md", "doc/docs/" .. tostring(locale) .. "doc/reference/the-yuescript-library.md" } -- cgit v1.2.3-55-g6feb