diff options
author | Li Jin <dragon-fly@qq.com> | 2024-05-23 16:30:05 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2024-05-23 16:30:05 +0800 |
commit | 1890294226034d27165af016c8c93a484d978b49 (patch) | |
tree | 97f7f698aef1998ceb037080bd9f46b6f894e441 /spec/outputs/compile_doc.lua | |
parent | 06bf167924d04aaefe80d6e4ead40989a447ea34 (diff) | |
download | yuescript-1890294226034d27165af016c8c93a484d978b49.tar.gz yuescript-1890294226034d27165af016c8c93a484d978b49.tar.bz2 yuescript-1890294226034d27165af016c8c93a484d978b49.zip |
prevent more anonymous functions generating from `const`, `close` decl.
Diffstat (limited to 'spec/outputs/compile_doc.lua')
-rw-r--r-- | spec/outputs/compile_doc.lua | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/spec/outputs/compile_doc.lua b/spec/outputs/compile_doc.lua index 29f4aeb..3781fb9 100644 --- a/spec/outputs/compile_doc.lua +++ b/spec/outputs/compile_doc.lua | |||
@@ -12,42 +12,42 @@ local _list_0 = { | |||
12 | for _index_0 = 1, #_list_0 do | 12 | for _index_0 = 1, #_list_0 do |
13 | local _des_0 = _list_0[_index_0] | 13 | local _des_0 = _list_0[_index_0] |
14 | local compiledFile, docFile = _des_0[1], _des_0[2] | 14 | local compiledFile, docFile = _des_0[1], _des_0[2] |
15 | local input <close> = (function() | 15 | local input |
16 | local _with_0 = io.open(docFile) | 16 | local _with_0 = io.open(docFile) |
17 | if _with_0 ~= nil then | 17 | if _with_0 ~= nil then |
18 | local to_lua = require("yue").to_lua | 18 | local to_lua = require("yue").to_lua |
19 | local text = _with_0:read("*a") | 19 | local text = _with_0:read("*a") |
20 | local codes = { } | 20 | local codes = { } |
21 | for code in text:gmatch("```moonscript(.-)```") do | 21 | for code in text:gmatch("```moonscript(.-)```") do |
22 | local result, err = to_lua(code, { | 22 | local result, err = to_lua(code, { |
23 | implicit_return_root = false, | 23 | implicit_return_root = false, |
24 | reserve_line_number = false | 24 | reserve_line_number = false |
25 | }) | 25 | }) |
26 | if result then | 26 | if result then |
27 | codes[#codes + 1] = result | 27 | codes[#codes + 1] = result |
28 | elseif not err:match("macro exporting module only accepts macro definition") then | 28 | elseif not err:match("macro exporting module only accepts macro definition") then |
29 | print(err) | 29 | print(err) |
30 | os.exit(1) | 30 | os.exit(1) |
31 | end | ||
32 | end | 31 | end |
33 | for code in text:gmatch("<pre>(.-)</pre>") do | 32 | end |
34 | local result, err = to_lua(code:gsub("<", "<"):gsub(">", ">"), { | 33 | for code in text:gmatch("<pre>(.-)</pre>") do |
35 | implicit_return_root = false, | 34 | local result, err = to_lua(code:gsub("<", "<"):gsub(">", ">"), { |
36 | reserve_line_number = false | 35 | implicit_return_root = false, |
37 | }) | 36 | reserve_line_number = false |
38 | if result then | 37 | }) |
39 | codes[#codes + 1] = result | 38 | if result then |
40 | else | 39 | codes[#codes + 1] = result |
41 | print(err) | 40 | else |
42 | os.exit(1) | 41 | print(err) |
43 | end | 42 | os.exit(1) |
44 | end | 43 | end |
45 | local output <close> = (function() | ||
46 | local _with_1 = io.open(tostring(outputFolder) .. "/" .. tostring(compiledFile), "w+") | ||
47 | _with_1:write(table.concat(codes)) | ||
48 | return _with_1 | ||
49 | end)() | ||
50 | end | 44 | end |
51 | return _with_0 | 45 | local output |
52 | end)() | 46 | local _with_1 = io.open(tostring(outputFolder) .. "/" .. tostring(compiledFile), "w+") |
47 | _with_1:write(table.concat(codes)) | ||
48 | output = _with_1 | ||
49 | local _close_0 <close> = output | ||
50 | end | ||
51 | input = _with_0 | ||
52 | local _close_0 <close> = input | ||
53 | end | 53 | end |