aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/codes_from_doc_zh.lua
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-02-12 10:29:07 +0800
committerLi Jin <dragon-fly@qq.com>2026-02-12 10:29:07 +0800
commitd63779ec0a6f00854f53b48b0f6a67707879b6d1 (patch)
treef9d7e736c31601dcfe1781a7f9eef9bfb3e3fed8 /spec/outputs/codes_from_doc_zh.lua
parent82e9b379db4eb77f82cf5693e476597feb18e40b (diff)
downloadyuescript-d63779ec0a6f00854f53b48b0f6a67707879b6d1.tar.gz
yuescript-d63779ec0a6f00854f53b48b0f6a67707879b6d1.tar.bz2
yuescript-d63779ec0a6f00854f53b48b0f6a67707879b6d1.zip
Updated docs.
Diffstat (limited to 'spec/outputs/codes_from_doc_zh.lua')
-rw-r--r--spec/outputs/codes_from_doc_zh.lua616
1 files changed, 354 insertions, 262 deletions
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
3 print(var) 3 print(var)
4end 4end
5print(var) 5print(var)
6local status, value
7do
8 repeat
9 local n = 12
10 if n > 10 then
11 status, value = "large", n
12 break
13 end
14 status, value = "small", n
15 break
16 until true
17end
6local counter 18local counter
7do 19do
8 local i = 0 20 local i = 0
@@ -24,6 +36,18 @@ do
24 print(var) 36 print(var)
25end 37end
26print(var) 38print(var)
39local status, value
40do
41 repeat
42 local n = 12
43 if n > 10 then
44 status, value = "large", n
45 break
46 end
47 status, value = "small", n
48 break
49 until true
50end
27local counter 51local counter
28do 52do
29 local i = 0 53 local i = 0
@@ -146,268 +170,6 @@ end
146do 170do
147 print(123, "hello") 171 print(123, "hello")
148end 172end
149do
150 local insert, concat = table.insert, table.concat
151 local C, Ct, Cmt
152 do
153 local _obj_0 = require("lpeg")
154 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
155 end
156 local x, y, z
157 do
158 local _obj_0 = require('mymodule')
159 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z
160 end
161 local a, b, c
162 local _obj_0 = require('module')
163 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
164end
165do
166 local module = require('module')
167 local module_x = require('module_x')
168 local d_a_s_h_e_s = require("d-a-s-h-e-s")
169 local part = require("module.part")
170end
171do
172 local PlayerModule = require("player")
173 local C, Ct, Cmt
174 do
175 local _obj_0 = require("lpeg")
176 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
177 end
178 local one, two, ch
179 local _obj_0 = require("export")
180 one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1]
181end
182do
183 local tostring <const> = tostring
184 local concat <const> = table.concat
185 print(concat({
186 "a",
187 tostring(1)
188 }))
189end
190do
191 local print <const> = print
192 local math <const> = math
193 print("hello")
194 math.random(3)
195end
196do
197 local print <const> = print
198 print(FLAG)
199 FLAG = 123
200end
201local _module_0 = { }
202local a, b, c = 1, 2, 3
203_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c
204local cool = "cat"
205_module_0["cool"] = cool
206local What
207if this then
208 What = "abc"
209else
210 What = "def"
211end
212_module_0["What"] = What
213local y
214y = function()
215 local hallo = 3434
216end
217_module_0["y"] = y
218local Something
219local _class_0
220local _base_0 = {
221 umm = "cool"
222}
223if _base_0.__index == nil then
224 _base_0.__index = _base_0
225end
226_class_0 = setmetatable({
227 __init = function() end,
228 __base = _base_0,
229 __name = "Something"
230}, {
231 __index = _base_0,
232 __call = function(cls, ...)
233 local _self_0 = setmetatable({ }, _base_0)
234 cls.__init(_self_0, ...)
235 return _self_0
236 end
237})
238_base_0.__class = _class_0
239Something = _class_0
240_module_0["Something"] = Something
241return _module_0
242local _module_0 = { }
243local loadstring, tolua
244do
245 local _obj_0 = yue
246 loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua
247end
248_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua
249local fieldA = tb.itemA.fieldA
250if fieldA == nil then
251 fieldA = '默认值'
252end
253_module_0["fieldA"] = fieldA
254return _module_0
255local _module_0 = setmetatable({ }, { })
256_module_0.itemA = tb
257getmetatable(_module_0).__index = items
258_module_0["a-b-c"] = 123
259return _module_0
260local _module_0 = { }
261local d, e, f = 3, 2, 1
262_module_0[#_module_0 + 1] = d
263_module_0[#_module_0 + 1] = e
264_module_0[#_module_0 + 1] = f
265if this then
266 _module_0[#_module_0 + 1] = 123
267else
268 _module_0[#_module_0 + 1] = 456
269end
270local _with_0 = tmp
271local j = 2000
272_module_0[#_module_0 + 1] = _with_0
273return _module_0
274local _module_0 = nil
275_module_0 = function()
276 print("你好")
277 return 123
278end
279return _module_0
280do
281 local insert, concat = table.insert, table.concat
282 local C, Ct, Cmt
283 do
284 local _obj_0 = require("lpeg")
285 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
286 end
287 local x, y, z
288 do
289 local _obj_0 = require('mymodule')
290 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z
291 end
292 local a, b, c
293 local _obj_0 = require('module')
294 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
295end
296do
297 local module = require('module')
298 local module_x = require('module_x')
299 local d_a_s_h_e_s = require("d-a-s-h-e-s")
300 local part = require("module.part")
301end
302do
303 local PlayerModule = require("player")
304 local C, Ct, Cmt
305 do
306 local _obj_0 = require("lpeg")
307 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
308 end
309 local one, two, ch
310 local _obj_0 = require("export")
311 one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1]
312end
313do
314 local tostring <const> = tostring
315 local concat <const> = table.concat
316 print(concat({
317 "a",
318 tostring(1)
319 }))
320end
321do
322 local print <const> = print
323 local math <const> = math
324 print("hello")
325 math.random(3)
326end
327do
328 local print <const> = print
329 print(FLAG)
330 FLAG = 123
331end
332local _module_0 = { }
333local a, b, c = 1, 2, 3
334_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c
335local cool = "cat"
336_module_0["cool"] = cool
337local What
338if this then
339 What = "abc"
340else
341 What = "def"
342end
343_module_0["What"] = What
344local y
345y = function()
346 local hallo = 3434
347end
348_module_0["y"] = y
349local Something
350local _class_0
351local _base_0 = {
352 umm = "cool"
353}
354if _base_0.__index == nil then
355 _base_0.__index = _base_0
356end
357_class_0 = setmetatable({
358 __init = function() end,
359 __base = _base_0,
360 __name = "Something"
361}, {
362 __index = _base_0,
363 __call = function(cls, ...)
364 local _self_0 = setmetatable({ }, _base_0)
365 cls.__init(_self_0, ...)
366 return _self_0
367 end
368})
369_base_0.__class = _class_0
370Something = _class_0
371_module_0["Something"] = Something
372return _module_0
373local _module_0 = { }
374local loadstring, tolua
375do
376 local _obj_0 = yue
377 loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua
378end
379_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua
380local fieldA = tb.itemA.fieldA
381if fieldA == nil then
382 fieldA = '默认值'
383end
384_module_0["fieldA"] = fieldA
385return _module_0
386local _module_0 = setmetatable({ }, { })
387_module_0.itemA = tb
388getmetatable(_module_0).__index = items
389_module_0["a-b-c"] = 123
390return _module_0
391local _module_0 = { }
392local d, e, f = 3, 2, 1
393_module_0[#_module_0 + 1] = d
394_module_0[#_module_0 + 1] = e
395_module_0[#_module_0 + 1] = f
396if this then
397 _module_0[#_module_0 + 1] = 123
398else
399 _module_0[#_module_0 + 1] = 456
400end
401local _with_0 = tmp
402local j = 2000
403_module_0[#_module_0 + 1] = _with_0
404return _module_0
405local _module_0 = nil
406_module_0 = function()
407 print("你好")
408 return 123
409end
410return _module_0
411xpcall(function() 173xpcall(function()
412 return func(1, 2, 3) 174 return func(1, 2, 3)
413end, function(err) 175end, function(err)
@@ -2395,6 +2157,12 @@ local file
2395local _with_0 = File("favorite_foods.txt") 2157local _with_0 = File("favorite_foods.txt")
2396_with_0:set_encoding("utf8") 2158_with_0:set_encoding("utf8")
2397file = _with_0 2159file = _with_0
2160local result
2161local _with_0 = obj
2162repeat
2163 result = _with_0.value
2164 break
2165until true
2398local create_person 2166local create_person
2399create_person = function(name, relatives) 2167create_person = function(name, relatives)
2400 local _with_0 = Person() 2168 local _with_0 = Person()
@@ -2435,6 +2203,12 @@ local file
2435local _with_0 = File("favorite_foods.txt") 2203local _with_0 = File("favorite_foods.txt")
2436_with_0:set_encoding("utf8") 2204_with_0:set_encoding("utf8")
2437file = _with_0 2205file = _with_0
2206local result
2207local _with_0 = obj
2208repeat
2209 result = _with_0.value
2210 break
2211until true
2438local create_person 2212local create_person
2439create_person = function(name, relatives) 2213create_person = function(name, relatives)
2440 local _with_0 = Person() 2214 local _with_0 = Person()
@@ -3268,6 +3042,13 @@ for _index_0 = 1, #_list_0 do
3268 break 3042 break
3269 end 3043 end
3270end 3044end
3045local key, score
3046for k, v in pairs(data) do
3047 if k == "target" then
3048 key, score = k, v * 10
3049 break
3050 end
3051end
3271local func_a 3052local func_a
3272func_a = function() 3053func_a = function()
3273 for i = 1, 10 do 3054 for i = 1, 10 do
@@ -3330,6 +3111,13 @@ for _index_0 = 1, #_list_0 do
3330 break 3111 break
3331 end 3112 end
3332end 3113end
3114local key, score
3115for k, v in pairs(data) do
3116 if k == "target" then
3117 key, score = k, v * 10
3118 break
3119 end
3120end
3333local func_a 3121local func_a
3334func_a = function() 3122func_a = function()
3335 for i = 1, 10 do 3123 for i = 1, 10 do
@@ -4008,11 +3796,32 @@ end
4008while not (running == false) do 3796while not (running == false) do
4009 my_function() 3797 my_function()
4010end 3798end
3799local value, doubled
3800local _val_0, _val_1
3801while true do
3802 local n = get_next()
3803 if n > 10 then
3804 _val_0, _val_1 = n, n * 2
3805 break
3806 end
3807end
3808value, doubled = _val_0, _val_1
4011local i = 10 3809local i = 10
4012repeat 3810repeat
4013 print(i) 3811 print(i)
4014 i = i - 1 3812 i = i - 1
4015until i == 0 3813until i == 0
3814local i = 1
3815local value, scaled
3816local _val_0, _val_1
3817repeat
3818 if i > 3 then
3819 _val_0, _val_1 = i, i * 100
3820 break
3821 end
3822 i = i + 1
3823until false
3824value, scaled = _val_0, _val_1
4016local i = 10 3825local i = 10
4017while i > 0 do 3826while i > 0 do
4018 print(i) 3827 print(i)
@@ -4029,11 +3838,32 @@ end
4029while not (running == false) do 3838while not (running == false) do
4030 my_function() 3839 my_function()
4031end 3840end
3841local value, doubled
3842local _val_0, _val_1
3843while true do
3844 local n = get_next()
3845 if n > 10 then
3846 _val_0, _val_1 = n, n * 2
3847 break
3848 end
3849end
3850value, doubled = _val_0, _val_1
4032local i = 10 3851local i = 10
4033repeat 3852repeat
4034 print(i) 3853 print(i)
4035 i = i - 1 3854 i = i - 1
4036until i == 0 3855until i == 0
3856local i = 1
3857local value, scaled
3858local _val_0, _val_1
3859repeat
3860 if i > 3 then
3861 _val_0, _val_1 = i, i * 100
3862 break
3863 end
3864 i = i + 1
3865until false
3866value, scaled = _val_0, _val_1
4037local my_object = { 3867local my_object = {
4038 value = 1000, 3868 value = 1000,
4039 write = function(self) 3869 write = function(self)
@@ -5136,3 +4966,265 @@ fn = function()
5136 return str 4966 return str
5137end 4967end
5138local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" 4968local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'"
4969do
4970 local insert, concat = table.insert, table.concat
4971 local C, Ct, Cmt
4972 do
4973 local _obj_0 = require("lpeg")
4974 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
4975 end
4976 local x, y, z
4977 do
4978 local _obj_0 = require('mymodule')
4979 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z
4980 end
4981 local a, b, c
4982 local _obj_0 = require('module')
4983 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
4984end
4985do
4986 local module = require('module')
4987 local module_x = require('module_x')
4988 local d_a_s_h_e_s = require("d-a-s-h-e-s")
4989 local part = require("module.part")
4990end
4991do
4992 local PlayerModule = require("player")
4993 local C, Ct, Cmt
4994 do
4995 local _obj_0 = require("lpeg")
4996 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
4997 end
4998 local one, two, ch
4999 local _obj_0 = require("export")
5000 one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1]
5001end
5002do
5003 local tostring <const> = tostring
5004 local concat <const> = table.concat
5005 print(concat({
5006 "a",
5007 tostring(1)
5008 }))
5009end
5010do
5011 local print <const> = print
5012 local math <const> = math
5013 print("hello")
5014 math.random(3)
5015end
5016do
5017 local print <const> = print
5018 print(FLAG)
5019 FLAG = 123
5020end
5021local _module_0 = { }
5022local a, b, c = 1, 2, 3
5023_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c
5024local cool = "cat"
5025_module_0["cool"] = cool
5026local What
5027if this then
5028 What = "abc"
5029else
5030 What = "def"
5031end
5032_module_0["What"] = What
5033local y
5034y = function()
5035 local hallo = 3434
5036end
5037_module_0["y"] = y
5038local Something
5039local _class_0
5040local _base_0 = {
5041 umm = "cool"
5042}
5043if _base_0.__index == nil then
5044 _base_0.__index = _base_0
5045end
5046_class_0 = setmetatable({
5047 __init = function() end,
5048 __base = _base_0,
5049 __name = "Something"
5050}, {
5051 __index = _base_0,
5052 __call = function(cls, ...)
5053 local _self_0 = setmetatable({ }, _base_0)
5054 cls.__init(_self_0, ...)
5055 return _self_0
5056 end
5057})
5058_base_0.__class = _class_0
5059Something = _class_0
5060_module_0["Something"] = Something
5061return _module_0
5062local _module_0 = { }
5063local loadstring, tolua
5064do
5065 local _obj_0 = yue
5066 loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua
5067end
5068_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua
5069local fieldA = tb.itemA.fieldA
5070if fieldA == nil then
5071 fieldA = '默认值'
5072end
5073_module_0["fieldA"] = fieldA
5074return _module_0
5075local _module_0 = setmetatable({ }, { })
5076_module_0.itemA = tb
5077getmetatable(_module_0).__index = items
5078_module_0["a-b-c"] = 123
5079return _module_0
5080local _module_0 = { }
5081local d, e, f = 3, 2, 1
5082_module_0[#_module_0 + 1] = d
5083_module_0[#_module_0 + 1] = e
5084_module_0[#_module_0 + 1] = f
5085if this then
5086 _module_0[#_module_0 + 1] = 123
5087else
5088 _module_0[#_module_0 + 1] = 456
5089end
5090local _with_0 = tmp
5091local j = 2000
5092_module_0[#_module_0 + 1] = _with_0
5093return _module_0
5094local _module_0 = nil
5095_module_0 = function()
5096 print("你好")
5097 return 123
5098end
5099return _module_0
5100do
5101 local insert, concat = table.insert, table.concat
5102 local C, Ct, Cmt
5103 do
5104 local _obj_0 = require("lpeg")
5105 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
5106 end
5107 local x, y, z
5108 do
5109 local _obj_0 = require('mymodule')
5110 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z
5111 end
5112 local a, b, c
5113 local _obj_0 = require('module')
5114 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
5115end
5116do
5117 local module = require('module')
5118 local module_x = require('module_x')
5119 local d_a_s_h_e_s = require("d-a-s-h-e-s")
5120 local part = require("module.part")
5121end
5122do
5123 local PlayerModule = require("player")
5124 local C, Ct, Cmt
5125 do
5126 local _obj_0 = require("lpeg")
5127 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
5128 end
5129 local one, two, ch
5130 local _obj_0 = require("export")
5131 one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1]
5132end
5133do
5134 local tostring <const> = tostring
5135 local concat <const> = table.concat
5136 print(concat({
5137 "a",
5138 tostring(1)
5139 }))
5140end
5141do
5142 local print <const> = print
5143 local math <const> = math
5144 print("hello")
5145 math.random(3)
5146end
5147do
5148 local print <const> = print
5149 print(FLAG)
5150 FLAG = 123
5151end
5152local _module_0 = { }
5153local a, b, c = 1, 2, 3
5154_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c
5155local cool = "cat"
5156_module_0["cool"] = cool
5157local What
5158if this then
5159 What = "abc"
5160else
5161 What = "def"
5162end
5163_module_0["What"] = What
5164local y
5165y = function()
5166 local hallo = 3434
5167end
5168_module_0["y"] = y
5169local Something
5170local _class_0
5171local _base_0 = {
5172 umm = "cool"
5173}
5174if _base_0.__index == nil then
5175 _base_0.__index = _base_0
5176end
5177_class_0 = setmetatable({
5178 __init = function() end,
5179 __base = _base_0,
5180 __name = "Something"
5181}, {
5182 __index = _base_0,
5183 __call = function(cls, ...)
5184 local _self_0 = setmetatable({ }, _base_0)
5185 cls.__init(_self_0, ...)
5186 return _self_0
5187 end
5188})
5189_base_0.__class = _class_0
5190Something = _class_0
5191_module_0["Something"] = Something
5192return _module_0
5193local _module_0 = { }
5194local loadstring, tolua
5195do
5196 local _obj_0 = yue
5197 loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua
5198end
5199_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua
5200local fieldA = tb.itemA.fieldA
5201if fieldA == nil then
5202 fieldA = '默认值'
5203end
5204_module_0["fieldA"] = fieldA
5205return _module_0
5206local _module_0 = setmetatable({ }, { })
5207_module_0.itemA = tb
5208getmetatable(_module_0).__index = items
5209_module_0["a-b-c"] = 123
5210return _module_0
5211local _module_0 = { }
5212local d, e, f = 3, 2, 1
5213_module_0[#_module_0 + 1] = d
5214_module_0[#_module_0 + 1] = e
5215_module_0[#_module_0 + 1] = f
5216if this then
5217 _module_0[#_module_0 + 1] = 123
5218else
5219 _module_0[#_module_0 + 1] = 456
5220end
5221local _with_0 = tmp
5222local j = 2000
5223_module_0[#_module_0 + 1] = _with_0
5224return _module_0
5225local _module_0 = nil
5226_module_0 = function()
5227 print("你好")
5228 return 123
5229end
5230return _module_0