aboutsummaryrefslogtreecommitdiff
path: root/doc/docs/zh
diff options
context:
space:
mode:
Diffstat (limited to 'doc/docs/zh')
-rw-r--r--doc/docs/zh/doc/advanced/do.md3
-rw-r--r--doc/docs/zh/doc/advanced/line-decorators.md3
-rw-r--r--doc/docs/zh/doc/advanced/macro.md7
-rw-r--r--doc/docs/zh/doc/advanced/module.md8
-rw-r--r--doc/docs/zh/doc/advanced/try.md2
-rw-r--r--doc/docs/zh/doc/assignment/assignment.md5
-rw-r--r--doc/docs/zh/doc/assignment/destructuring-assignment.md12
-rw-r--r--doc/docs/zh/doc/assignment/if-assignment.md4
-rw-r--r--doc/docs/zh/doc/assignment/the-using-clause-controlling-destructive-assignment.md3
-rw-r--r--doc/docs/zh/doc/assignment/varargs-assignment.md1
-rw-r--r--doc/docs/zh/doc/control-flow/conditionals.md8
-rw-r--r--doc/docs/zh/doc/control-flow/continue.md2
-rw-r--r--doc/docs/zh/doc/control-flow/for-loop.md6
-rw-r--r--doc/docs/zh/doc/control-flow/switch.md11
-rw-r--r--doc/docs/zh/doc/control-flow/while-loop.md3
-rw-r--r--doc/docs/zh/doc/data-structures/comprehensions.md17
-rw-r--r--doc/docs/zh/doc/data-structures/table-literals.md9
-rw-r--r--doc/docs/zh/doc/functions/backcalls.md4
-rw-r--r--doc/docs/zh/doc/functions/function-literals.md23
-rw-r--r--doc/docs/zh/doc/functions/function-stubs.md1
-rw-r--r--doc/docs/zh/doc/getting-started/introduction.md2
-rw-r--r--doc/docs/zh/doc/getting-started/usage.md88
-rw-r--r--doc/docs/zh/doc/language-basics/attributes.md3
-rw-r--r--doc/docs/zh/doc/language-basics/comment.md1
-rw-r--r--doc/docs/zh/doc/language-basics/literals.md6
-rw-r--r--doc/docs/zh/doc/language-basics/operator.md15
-rw-r--r--doc/docs/zh/doc/language-basics/whitespace.md2
-rw-r--r--doc/docs/zh/doc/objects/object-oriented-programming.md27
-rw-r--r--doc/docs/zh/doc/objects/with-statement.md7
-rw-r--r--doc/docs/zh/doc/reference/license-mit.md2
-rw-r--r--doc/docs/zh/doc/reference/the-yuescript-library.md303
-rwxr-xr-xdoc/docs/zh/try/index.md1
32 files changed, 404 insertions, 185 deletions
diff --git a/doc/docs/zh/doc/advanced/do.md b/doc/docs/zh/doc/advanced/do.md
index 52dca26..a2d5d19 100644
--- a/doc/docs/zh/doc/advanced/do.md
+++ b/doc/docs/zh/doc/advanced/do.md
@@ -8,6 +8,7 @@ do
8 print var 8 print var
9print var -- 这里是nil 9print var -- 这里是nil
10``` 10```
11
11<YueDisplay> 12<YueDisplay>
12 13
13```yue 14```yue
@@ -31,6 +32,7 @@ counter = do
31print counter! 32print counter!
32print counter! 33print counter!
33``` 34```
35
34<YueDisplay> 36<YueDisplay>
35 37
36```yue 38```yue
@@ -53,6 +55,7 @@ tbl = {
53 1234 55 1234
54} 56}
55``` 57```
58
56<YueDisplay> 59<YueDisplay>
57 60
58```yue 61```yue
diff --git a/doc/docs/zh/doc/advanced/line-decorators.md b/doc/docs/zh/doc/advanced/line-decorators.md
index 86a1bd9..853e396 100644
--- a/doc/docs/zh/doc/advanced/line-decorators.md
+++ b/doc/docs/zh/doc/advanced/line-decorators.md
@@ -5,6 +5,7 @@
5```yuescript 5```yuescript
6print "你好,世界" if name == "Rob" 6print "你好,世界" if name == "Rob"
7``` 7```
8
8<YueDisplay> 9<YueDisplay>
9 10
10```yue 11```yue
@@ -18,6 +19,7 @@ print "你好,世界" if name == "Rob"
18```yuescript 19```yuescript
19print "项目: ", item for item in *items 20print "项目: ", item for item in *items
20``` 21```
22
21<YueDisplay> 23<YueDisplay>
22 24
23```yue 25```yue
@@ -33,6 +35,7 @@ game\update! while game\isRunning!
33 35
34reader\parse_line! until reader\eof! 36reader\parse_line! until reader\eof!
35``` 37```
38
36<YueDisplay> 39<YueDisplay>
37 40
38```yue 41```yue
diff --git a/doc/docs/zh/doc/advanced/macro.md b/doc/docs/zh/doc/advanced/macro.md
index 91be42c..64cfa6d 100644
--- a/doc/docs/zh/doc/advanced/macro.md
+++ b/doc/docs/zh/doc/advanced/macro.md
@@ -32,6 +32,7 @@ macro and = (...) -> "#{ table.concat {...}, ' and ' }"
32if $and f1!, f2!, f3! 32if $and f1!, f2!, f3!
33 print "OK" 33 print "OK"
34``` 34```
35
35<YueDisplay> 36<YueDisplay>
36 37
37```yue 38```yue
@@ -94,6 +95,7 @@ if cond then
94end 95end
95]==] 96]==]
96``` 97```
98
97<YueDisplay> 99<YueDisplay>
98 100
99```yue 101```yue
@@ -142,6 +144,7 @@ import "utils" as {
142} 144}
143[1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _ 145[1, 2, 3] |> $map(_ * 2) |> $filter(_ > 4) |> $each print _
144``` 146```
147
145<YueDisplay> 148<YueDisplay>
146 149
147```yue 150```yue
@@ -172,6 +175,7 @@ import "utils" as {
172print $FILE -- 获取当前模块名称的字符串 175print $FILE -- 获取当前模块名称的字符串
173print $LINE -- 获取当前代码行数:2 176print $LINE -- 获取当前代码行数:2
174``` 177```
178
175<YueDisplay> 179<YueDisplay>
176 180
177```yue 181```yue
@@ -202,6 +206,7 @@ macro BodyType = $Enum(
202print "有效的枚举类型:", $BodyType Static 206print "有效的枚举类型:", $BodyType Static
203-- print "编译报错的枚举类型:", $BodyType Unknown 207-- print "编译报错的枚举类型:", $BodyType Unknown
204``` 208```
209
205<YueDisplay> 210<YueDisplay>
206 211
207```yue 212```yue
@@ -237,6 +242,7 @@ macro printNumAndStr = (num `Num, str `String) -> |
237 242
238$printNumAndStr 123, "hello" 243$printNumAndStr 123, "hello"
239``` 244```
245
240<YueDisplay> 246<YueDisplay>
241 247
242```yue 248```yue
@@ -261,6 +267,7 @@ macro printNumAndStr = (num, str) ->
261 267
262$printNumAndStr 123, "hello" 268$printNumAndStr 123, "hello"
263``` 269```
270
264<YueDisplay> 271<YueDisplay>
265 272
266```yue 273```yue
diff --git a/doc/docs/zh/doc/advanced/module.md b/doc/docs/zh/doc/advanced/module.md
index bae6618..6c90f0e 100644
--- a/doc/docs/zh/doc/advanced/module.md
+++ b/doc/docs/zh/doc/advanced/module.md
@@ -28,6 +28,7 @@ do
28 import "lpeg" as :C, :Ct, :Cmt 28 import "lpeg" as :C, :Ct, :Cmt
29 import "export" as {one, two, Something:{umm:{ch}}} 29 import "export" as {one, two, Something:{umm:{ch}}}
30``` 30```
31
31<YueDisplay> 32<YueDisplay>
32 33
33```yue 34```yue
@@ -67,6 +68,7 @@ do
67 import table.concat 68 import table.concat
68 print concat ["a", tostring 1] 69 print concat ["a", tostring 1]
69``` 70```
71
70<YueDisplay> 72<YueDisplay>
71 73
72```yue 74```yue
@@ -98,6 +100,7 @@ do
98 print FLAG 100 print FLAG
99 FLAG = 123 101 FLAG = 123
100``` 102```
103
101<YueDisplay> 104<YueDisplay>
102 105
103```yue 106```yue
@@ -140,6 +143,7 @@ export y = ->
140export class Something 143export class Something
141 umm: "cool" 144 umm: "cool"
142``` 145```
146
143<YueDisplay> 147<YueDisplay>
144 148
145```yue 149```yue
@@ -166,6 +170,7 @@ export class Something
166export :loadstring, to_lua: tolua = yue 170export :loadstring, to_lua: tolua = yue
167export {itemA: {:fieldA = '默认值'}} = tb 171export {itemA: {:fieldA = '默认值'}} = tb
168``` 172```
173
169<YueDisplay> 174<YueDisplay>
170 175
171```yue 176```yue
@@ -182,6 +187,7 @@ export.itemA = tb
182export.<index> = items 187export.<index> = items
183export["a-b-c"] = 123 188export["a-b-c"] = 123
184``` 189```
190
185<YueDisplay> 191<YueDisplay>
186 192
187```yue 193```yue
@@ -208,6 +214,7 @@ else
208export with tmp 214export with tmp
209 j = 2000 215 j = 2000
210``` 216```
217
211<YueDisplay> 218<YueDisplay>
212 219
213```yue 220```yue
@@ -234,6 +241,7 @@ export default ->
234 print "你好" 241 print "你好"
235 123 242 123
236``` 243```
244
237<YueDisplay> 245<YueDisplay>
238 246
239```yue 247```yue
diff --git a/doc/docs/zh/doc/advanced/try.md b/doc/docs/zh/doc/advanced/try.md
index b4de24d..ef90831 100644
--- a/doc/docs/zh/doc/advanced/try.md
+++ b/doc/docs/zh/doc/advanced/try.md
@@ -29,6 +29,7 @@ catch err
29 print yue.traceback err 29 print yue.traceback err
30 print result 30 print result
31``` 31```
32
32<YueDisplay> 33<YueDisplay>
33 34
34```yue 35```yue
@@ -82,6 +83,7 @@ catch e
82 print e 83 print e
83 e 84 e
84``` 85```
86
85<YueDisplay> 87<YueDisplay>
86 88
87```yue 89```yue
diff --git a/doc/docs/zh/doc/assignment/assignment.md b/doc/docs/zh/doc/assignment/assignment.md
index 49561fb..7245e18 100644
--- a/doc/docs/zh/doc/assignment/assignment.md
+++ b/doc/docs/zh/doc/assignment/assignment.md
@@ -7,6 +7,7 @@ hello = "world"
7a, b, c = 1, 2, 3 7a, b, c = 1, 2, 3
8hello = 123 -- 访问现有的变量 8hello = 123 -- 访问现有的变量
9``` 9```
10
10<YueDisplay> 11<YueDisplay>
11 12
12```yue 13```yue
@@ -31,6 +32,7 @@ x %= 10
31s ..= "world" -- 如果执行更新的局部变量不存在,将新建一个局部变量 32s ..= "world" -- 如果执行更新的局部变量不存在,将新建一个局部变量
32arg or= "默认值" 33arg or= "默认值"
33``` 34```
35
34<YueDisplay> 36<YueDisplay>
35 37
36```yue 38```yue
@@ -54,6 +56,7 @@ arg or= "默认值"
54a = b = c = d = e = 0 56a = b = c = d = e = 0
55x = y = z = f! 57x = y = z = f!
56``` 58```
59
57<YueDisplay> 60<YueDisplay>
58 61
59```yue 62```yue
@@ -81,6 +84,7 @@ do
81 a = 1 84 a = 1
82 B = 2 85 B = 2
83``` 86```
87
84<YueDisplay> 88<YueDisplay>
85 89
86```yue 90```yue
@@ -120,6 +124,7 @@ do
120 B = 2 124 B = 2
121 local Temp = "一个局部值" 125 local Temp = "一个局部值"
122``` 126```
127
123<YueDisplay> 128<YueDisplay>
124 129
125```yue 130```yue
diff --git a/doc/docs/zh/doc/assignment/destructuring-assignment.md b/doc/docs/zh/doc/assignment/destructuring-assignment.md
index 29219d3..469071f 100644
--- a/doc/docs/zh/doc/assignment/destructuring-assignment.md
+++ b/doc/docs/zh/doc/assignment/destructuring-assignment.md
@@ -12,8 +12,8 @@ thing = [1, 2]
12[a, b] = thing 12[a, b] = thing
13print a, b 13print a, b
14``` 14```
15<YueDisplay>
16 15
16<YueDisplay>
17 17
18```yue 18```yue
19thing = [1, 2] 19thing = [1, 2]
@@ -38,6 +38,7 @@ print hello, the_day
38 38
39:day = obj -- 可以不带大括号进行简单的解构 39:day = obj -- 可以不带大括号进行简单的解构
40``` 40```
41
41<YueDisplay> 42<YueDisplay>
42 43
43```yue 44```yue
@@ -69,6 +70,7 @@ obj2 = {
69{numbers: [first, second], properties: {color: color}} = obj2 70{numbers: [first, second], properties: {color: color}} = obj2
70print first, second, color 71print first, second, color
71``` 72```
73
72<YueDisplay> 74<YueDisplay>
73 75
74```yue 76```yue
@@ -96,6 +98,7 @@ print first, second, color
96 } 98 }
97} = obj2 99} = obj2
98``` 100```
101
99<YueDisplay> 102<YueDisplay>
100 103
101```yue 104```yue
@@ -114,6 +117,7 @@ print first, second, color
114```yuescript 117```yuescript
115{:concat, :insert} = table 118{:concat, :insert} = table
116``` 119```
120
117<YueDisplay> 121<YueDisplay>
118 122
119```yue 123```yue
@@ -127,6 +131,7 @@ print first, second, color
127```yuescript 131```yuescript
128{:mix, :max, random: rand} = math 132{:mix, :max, random: rand} = math
129``` 133```
134
130<YueDisplay> 135<YueDisplay>
131 136
132```yue 137```yue
@@ -140,6 +145,7 @@ print first, second, color
140```yuescript 145```yuescript
141{:name = "nameless", :job = "jobless"} = person 146{:name = "nameless", :job = "jobless"} = person
142``` 147```
148
143<YueDisplay> 149<YueDisplay>
144 150
145```yue 151```yue
@@ -153,6 +159,7 @@ print first, second, color
153```yuescript 159```yuescript
154[_, two, _, four] = items 160[_, two, _, four] = items
155``` 161```
162
156<YueDisplay> 163<YueDisplay>
157 164
158```yue 165```yue
@@ -172,6 +179,7 @@ print first -- 打印: first
172print bulk -- 打印: {"second", "third", "fourth"} 179print bulk -- 打印: {"second", "third", "fourth"}
173print last -- 打印: last 180print last -- 打印: last
174``` 181```
182
175<YueDisplay> 183<YueDisplay>
176 184
177```yue 185```yue
@@ -196,6 +204,7 @@ print last -- 打印: last
196-- 跳过中间的元素,只捕获第一个和最后一个元素 204-- 跳过中间的元素,只捕获第一个和最后一个元素
197[first, ..._, last] = orders 205[first, ..._, last] = orders
198``` 206```
207
199<YueDisplay> 208<YueDisplay>
200 209
201```yue 210```yue
@@ -224,6 +233,7 @@ tuples = [
224for [left, right] in *tuples 233for [left, right] in *tuples
225 print left, right 234 print left, right
226``` 235```
236
227<YueDisplay> 237<YueDisplay>
228 238
229```yue 239```yue
diff --git a/doc/docs/zh/doc/assignment/if-assignment.md b/doc/docs/zh/doc/assignment/if-assignment.md
index e4077e1..915b1d5 100644
--- a/doc/docs/zh/doc/assignment/if-assignment.md
+++ b/doc/docs/zh/doc/assignment/if-assignment.md
@@ -6,6 +6,7 @@
6if user := database.find_user "moon" 6if user := database.find_user "moon"
7 print user.name 7 print user.name
8``` 8```
9
9<YueDisplay> 10<YueDisplay>
10 11
11```yue 12```yue
@@ -23,6 +24,7 @@ elseif world := os.getenv "world"
23else 24else
24 print "什么都没有 :(" 25 print "什么都没有 :("
25``` 26```
27
26<YueDisplay> 28<YueDisplay>
27 29
28```yue 30```yue
@@ -43,6 +45,7 @@ if success, result := pcall -> "无报错地获取结果"
43 print result -- 变量 result 是有作用域的 45 print result -- 变量 result 是有作用域的
44print "好的" 46print "好的"
45``` 47```
48
46<YueDisplay> 49<YueDisplay>
47 50
48```yue 51```yue
@@ -62,6 +65,7 @@ while byte := stream\read_one!
62 -- 对 byte 做一些操作 65 -- 对 byte 做一些操作
63 print byte 66 print byte
64``` 67```
68
65<YueDisplay> 69<YueDisplay>
66 70
67```yue 71```yue
diff --git a/doc/docs/zh/doc/assignment/the-using-clause-controlling-destructive-assignment.md b/doc/docs/zh/doc/assignment/the-using-clause-controlling-destructive-assignment.md
index 722de6f..8a9acf4 100644
--- a/doc/docs/zh/doc/assignment/the-using-clause-controlling-destructive-assignment.md
+++ b/doc/docs/zh/doc/assignment/the-using-clause-controlling-destructive-assignment.md
@@ -17,6 +17,7 @@ my_func!
17 17
18print i -- 将打印 0 18print i -- 将打印 0
19``` 19```
20
20<YueDisplay> 21<YueDisplay>
21 22
22```yue 23```yue
@@ -52,6 +53,7 @@ my_func = (using nil) ->
52my_func! 53my_func!
53print i -- 打印 100,i 没有受到影响 54print i -- 打印 100,i 没有受到影响
54``` 55```
56
55<YueDisplay> 57<YueDisplay>
56 58
57```yue 59```yue
@@ -80,6 +82,7 @@ my_func = (add using k, i) ->
80my_func(22) 82my_func(22)
81print i, k -- 这些已经被更新 83print i, k -- 这些已经被更新
82``` 84```
85
83<YueDisplay> 86<YueDisplay>
84 87
85```yue 88```yue
diff --git a/doc/docs/zh/doc/assignment/varargs-assignment.md b/doc/docs/zh/doc/assignment/varargs-assignment.md
index 6cc4278..cc9206e 100644
--- a/doc/docs/zh/doc/assignment/varargs-assignment.md
+++ b/doc/docs/zh/doc/assignment/varargs-assignment.md
@@ -10,6 +10,7 @@ count = select '#', ...
10first = select 1, ... 10first = select 1, ...
11print ok, count, first 11print ok, count, first
12``` 12```
13
13<YueDisplay> 14<YueDisplay>
14 15
15```yue 16```yue
diff --git a/doc/docs/zh/doc/control-flow/conditionals.md b/doc/docs/zh/doc/control-flow/conditionals.md
index ba77f40..3a4d5d1 100644
--- a/doc/docs/zh/doc/control-flow/conditionals.md
+++ b/doc/docs/zh/doc/control-flow/conditionals.md
@@ -7,6 +7,7 @@ if have_coins
7else 7else
8 print "没有硬币" 8 print "没有硬币"
9``` 9```
10
10<YueDisplay> 11<YueDisplay>
11 12
12```yue 13```yue
@@ -25,6 +26,7 @@ else
25have_coins = false 26have_coins = false
26if have_coins then print "有硬币" else print "没有硬币" 27if have_coins then print "有硬币" else print "没有硬币"
27``` 28```
29
28<YueDisplay> 30<YueDisplay>
29 31
30```yue 32```yue
@@ -40,6 +42,7 @@ if have_coins then print "有硬币" else print "没有硬币"
40have_coins = false 42have_coins = false
41print if have_coins then "有硬币" else "没有硬币" 43print if have_coins then "有硬币" else "没有硬币"
42``` 44```
45
43<YueDisplay> 46<YueDisplay>
44 47
45```yue 48```yue
@@ -65,6 +68,7 @@ else
65 68
66print message -- 打印: 我很高 69print message -- 打印: 我很高
67``` 70```
71
68<YueDisplay> 72<YueDisplay>
69 73
70```yue 74```yue
@@ -90,8 +94,8 @@ print message -- 打印: 我很高
90unless os.date("%A") == "Monday" 94unless os.date("%A") == "Monday"
91 print "今天不是星期一!" 95 print "今天不是星期一!"
92``` 96```
93<YueDisplay>
94 97
98<YueDisplay>
95 99
96```yue 100```yue
97unless os.date("%A") == "Monday" 101unless os.date("%A") == "Monday"
@@ -103,6 +107,7 @@ unless os.date("%A") == "Monday"
103```yuescript 107```yuescript
104print "你真幸运!" unless math.random! > 0.1 108print "你真幸运!" unless math.random! > 0.1
105``` 109```
110
106<YueDisplay> 111<YueDisplay>
107 112
108```yue 113```yue
@@ -124,6 +129,7 @@ if a in [1, 3, 5, 7]
124if a in list 129if a in list
125 print "检查`a`是否在列表中" 130 print "检查`a`是否在列表中"
126``` 131```
132
127<YueDisplay> 133<YueDisplay>
128 134
129```yue 135```yue
diff --git a/doc/docs/zh/doc/control-flow/continue.md b/doc/docs/zh/doc/control-flow/continue.md
index 9fab8a3..3b1a093 100644
--- a/doc/docs/zh/doc/control-flow/continue.md
+++ b/doc/docs/zh/doc/control-flow/continue.md
@@ -9,6 +9,7 @@ while i < 10
9 continue if i % 2 == 0 9 continue if i % 2 == 0
10 print i 10 print i
11``` 11```
12
12<YueDisplay> 13<YueDisplay>
13 14
14```yue 15```yue
@@ -29,6 +30,7 @@ odds = for x in *my_numbers
29 continue if x % 2 == 1 30 continue if x % 2 == 1
30 x 31 x
31``` 32```
33
32<YueDisplay> 34<YueDisplay>
33 35
34```yue 36```yue
diff --git a/doc/docs/zh/doc/control-flow/for-loop.md b/doc/docs/zh/doc/control-flow/for-loop.md
index 212ff81..52180b7 100644
--- a/doc/docs/zh/doc/control-flow/for-loop.md
+++ b/doc/docs/zh/doc/control-flow/for-loop.md
@@ -12,6 +12,7 @@ for k = 1, 15, 2 -- 提供了一个遍历的步长
12for key, value in pairs object 12for key, value in pairs object
13 print key, value 13 print key, value
14``` 14```
15
15<YueDisplay> 16<YueDisplay>
16 17
17```yue 18```yue
@@ -33,6 +34,7 @@ for key, value in pairs object
33for item in *items[2, 4] 34for item in *items[2, 4]
34 print item 35 print item
35``` 36```
37
36<YueDisplay> 38<YueDisplay>
37 39
38```yue 40```yue
@@ -49,6 +51,7 @@ for item in *items do print item
49 51
50for j = 1, 10, 3 do print j 52for j = 1, 10, 3 do print j
51``` 53```
54
52<YueDisplay> 55<YueDisplay>
53 56
54```yue 57```yue
@@ -70,6 +73,7 @@ doubled_evens = for i = 1, 20
70 else 73 else
71 i 74 i
72``` 75```
76
73<YueDisplay> 77<YueDisplay>
74 78
75```yue 79```yue
@@ -90,6 +94,7 @@ doubled_evens = for i = 1, 20
90first_large = for n in *numbers 94first_large = for n in *numbers
91 break n if n > 10 95 break n if n > 10
92``` 96```
97
93<YueDisplay> 98<YueDisplay>
94 99
95```yue 100```yue
@@ -110,6 +115,7 @@ func_b = -> return for i = 1, 10 do i
110print func_a! -- 打印 nil 115print func_a! -- 打印 nil
111print func_b! -- 打印 table 对象 116print func_b! -- 打印 table 对象
112``` 117```
118
113<YueDisplay> 119<YueDisplay>
114 120
115```yue 121```yue
diff --git a/doc/docs/zh/doc/control-flow/switch.md b/doc/docs/zh/doc/control-flow/switch.md
index 700bc2a..69ba5b5 100644
--- a/doc/docs/zh/doc/control-flow/switch.md
+++ b/doc/docs/zh/doc/control-flow/switch.md
@@ -11,6 +11,7 @@ switch name := "Dan"
11 else 11 else
12 print "我不认识你,你的名字是#{name}" 12 print "我不认识你,你的名字是#{name}"
13``` 13```
14
14<YueDisplay> 15<YueDisplay>
15 16
16```yue 17```yue
@@ -39,6 +40,7 @@ next_number = switch b
39 else 40 else
40 error "数字数得太大了!" 41 error "数字数得太大了!"
41``` 42```
43
42<YueDisplay> 44<YueDisplay>
43 45
44```yue 46```yue
@@ -62,6 +64,7 @@ msg = switch math.random(1, 5)
62 when 2 then "你差点很幸运" 64 when 2 then "你差点很幸运"
63 else "不太幸运" 65 else "不太幸运"
64``` 66```
67
65<YueDisplay> 68<YueDisplay>
66 69
67```yue 70```yue
@@ -87,6 +90,7 @@ switch math.random(1, 5) when 1
87else 90else
88 print "不太幸运" 91 print "不太幸运"
89``` 92```
93
90<YueDisplay> 94<YueDisplay>
91 95
92```yue 96```yue
@@ -124,6 +128,7 @@ for item in *items
124 when :width, :height 128 when :width, :height
125 print "尺寸 #{width}, #{height}" 129 print "尺寸 #{width}, #{height}"
126``` 130```
131
127<YueDisplay> 132<YueDisplay>
128 133
129```yue 134```yue
@@ -154,6 +159,7 @@ switch item
154 when {pos: {:x = 50, :y = 200}} 159 when {pos: {:x = 50, :y = 200}}
155 print "Vec2 #{x}, #{y}" -- 表格解构仍然会通过 160 print "Vec2 #{x}, #{y}" -- 表格解构仍然会通过
156``` 161```
162
157<YueDisplay> 163<YueDisplay>
158 164
159```yue 165```yue
@@ -181,6 +187,7 @@ switch tb
181 when [1, 2, b = 3] -- 变量b有默认值 187 when [1, 2, b = 3] -- 变量b有默认值
182 print "1, 2, #{b}" 188 print "1, 2, #{b}"
183``` 189```
190
184<YueDisplay> 191<YueDisplay>
185 192
186```yue 193```yue
@@ -206,6 +213,7 @@ switch tb
206 else 213 else
207 print "无效值" 214 print "无效值"
208``` 215```
216
209<YueDisplay> 217<YueDisplay>
210 218
211```yue 219```yue
@@ -231,6 +239,7 @@ switch tb
231 else 239 else
232 print "无效值" 240 print "无效值"
233``` 241```
242
234<YueDisplay> 243<YueDisplay>
235 244
236```yue 245```yue
@@ -257,6 +266,7 @@ switch tb
257 ] 266 ]
258 print "匹配成功", fourth 267 print "匹配成功", fourth
259``` 268```
269
260<YueDisplay> 270<YueDisplay>
261 271
262```yue 272```yue
@@ -282,6 +292,7 @@ switch segments
282 print "Resource:", resource -- 打印: "logs" 292 print "Resource:", resource -- 打印: "logs"
283 print "Action:", action -- 打印: "view" 293 print "Action:", action -- 打印: "view"
284``` 294```
295
285<YueDisplay> 296<YueDisplay>
286 297
287```yue 298```yue
diff --git a/doc/docs/zh/doc/control-flow/while-loop.md b/doc/docs/zh/doc/control-flow/while-loop.md
index 5995890..3c624fe 100644
--- a/doc/docs/zh/doc/control-flow/while-loop.md
+++ b/doc/docs/zh/doc/control-flow/while-loop.md
@@ -10,6 +10,7 @@ while i > 0
10 10
11while running == true do my_function! 11while running == true do my_function!
12``` 12```
13
13<YueDisplay> 14<YueDisplay>
14 15
15```yue 16```yue
@@ -31,6 +32,7 @@ until i == 0
31 32
32until running == false do my_function! 33until running == false do my_function!
33``` 34```
35
34<YueDisplay> 36<YueDisplay>
35 37
36```yue 38```yue
@@ -56,6 +58,7 @@ repeat
56 i -= 1 58 i -= 1
57until i == 0 59until i == 0
58``` 60```
61
59<YueDisplay> 62<YueDisplay>
60 63
61```yue 64```yue
diff --git a/doc/docs/zh/doc/data-structures/comprehensions.md b/doc/docs/zh/doc/data-structures/comprehensions.md
index fd25b22..62f0896 100644
--- a/doc/docs/zh/doc/data-structures/comprehensions.md
+++ b/doc/docs/zh/doc/data-structures/comprehensions.md
@@ -10,6 +10,7 @@
10items = [1, 2, 3, 4] 10items = [1, 2, 3, 4]
11doubled = [item * 2 for i, item in ipairs items] 11doubled = [item * 2 for i, item in ipairs items]
12``` 12```
13
13<YueDisplay> 14<YueDisplay>
14 15
15```yue 16```yue
@@ -24,6 +25,7 @@ doubled = [item * 2 for i, item in ipairs items]
24```yuescript 25```yuescript
25slice = [item for i, item in ipairs items when i > 1 and i < 3] 26slice = [item for i, item in ipairs items when i > 1 and i < 3]
26``` 27```
28
27<YueDisplay> 29<YueDisplay>
28 30
29```yue 31```yue
@@ -37,6 +39,7 @@ slice = [item for i, item in ipairs items when i > 1 and i < 3]
37```yuescript 39```yuescript
38doubled = [item * 2 for item in *items] 40doubled = [item * 2 for item in *items]
39``` 41```
42
40<YueDisplay> 43<YueDisplay>
41 44
42```yue 45```yue
@@ -55,6 +58,7 @@ data =
55flat = [...v for k,v in pairs data] 58flat = [...v for k,v in pairs data]
56-- flat 现在为 [1, 2, 3, 4, 5, 6] 59-- flat 现在为 [1, 2, 3, 4, 5, 6]
57``` 60```
61
58<YueDisplay> 62<YueDisplay>
59 63
60```yue 64```yue
@@ -79,6 +83,7 @@ y_coords = [9, 2, 3]
79points = [ [x, y] for x in *x_coords \ 83points = [ [x, y] for x in *x_coords \
80for y in *y_coords] 84for y in *y_coords]
81``` 85```
86
82<YueDisplay> 87<YueDisplay>
83 88
84```yue 89```yue
@@ -96,6 +101,7 @@ for y in *y_coords]
96```yuescript 101```yuescript
97evens = [i for i = 1, 100 when i % 2 == 0] 102evens = [i for i = 1, 100 when i % 2 == 0]
98``` 103```
104
99<YueDisplay> 105<YueDisplay>
100 106
101```yue 107```yue
@@ -119,6 +125,7 @@ thing = {
119 125
120thing_copy = {k, v for k, v in pairs thing} 126thing_copy = {k, v for k, v in pairs thing}
121``` 127```
128
122<YueDisplay> 129<YueDisplay>
123 130
124```yue 131```yue
@@ -136,6 +143,7 @@ thing_copy = {k, v for k, v in pairs thing}
136```yuescript 143```yuescript
137no_color = {k, v for k, v in pairs thing when k != "color"} 144no_color = {k, v for k, v in pairs thing when k != "color"}
138``` 145```
146
139<YueDisplay> 147<YueDisplay>
140 148
141```yue 149```yue
@@ -150,6 +158,7 @@ no_color = {k, v for k, v in pairs thing when k != "color"}
150numbers = [1, 2, 3, 4] 158numbers = [1, 2, 3, 4]
151sqrts = {i, math.sqrt i for i in *numbers} 159sqrts = {i, math.sqrt i for i in *numbers}
152``` 160```
161
153<YueDisplay> 162<YueDisplay>
154 163
155```yue 164```yue
@@ -167,6 +176,7 @@ sqrts = {i, math.sqrt i for i in *numbers}
167tuples = [ ["hello", "world"], ["foo", "bar"]] 176tuples = [ ["hello", "world"], ["foo", "bar"]]
168tbl = {unpack tuple for tuple in *tuples} 177tbl = {unpack tuple for tuple in *tuples}
169``` 178```
179
170<YueDisplay> 180<YueDisplay>
171 181
172```yue 182```yue
@@ -185,6 +195,7 @@ tbl = {unpack tuple for tuple in *tuples}
185```yuescript 195```yuescript
186slice = [item for item in *items[1, 5]] 196slice = [item for item in *items[1, 5]]
187``` 197```
198
188<YueDisplay> 199<YueDisplay>
189 200
190```yue 201```yue
@@ -198,6 +209,7 @@ slice = [item for item in *items[1, 5]]
198```yuescript 209```yuescript
199slice = [item for item in *items[2,]] 210slice = [item for item in *items[2,]]
200``` 211```
212
201<YueDisplay> 213<YueDisplay>
202 214
203```yue 215```yue
@@ -211,8 +223,8 @@ slice = [item for item in *items[2,]]
211```yuescript 223```yuescript
212slice = [item for item in *items[,,2]] 224slice = [item for item in *items[,,2]]
213``` 225```
214<YueDisplay>
215 226
227<YueDisplay>
216 228
217```yue 229```yue
218slice = [item for item in *items[,,2]] 230slice = [item for item in *items[,,2]]
@@ -226,6 +238,7 @@ slice = [item for item in *items[,,2]]
226-- 取最后4个元素 238-- 取最后4个元素
227slice = [item for item in *items[-4,-1]] 239slice = [item for item in *items[-4,-1]]
228``` 240```
241
229<YueDisplay> 242<YueDisplay>
230 243
231```yue 244```yue
@@ -240,6 +253,7 @@ slice = [item for item in *items[-4,-1]]
240```yuescript 253```yuescript
241reverse_slice = [item for item in *items[-1,1,-1]] 254reverse_slice = [item for item in *items[-1,1,-1]]
242``` 255```
256
243<YueDisplay> 257<YueDisplay>
244 258
245```yue 259```yue
@@ -259,6 +273,7 @@ sub_list = items[2, 4]
259-- 取最后4个元素作为新的列表 273-- 取最后4个元素作为新的列表
260last_four_items = items[-4, -1] 274last_four_items = items[-4, -1]
261``` 275```
276
262<YueDisplay> 277<YueDisplay>
263 278
264```yue 279```yue
diff --git a/doc/docs/zh/doc/data-structures/table-literals.md b/doc/docs/zh/doc/data-structures/table-literals.md
index a111950..a8ff9b8 100644
--- a/doc/docs/zh/doc/data-structures/table-literals.md
+++ b/doc/docs/zh/doc/data-structures/table-literals.md
@@ -5,6 +5,7 @@
5```yuescript 5```yuescript
6some_values = [1, 2, 3, 4] 6some_values = [1, 2, 3, 4]
7``` 7```
8
8<YueDisplay> 9<YueDisplay>
9 10
10```yue 11```yue
@@ -22,6 +23,7 @@ some_values = {
22 ["favorite food"]: "rice" 23 ["favorite food"]: "rice"
23} 24}
24``` 25```
26
25<YueDisplay> 27<YueDisplay>
26 28
27```yue 29```yue
@@ -42,6 +44,7 @@ profile =
42 shoe_size: 13, 44 shoe_size: 13,
43 favorite_foods: ["冰淇淋", "甜甜圈"] 45 favorite_foods: ["冰淇淋", "甜甜圈"]
44``` 46```
47
45<YueDisplay> 48<YueDisplay>
46 49
47```yue 50```yue
@@ -63,6 +66,7 @@ values = {
63 occupation: "打击犯罪" 66 occupation: "打击犯罪"
64} 67}
65``` 68```
69
66<YueDisplay> 70<YueDisplay>
67 71
68```yue 72```yue
@@ -83,6 +87,7 @@ my_function dance: "探戈", partner: "无"
83 87
84y = type: "狗", legs: 4, tails: 1 88y = type: "狗", legs: 4, tails: 1
85``` 89```
90
86<YueDisplay> 91<YueDisplay>
87 92
88```yue 93```yue
@@ -101,6 +106,7 @@ tbl = {
101 end: "饥饿" 106 end: "饥饿"
102} 107}
103``` 108```
109
104<YueDisplay> 110<YueDisplay>
105 111
106```yue 112```yue
@@ -121,6 +127,7 @@ person = { :hair, :height, shoe_size: 40 }
121 127
122print_table :hair, :height 128print_table :hair, :height
123``` 129```
130
124<YueDisplay> 131<YueDisplay>
125 132
126```yue 133```yue
@@ -141,6 +148,7 @@ t = {
141 "你好 世界": true 148 "你好 世界": true
142} 149}
143``` 150```
151
144<YueDisplay> 152<YueDisplay>
145 153
146```yue 154```yue
@@ -158,6 +166,7 @@ t = {
158some_values = [ 1, 2, 3, 4 ] 166some_values = [ 1, 2, 3, 4 ]
159list_with_one_element = [ 1, ] 167list_with_one_element = [ 1, ]
160``` 168```
169
161<YueDisplay> 170<YueDisplay>
162 171
163```yue 172```yue
diff --git a/doc/docs/zh/doc/functions/backcalls.md b/doc/docs/zh/doc/functions/backcalls.md
index 4c32fac..7baac90 100644
--- a/doc/docs/zh/doc/functions/backcalls.md
+++ b/doc/docs/zh/doc/functions/backcalls.md
@@ -6,6 +6,7 @@
6x <- f 6x <- f
7print "hello" .. x 7print "hello" .. x
8``` 8```
9
9<YueDisplay> 10<YueDisplay>
10 11
11```yue 12```yue
@@ -21,6 +22,7 @@ print "hello" .. x
21<= f 22<= f
22print @value 23print @value
23``` 24```
25
24<YueDisplay> 26<YueDisplay>
25 27
26```yue 28```yue
@@ -36,6 +38,7 @@ print @value
36(x) <- map _, [1, 2, 3] 38(x) <- map _, [1, 2, 3]
37x * 2 39x * 2
38``` 40```
41
39<YueDisplay> 42<YueDisplay>
40 43
41```yue 44```yue
@@ -55,6 +58,7 @@ result, msg = do
55 check info 58 check info
56print result, msg 59print result, msg
57``` 60```
61
58<YueDisplay> 62<YueDisplay>
59 63
60```yue 64```yue
diff --git a/doc/docs/zh/doc/functions/function-literals.md b/doc/docs/zh/doc/functions/function-literals.md
index efe920b..163d155 100644
--- a/doc/docs/zh/doc/functions/function-literals.md
+++ b/doc/docs/zh/doc/functions/function-literals.md
@@ -6,6 +6,7 @@
6my_function = -> 6my_function = ->
7my_function() -- 调用空函数 7my_function() -- 调用空函数
8``` 8```
9
9<YueDisplay> 10<YueDisplay>
10 11
11```yue 12```yue
@@ -24,6 +25,7 @@ func_b = ->
24 value = 100 25 value = 100
25 print "这个值是:", value 26 print "这个值是:", value
26``` 27```
28
27<YueDisplay> 29<YueDisplay>
28 30
29```yue 31```yue
@@ -42,6 +44,7 @@ func_b = ->
42func_a! 44func_a!
43func_b() 45func_b()
44``` 46```
47
45<YueDisplay> 48<YueDisplay>
46 49
47```yue 50```yue
@@ -56,6 +59,7 @@ func_b()
56```yuescript 59```yuescript
57sum = (x, y) -> print "数字的和", x + y 60sum = (x, y) -> print "数字的和", x + y
58``` 61```
62
59<YueDisplay> 63<YueDisplay>
60 64
61```yue 65```yue
@@ -72,6 +76,7 @@ print sum 10, 20
72 76
73a b c "a", "b", "c" 77a b c "a", "b", "c"
74``` 78```
79
75<YueDisplay> 80<YueDisplay>
76 81
77```yue 82```yue
@@ -88,6 +93,7 @@ a b c "a", "b", "c"
88```yuescript 93```yuescript
89print "x:", sum(10, 20), "y:", sum(30, 40) 94print "x:", sum(10, 20), "y:", sum(30, 40)
90``` 95```
96
91<YueDisplay> 97<YueDisplay>
92 98
93```yue 99```yue
@@ -104,6 +110,7 @@ print "x:", sum(10, 20), "y:", sum(30, 40)
104sum = (x, y) -> x + y 110sum = (x, y) -> x + y
105print "数字的和是", sum 10, 20 111print "数字的和是", sum 10, 20
106``` 112```
113
107<YueDisplay> 114<YueDisplay>
108 115
109```yue 116```yue
@@ -118,6 +125,7 @@ print "数字的和是", sum 10, 20
118```yuescript 125```yuescript
119sum = (x, y) -> return x + y 126sum = (x, y) -> return x + y
120``` 127```
128
121<YueDisplay> 129<YueDisplay>
122 130
123```yue 131```yue
@@ -132,6 +140,7 @@ sum = (x, y) -> return x + y
132mystery = (x, y) -> x + y, x - y 140mystery = (x, y) -> x + y, x - y
133a, b = mystery 10, 20 141a, b = mystery 10, 20
134``` 142```
143
135<YueDisplay> 144<YueDisplay>
136 145
137```yue 146```yue
@@ -148,6 +157,7 @@ a, b = mystery 10, 20
148```yuescript 157```yuescript
149func = (num) => @value + num 158func = (num) => @value + num
150``` 159```
160
151<YueDisplay> 161<YueDisplay>
152 162
153```yue 163```yue
@@ -165,6 +175,7 @@ my_function = (name = "某物", height = 100) ->
165 print "你好,我是", name 175 print "你好,我是", name
166 print "我的高度是", height 176 print "我的高度是", height
167``` 177```
178
168<YueDisplay> 179<YueDisplay>
169 180
170```yue 181```yue
@@ -181,6 +192,7 @@ my_function = (name = "某物", height = 100) ->
181some_args = (x = 100, y = x + 1000) -> 192some_args = (x = 100, y = x + 1000) ->
182 print x + y 193 print x + y
183``` 194```
195
184<YueDisplay> 196<YueDisplay>
185 197
186```yue 198```yue
@@ -202,6 +214,7 @@ b = x-10
202c = x -y 214c = x -y
203d = x- z 215d = x- z
204``` 216```
217
205<YueDisplay> 218<YueDisplay>
206 219
207```yue 220```yue
@@ -223,6 +236,7 @@ d = x- z
223x = func"hello" + 100 236x = func"hello" + 100
224y = func "hello" + 100 237y = func "hello" + 100
225``` 238```
239
226<YueDisplay> 240<YueDisplay>
227 241
228```yue 242```yue
@@ -247,6 +261,7 @@ cool_func 1, 2,
247 5, 6, 261 5, 6,
248 7, 8 262 7, 8
249``` 263```
264
250<YueDisplay> 265<YueDisplay>
251 266
252```yue 267```yue
@@ -269,6 +284,7 @@ my_func 5, 6, 7,
269 9, 1, 2, 284 9, 1, 2,
270 5, 4 285 5, 4
271``` 286```
287
272<YueDisplay> 288<YueDisplay>
273 289
274```yue 290```yue
@@ -289,6 +305,7 @@ x = [
289 8, 9, 10 305 8, 9, 10
290] 306]
291``` 307```
308
292<YueDisplay> 309<YueDisplay>
293 310
294```yue 311```yue
@@ -309,6 +326,7 @@ y = [ my_func 1, 2, 3,
309 5, 6, 7 326 5, 6, 7
310] 327]
311``` 328```
329
312<YueDisplay> 330<YueDisplay>
313 331
314```yue 332```yue
@@ -335,6 +353,7 @@ if func 1, 2, 3,
335 print "hello" 353 print "hello"
336 print "我在if内部" 354 print "我在if内部"
337``` 355```
356
338<YueDisplay> 357<YueDisplay>
339 358
340```yue 359```yue
@@ -373,6 +392,7 @@ f2 = ({a: a1 = 123, :b = 'abc'}, c = {}) ->
373arg1 = {a: 0} 392arg1 = {a: 0}
374f2 arg1, arg2 393f2 arg1, arg2
375``` 394```
395
376<YueDisplay> 396<YueDisplay>
377 397
378```yue 398```yue
@@ -402,6 +422,7 @@ findFirstEven = (list): nil ->
402 if sub % 2 == 0 422 if sub % 2 == 0
403 return sub 423 return sub
404``` 424```
425
405<YueDisplay> 426<YueDisplay>
406 427
407```yue 428```yue
@@ -426,6 +447,7 @@ findFirstEven = (list) ->
426 return sub 447 return sub
427 nil 448 nil
428``` 449```
450
429<YueDisplay> 451<YueDisplay>
430 452
431```yue 453```yue
@@ -467,6 +489,7 @@ process = (...args) ->
467 489
468process 1, nil, 3, nil, 5 490process 1, nil, 3, nil, 5
469``` 491```
492
470<YueDisplay> 493<YueDisplay>
471 494
472```yue 495```yue
diff --git a/doc/docs/zh/doc/functions/function-stubs.md b/doc/docs/zh/doc/functions/function-stubs.md
index af08feb..888c3eb 100644
--- a/doc/docs/zh/doc/functions/function-stubs.md
+++ b/doc/docs/zh/doc/functions/function-stubs.md
@@ -24,6 +24,7 @@ run_callback my_object.write
24-- 让我们把对象捆绑到一个新函数中 24-- 让我们把对象捆绑到一个新函数中
25run_callback my_object\write 25run_callback my_object\write
26``` 26```
27
27<YueDisplay> 28<YueDisplay>
28 29
29```yue 30```yue
diff --git a/doc/docs/zh/doc/getting-started/introduction.md b/doc/docs/zh/doc/getting-started/introduction.md
index 827d163..7911363 100644
--- a/doc/docs/zh/doc/getting-started/introduction.md
+++ b/doc/docs/zh/doc/getting-started/introduction.md
@@ -5,6 +5,7 @@
5Yue(月)是中文中“月亮”的名称。 5Yue(月)是中文中“月亮”的名称。
6 6
7## 月之脚本概览 7## 月之脚本概览
8
8```yuescript 9```yuescript
9-- 导入语法 10-- 导入语法
10import p, to_lua from "yue" 11import p, to_lua from "yue"
@@ -49,6 +50,7 @@ with apple
49-- 类似js的导出语法 50-- 类似js的导出语法
50export 🌛 = "月之脚本" 51export 🌛 = "月之脚本"
51``` 52```
53
52<YueDisplay> 54<YueDisplay>
53 55
54```yue 56```yue
diff --git a/doc/docs/zh/doc/getting-started/usage.md b/doc/docs/zh/doc/getting-started/usage.md
index b9d84d4..c9bad2e 100644
--- a/doc/docs/zh/doc/getting-started/usage.md
+++ b/doc/docs/zh/doc/getting-started/usage.md
@@ -4,49 +4,51 @@
4 4
5&emsp;&emsp;在 Lua 中使用月之脚本模块: 5&emsp;&emsp;在 Lua 中使用月之脚本模块:
6 6
7* **用法 1** 7- **用法 1**
8 8
9 &emsp;&emsp;在 Lua 中引入 "你的脚本入口文件.yue"。 9 &emsp;&emsp;在 Lua 中引入 "你的脚本入口文件.yue"。
10 10
11 ```Lua 11 ```Lua
12 require("yue")("你的脚本入口文件") 12 require("yue")("你的脚本入口文件")
13 ``` 13 ```
14 14
15 &emsp;&emsp;当你在同一路径下把 "你的脚本入口文件.yue" 编译成了 "你的脚本入口文件.lua" 时,仍然可以使用这个代码加载 .lua 代码文件。在其余的月之脚本文件中,只需正常使用 **require** 或 **import** 进行脚本引用即可。错误消息中的代码行号也会被正确处理。 15 &emsp;&emsp;当你在同一路径下把 "你的脚本入口文件.yue" 编译成了 "你的脚本入口文件.lua" 时,仍然可以使用这个代码加载 .lua 代码文件。在其余的月之脚本文件中,只需正常使用 **require** 或 **import** 进行脚本引用即可。错误消息中的代码行号也会被正确处理。
16 16
17* **用法 2** 17- **用法 2**
18 18
19 &emsp;&emsp;手动引入月之脚本模块并重写错误消息来帮助调试。 19 &emsp;&emsp;手动引入月之脚本模块并重写错误消息来帮助调试。
20 ```lua 20
21 local yue = require("yue") 21 ```lua
22 yue.insert_loaders() 22 local yue = require("yue")
23 local success, result = xpcall(function() 23 yue.insert_loaders()
24 return require("yuescript_module_name") 24 local success, result = xpcall(function()
25 end, function(err) 25 return require("yuescript_module_name")
26 return yue.traceback(err) 26 end, function(err)
27 end) 27 return yue.traceback(err)
28 ``` 28 end)
29 29 ```
30* **用法 3** 30
31 31- **用法 3**
32 &emsp;&emsp;在 Lua 中使用月之脚本编译器功能。 32
33 ```lua 33 &emsp;&emsp;在 Lua 中使用月之脚本编译器功能。
34 local yue = require("yue") 34
35 local codes, err, globals = yue.to_lua([[ 35 ```lua
36 f = -> 36 local yue = require("yue")
37 print "hello world" 37 local codes, err, globals = yue.to_lua([[
38 f! 38 f = ->
39 ]],{ 39 print "hello world"
40 implicit_return_root = true, 40 f!
41 reserve_line_number = true, 41 ]],{
42 lint_global = true, 42 implicit_return_root = true,
43 space_over_tab = false, 43 reserve_line_number = true,
44 options = { 44 lint_global = true,
45 target = "5.4", 45 space_over_tab = false,
46 path = "/script" 46 options = {
47 } 47 target = "5.4",
48 }) 48 path = "/script"
49 ``` 49 }
50 })
51 ```
50 52
51## 月之脚本编译工具 53## 月之脚本编译工具
52 54
diff --git a/doc/docs/zh/doc/language-basics/attributes.md b/doc/docs/zh/doc/language-basics/attributes.md
index 3dc3b0b..43bc5f9 100644
--- a/doc/docs/zh/doc/language-basics/attributes.md
+++ b/doc/docs/zh/doc/language-basics/attributes.md
@@ -6,6 +6,7 @@
6const a = 123 6const a = 123
7close _ = <close>: -> print "超出范围。" 7close _ = <close>: -> print "超出范围。"
8``` 8```
9
9<YueDisplay> 10<YueDisplay>
10 11
11```yue 12```yue
@@ -21,6 +22,7 @@ close _ = <close>: -> print "超出范围。"
21const {:a, :b, c, d} = tb 22const {:a, :b, c, d} = tb
22-- a = 1 23-- a = 1
23``` 24```
25
24<YueDisplay> 26<YueDisplay>
25 27
26```yue 28```yue
@@ -36,6 +38,7 @@ const {:a, :b, c, d} = tb
36global const Constant = 123 38global const Constant = 123
37-- Constant = 1 39-- Constant = 1
38``` 40```
41
39<YueDisplay> 42<YueDisplay>
40 43
41```yue 44```yue
diff --git a/doc/docs/zh/doc/language-basics/comment.md b/doc/docs/zh/doc/language-basics/comment.md
index f6a7b4e..0e69979 100644
--- a/doc/docs/zh/doc/language-basics/comment.md
+++ b/doc/docs/zh/doc/language-basics/comment.md
@@ -12,6 +12,7 @@ str = --[[
12 12
13func --[[端口]] 3000, --[[ip]] "192.168.1.1" 13func --[[端口]] 3000, --[[ip]] "192.168.1.1"
14``` 14```
15
15<YueDisplay> 16<YueDisplay>
16 17
17```yue 18```yue
diff --git a/doc/docs/zh/doc/language-basics/literals.md b/doc/docs/zh/doc/language-basics/literals.md
index 1592bae..0837c71 100644
--- a/doc/docs/zh/doc/language-basics/literals.md
+++ b/doc/docs/zh/doc/language-basics/literals.md
@@ -12,6 +12,7 @@ some_string = "这是一个字符串
12-- 字符串插值只在双引号字符串中可用。 12-- 字符串插值只在双引号字符串中可用。
13print "我有#{math.random! * 100}%的把握。" 13print "我有#{math.random! * 100}%的把握。"
14``` 14```
15
15<YueDisplay> 16<YueDisplay>
16 17
17```yue 18```yue
@@ -34,8 +35,8 @@ integer = 1_000_000
34hex = 0xEF_BB_BF 35hex = 0xEF_BB_BF
35binary = 0B10011 36binary = 0B10011
36``` 37```
37<YueDisplay>
38 38
39<YueDisplay>
39 40
40```yue 41```yue
41integer = 1_000_000 42integer = 1_000_000
@@ -56,6 +57,7 @@ str = |
56 - item1 57 - item1
57 - #{expr} 58 - #{expr}
58``` 59```
60
59<YueDisplay> 61<YueDisplay>
60 62
61```yue 63```yue
@@ -79,6 +81,7 @@ fn = ->
79 bar: baz 81 bar: baz
80 return str 82 return str
81``` 83```
84
82<YueDisplay> 85<YueDisplay>
83 86
84```yue 87```yue
@@ -100,6 +103,7 @@ str = |
100 path: "C:\Program Files\App" 103 path: "C:\Program Files\App"
101 note: 'He said: "#{Hello}!"' 104 note: 'He said: "#{Hello}!"'
102``` 105```
106
103<YueDisplay> 107<YueDisplay>
104 108
105```yue 109```yue
diff --git a/doc/docs/zh/doc/language-basics/operator.md b/doc/docs/zh/doc/language-basics/operator.md
index 6c9fc5b..d948667 100644
--- a/doc/docs/zh/doc/language-basics/operator.md
+++ b/doc/docs/zh/doc/language-basics/operator.md
@@ -6,6 +6,7 @@
6tb\func! if tb ~= nil 6tb\func! if tb ~= nil
7tb::func! if tb != nil 7tb::func! if tb != nil
8``` 8```
9
9<YueDisplay> 10<YueDisplay>
10 11
11```yue 12```yue
@@ -27,6 +28,7 @@ a = 5
27print 1 <= a <= 10 28print 1 <= a <= 10
28-- 输出:true 29-- 输出:true
29``` 30```
31
30<YueDisplay> 32<YueDisplay>
31 33
32```yue 34```yue
@@ -64,6 +66,7 @@ print v(1) > v(2) <= v(3)
64 false 66 false
65]] 67]]
66``` 68```
69
67<YueDisplay> 70<YueDisplay>
68 71
69```yue 72```yue
@@ -101,6 +104,7 @@ print v(1) > v(2) <= v(3)
101tab = [] 104tab = []
102tab[] = "Value" 105tab[] = "Value"
103``` 106```
107
104<YueDisplay> 108<YueDisplay>
105 109
106```yue 110```yue
@@ -118,6 +122,7 @@ tbB = [4, 5, 6]
118tbA[] = ...tbB 122tbA[] = ...tbB
119-- tbA 现在为 [1, 2, 3, 4, 5, 6] 123-- tbA 现在为 [1, 2, 3, 4, 5, 6]
120``` 124```
125
121<YueDisplay> 126<YueDisplay>
122 127
123```yue 128```yue
@@ -149,6 +154,7 @@ a = {1, 2, 3, x: 1}
149b = {4, 5, y: 1} 154b = {4, 5, y: 1}
150merge = {...a, ...b} 155merge = {...a, ...b}
151``` 156```
157
152<YueDisplay> 158<YueDisplay>
153 159
154```yue 160```yue
@@ -179,6 +185,7 @@ last = data.items[#]
179second_last = data.items[#-1] 185second_last = data.items[#-1]
180data.items[#] = 1 186data.items[#] = 1
181``` 187```
188
182<YueDisplay> 189<YueDisplay>
183 190
184```yue 191```yue
@@ -212,6 +219,7 @@ print d.value
212 219
213close _ = <close>: -> print "超出范围" 220close _ = <close>: -> print "超出范围"
214``` 221```
222
215<YueDisplay> 223<YueDisplay>
216 224
217```yue 225```yue
@@ -245,8 +253,8 @@ print tb.value
245tb.<> = __index: {item: "hello"} 253tb.<> = __index: {item: "hello"}
246print tb.item 254print tb.item
247``` 255```
248<YueDisplay>
249 256
257<YueDisplay>
250 258
251```yue 259```yue
252-- 使用包含字段 "value" 的元表创建 260-- 使用包含字段 "value" 的元表创建
@@ -267,6 +275,7 @@ print tb.item
267{item, :new, :<close>, <index>: getter} = tb 275{item, :new, :<close>, <index>: getter} = tb
268print item, new, close, getter 276print item, new, close, getter
269``` 277```
278
270<YueDisplay> 279<YueDisplay>
271 280
272```yue 281```yue
@@ -294,6 +303,7 @@ with? io.open "test.txt", "w"
294 \write "你好" 303 \write "你好"
295 \close! 304 \close!
296``` 305```
306
297<YueDisplay> 307<YueDisplay>
298 308
299```yue 309```yue
@@ -330,6 +340,7 @@ readFile "example.txt"
330 |> render 340 |> render
331 |> print 341 |> print
332``` 342```
343
333<YueDisplay> 344<YueDisplay>
334 345
335```yue 346```yue
@@ -358,6 +369,7 @@ func a ?? {}
358 369
359a ??= false 370a ??= false
360``` 371```
372
361<YueDisplay> 373<YueDisplay>
362 374
363```yue 375```yue
@@ -414,6 +426,7 @@ tb =
414 func: => @value + 2 426 func: => @value + 2
415 tb: { } 427 tb: { }
416``` 428```
429
417<YueDisplay> 430<YueDisplay>
418 431
419```yue 432```yue
diff --git a/doc/docs/zh/doc/language-basics/whitespace.md b/doc/docs/zh/doc/language-basics/whitespace.md
index 1886e23..e27165f 100644
--- a/doc/docs/zh/doc/language-basics/whitespace.md
+++ b/doc/docs/zh/doc/language-basics/whitespace.md
@@ -9,6 +9,7 @@
9```yuescript 9```yuescript
10a = 1; b = 2; print a + b 10a = 1; b = 2; print a + b
11``` 11```
12
12<YueDisplay> 13<YueDisplay>
13 14
14```yue 15```yue
@@ -29,6 +30,7 @@ Rx.Observable
29 \map (value) -> value .. '!' 30 \map (value) -> value .. '!'
30 \subscribe print 31 \subscribe print
31``` 32```
33
32<YueDisplay> 34<YueDisplay>
33 35
34```yue 36```yue
diff --git a/doc/docs/zh/doc/objects/object-oriented-programming.md b/doc/docs/zh/doc/objects/object-oriented-programming.md
index 9eb94d8..04f816a 100644
--- a/doc/docs/zh/doc/objects/object-oriented-programming.md
+++ b/doc/docs/zh/doc/objects/object-oriented-programming.md
@@ -15,6 +15,7 @@ class Inventory
15 else 15 else
16 @items[name] = 1 16 @items[name] = 1
17``` 17```
18
18<YueDisplay> 19<YueDisplay>
19 20
20```yue 21```yue
@@ -44,8 +45,8 @@ inv = Inventory!
44inv\add_item "t-shirt" 45inv\add_item "t-shirt"
45inv\add_item "pants" 46inv\add_item "pants"
46``` 47```
47<YueDisplay>
48 48
49<YueDisplay>
49 50
50```yue 51```yue
51inv = Inventory! 52inv = Inventory!
@@ -76,6 +77,7 @@ b\give_item "shirt"
76-- 会同时打印出裤子和衬衫 77-- 会同时打印出裤子和衬衫
77print item for item in *a.clothes 78print item for item in *a.clothes
78``` 79```
80
79<YueDisplay> 81<YueDisplay>
80 82
81```yue 83```yue
@@ -103,6 +105,7 @@ class Person
103 new: => 105 new: =>
104 @clothes = [] 106 @clothes = []
105``` 107```
108
106<YueDisplay> 109<YueDisplay>
107 110
108```yue 111```yue
@@ -124,6 +127,7 @@ class BackPack extends Inventory
124 if #@items > size then error "背包已满" 127 if #@items > size then error "背包已满"
125 super name 128 super name
126``` 129```
130
127<YueDisplay> 131<YueDisplay>
128 132
129```yue 133```yue
@@ -150,6 +154,7 @@ class Shelf
150-- 将打印: Shelf 被 Cupboard 继承 154-- 将打印: Shelf 被 Cupboard 继承
151class Cupboard extends Shelf 155class Cupboard extends Shelf
152``` 156```
157
153<YueDisplay> 158<YueDisplay>
154 159
155```yue 160```yue
@@ -186,6 +191,7 @@ class MyClass extends ParentClass
186 -- super 作为值等于父类: 191 -- super 作为值等于父类:
187 assert super == ParentClass 192 assert super == ParentClass
188``` 193```
194
189<YueDisplay> 195<YueDisplay>
190 196
191```yue 197```yue
@@ -214,6 +220,7 @@ assert b.__class == BackPack
214 220
215print BackPack.size -- 打印 10 221print BackPack.size -- 打印 10
216``` 222```
223
217<YueDisplay> 224<YueDisplay>
218 225
219```yue 226```yue
@@ -235,13 +242,14 @@ print BackPack.size -- 打印 10
235 242
236&emsp;&emsp;如果在类对象的元表中找不到某个属性,系统会从基表中检索该属性。这就意味着我们可以直接从类本身访问到其方法和属性。 243&emsp;&emsp;如果在类对象的元表中找不到某个属性,系统会从基表中检索该属性。这就意味着我们可以直接从类本身访问到其方法和属性。
237 244
238&emsp;&emsp;需要特别注意的是,对类对象的赋值并不会影响到基表,因此这不是向实例添加新方法的正确方式。相反,需要直接修改基表。关于这点,可以参考下面的 “__base” 字段。 245&emsp;&emsp;需要特别注意的是,对类对象的赋值并不会影响到基表,因此这不是向实例添加新方法的正确方式。相反,需要直接修改基表。关于这点,可以参考下面的 “\_\_base” 字段。
239 246
240&emsp;&emsp;此外,类对象包含几个特殊的属性:当类被声明时,类的名称会作为一个字符串存储在类对象的 “__name” 字段中。 247&emsp;&emsp;此外,类对象包含几个特殊的属性:当类被声明时,类的名称会作为一个字符串存储在类对象的 “\_\_name” 字段中。
241 248
242```yuescript 249```yuescript
243print BackPack.__name -- 打印 Backpack 250print BackPack.__name -- 打印 Backpack
244``` 251```
252
245<YueDisplay> 253<YueDisplay>
246 254
247```yue 255```yue
@@ -267,6 +275,7 @@ Things\some_func!
267-- 类变量在实例中不可见 275-- 类变量在实例中不可见
268assert Things().some_func == nil 276assert Things().some_func == nil
269``` 277```
278
270<YueDisplay> 279<YueDisplay>
271 280
272```yue 281```yue
@@ -295,6 +304,7 @@ Counter!
295 304
296print Counter.count -- 输出 2 305print Counter.count -- 输出 2
297``` 306```
307
298<YueDisplay> 308<YueDisplay>
299 309
300```yue 310```yue
@@ -317,6 +327,7 @@ print Counter.count -- 输出 2
317```yuescript 327```yuescript
318@@hello 1,2,3,4 328@@hello 1,2,3,4
319``` 329```
330
320<YueDisplay> 331<YueDisplay>
321 332
322```yue 333```yue
@@ -335,6 +346,7 @@ print Counter.count -- 输出 2
335class Things 346class Things
336 @class_var = "hello world" 347 @class_var = "hello world"
337``` 348```
349
338<YueDisplay> 350<YueDisplay>
339 351
340```yue 352```yue
@@ -356,6 +368,7 @@ class MoreThings
356 some_method: => 368 some_method: =>
357 log "hello world: " .. secret 369 log "hello world: " .. secret
358``` 370```
371
359<YueDisplay> 372<YueDisplay>
360 373
361```yue 374```yue
@@ -379,6 +392,7 @@ class MoreThings
379assert @ == self 392assert @ == self
380assert @@ == self.__class 393assert @@ == self.__class
381``` 394```
395
382<YueDisplay> 396<YueDisplay>
383 397
384```yue 398```yue
@@ -393,6 +407,7 @@ assert @@ == self.__class
393```yuescript 407```yuescript
394some_instance_method = (...) => @@ ... 408some_instance_method = (...) => @@ ...
395``` 409```
410
396<YueDisplay> 411<YueDisplay>
397 412
398```yue 413```yue
@@ -418,6 +433,7 @@ class Something
418 @@biz = biz 433 @@biz = biz
419 @@baz = baz 434 @@baz = baz
420``` 435```
436
421<YueDisplay> 437<YueDisplay>
422 438
423```yue 439```yue
@@ -443,6 +459,7 @@ new = (@fieldA, @fieldB) => @
443obj = new {}, 123, "abc" 459obj = new {}, 123, "abc"
444print obj 460print obj
445``` 461```
462
446<YueDisplay> 463<YueDisplay>
447 464
448```yue 465```yue
@@ -462,6 +479,7 @@ x = class Bucket
462 drops: 0 479 drops: 0
463 add_drop: => @drops += 1 480 add_drop: => @drops += 1
464``` 481```
482
465<YueDisplay> 483<YueDisplay>
466 484
467```yue 485```yue
@@ -482,6 +500,7 @@ BigBucket = class extends Bucket
482 500
483assert Bucket.__name == "BigBucket" 501assert Bucket.__name == "BigBucket"
484``` 502```
503
485<YueDisplay> 504<YueDisplay>
486 505
487```yue 506```yue
@@ -498,6 +517,7 @@ assert Bucket.__name == "BigBucket"
498```yuescript 517```yuescript
499x = class 518x = class
500``` 519```
520
501<YueDisplay> 521<YueDisplay>
502 522
503```yue 523```yue
@@ -527,6 +547,7 @@ y\func!
527 547
528assert y.__class.__parent ~= X -- X 不是 Y 的父类 548assert y.__class.__parent ~= X -- X 不是 Y 的父类
529``` 549```
550
530<YueDisplay> 551<YueDisplay>
531 552
532```yue 553```yue
diff --git a/doc/docs/zh/doc/objects/with-statement.md b/doc/docs/zh/doc/objects/with-statement.md
index fbd3633..0925050 100644
--- a/doc/docs/zh/doc/objects/with-statement.md
+++ b/doc/docs/zh/doc/objects/with-statement.md
@@ -1,6 +1,5 @@
1# with 语句 1# with 语句
2 2
3
4在编写 Lua 代码时,我们在创建对象后的常见操作是立即调用这个对象一系列操作函数并设置一系列属性。 3在编写 Lua 代码时,我们在创建对象后的常见操作是立即调用这个对象一系列操作函数并设置一系列属性。
5 4
6这导致在代码中多次重复引用对象的名称,增加了不必要的文本噪音。一个常见的解决方案是在创建对象时,在构造函数传入一个表,该表包含要覆盖设置的键和值的集合。这样做的缺点是该对象的构造函数必须支持这种初始化形式。 5这导致在代码中多次重复引用对象的名称,增加了不必要的文本噪音。一个常见的解决方案是在创建对象时,在构造函数传入一个表,该表包含要覆盖设置的键和值的集合。这样做的缺点是该对象的构造函数必须支持这种初始化形式。
@@ -16,6 +15,7 @@ with Person!
16 \save! 15 \save!
17 print .name 16 print .name
18``` 17```
18
19<YueDisplay> 19<YueDisplay>
20 20
21```yue 21```yue
@@ -34,6 +34,7 @@ with 语句也可以用作一个表达式,并返回它的代码块正在处理
34file = with File "favorite_foods.txt" 34file = with File "favorite_foods.txt"
35 \set_encoding "utf8" 35 \set_encoding "utf8"
36``` 36```
37
37<YueDisplay> 38<YueDisplay>
38 39
39```yue 40```yue
@@ -53,6 +54,7 @@ create_person = (name, relatives) ->
53 54
54me = create_person "Leaf", [dad, mother, sister] 55me = create_person "Leaf", [dad, mother, sister]
55``` 56```
57
56<YueDisplay> 58<YueDisplay>
57 59
58```yue 60```yue
@@ -75,6 +77,7 @@ with str := "你好"
75 print "原始:", str 77 print "原始:", str
76 print "大写:", \upper! 78 print "大写:", \upper!
77``` 79```
80
78<YueDisplay> 81<YueDisplay>
79 82
80```yue 83```yue
@@ -96,6 +99,7 @@ with tb
96 ["key-name"] = value 99 ["key-name"] = value
97 [] = "abc" -- 追加到 "tb" 100 [] = "abc" -- 追加到 "tb"
98``` 101```
102
99<YueDisplay> 103<YueDisplay>
100 104
101```yue 105```yue
@@ -116,6 +120,7 @@ with tb
116with? obj 120with? obj
117 print obj.name 121 print obj.name
118``` 122```
123
119<YueDisplay> 124<YueDisplay>
120 125
121```yue 126```yue
diff --git a/doc/docs/zh/doc/reference/license-mit.md b/doc/docs/zh/doc/reference/license-mit.md
index 24b5b15..7979663 100644
--- a/doc/docs/zh/doc/reference/license-mit.md
+++ b/doc/docs/zh/doc/reference/license-mit.md
@@ -1,6 +1,6 @@
1# MIT 许可证 1# MIT 许可证
2 2
3版权 (c) 2017-2026 李瑾 \<dragon-fly@qq.com\> 3版权 (c) 2017-2026 李瑾 \<dragon-fly@qq.com\>
4 4
5特此免费授予任何获得本软件副本和相关文档文件(下称“软件”)的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、转授许可和/或出售该软件副本,以及再授权被配发了本软件的人如上的权利,须在下列条件下: 5特此免费授予任何获得本软件副本和相关文档文件(下称“软件”)的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、转授许可和/或出售该软件副本,以及再授权被配发了本软件的人如上的权利,须在下列条件下:
6上述版权声明和本许可声明应包含在该软件的所有副本或实质成分中。 6上述版权声明和本许可声明应包含在该软件的所有副本或实质成分中。
diff --git a/doc/docs/zh/doc/reference/the-yuescript-library.md b/doc/docs/zh/doc/reference/the-yuescript-library.md
index 54e26f7..9565b01 100644
--- a/doc/docs/zh/doc/reference/the-yuescript-library.md
+++ b/doc/docs/zh/doc/reference/the-yuescript-library.md
@@ -17,6 +17,7 @@
17月之脚本版本。 17月之脚本版本。
18 18
19**签名:** 19**签名:**
20
20```lua 21```lua
21version: string 22version: string
22``` 23```
@@ -30,6 +31,7 @@ version: string
30当前平台的文件分隔符。 31当前平台的文件分隔符。
31 32
32**签名:** 33**签名:**
34
33```lua 35```lua
34dirsep: string 36dirsep: string
35``` 37```
@@ -43,6 +45,7 @@ dirsep: string
43编译模块代码缓存。 45编译模块代码缓存。
44 46
45**签名:** 47**签名:**
48
46```lua 49```lua
47yue_compiled: {string: string} 50yue_compiled: {string: string}
48``` 51```
@@ -56,6 +59,7 @@ yue_compiled: {string: string}
56月之脚本的编译函数。它将 YueScript 代码编译为 Lua 代码。 59月之脚本的编译函数。它将 YueScript 代码编译为 Lua 代码。
57 60
58**签名:** 61**签名:**
62
59```lua 63```lua
60to_lua: function(code: string, config?: Config): 64to_lua: function(code: string, config?: Config):
61 --[[codes]] string | nil, 65 --[[codes]] string | nil,
@@ -65,17 +69,17 @@ to_lua: function(code: string, config?: Config):
65 69
66**参数:** 70**参数:**
67 71
68| 参数名 | 类型 | 描述 | 72| 参数名 | 类型 | 描述 |
69| --- | --- | --- | 73| ------ | ------ | ------------------- |
70| code | string | YueScript 代码。 | 74| code | string | YueScript 代码。 |
71| config | Config | [可选] 编译器选项。 | 75| config | Config | [可选] 编译器选项。 |
72 76
73**返回值:** 77**返回值:**
74 78
75| 返回类型 | 描述 | 79| 返回类型 | 描述 |
76| --- | --- | 80| ----------------------------------- | ------------------------------------------------------------------------------------------ |
77| string \| nil | 编译后的 Lua 代码,如果编译失败则为 nil。 | 81| string \| nil | 编译后的 Lua 代码,如果编译失败则为 nil。 |
78| string \| nil | 错误消息,如果编译成功则为 nil。 | 82| string \| nil | 错误消息,如果编译成功则为 nil。 |
79| {{string, integer, integer}} \| nil | 代码中出现的全局变量(带有名称、行和列),如果编译器选项 `lint_global` 为 false 则为 nil。 | 83| {{string, integer, integer}} \| nil | 代码中出现的全局变量(带有名称、行和列),如果编译器选项 `lint_global` 为 false 则为 nil。 |
80 84
81### file_exist 85### file_exist
@@ -87,21 +91,22 @@ to_lua: function(code: string, config?: Config):
87检查源文件是否存在的函数。可以覆盖该函数以自定义行为。 91检查源文件是否存在的函数。可以覆盖该函数以自定义行为。
88 92
89**签名:** 93**签名:**
94
90```lua 95```lua
91file_exist: function(filename: string): boolean 96file_exist: function(filename: string): boolean
92``` 97```
93 98
94**参数:** 99**参数:**
95 100
96| 参数名 | 类型 | 描述 | 101| 参数名 | 类型 | 描述 |
97| --- | --- | --- | 102| -------- | ------ | -------- |
98| filename | string | 文件名。 | 103| filename | string | 文件名。 |
99 104
100**返回值:** 105**返回值:**
101 106
102| 返回类型 | 描述 | 107| 返回类型 | 描述 |
103| --- | --- | 108| -------- | -------------- |
104| boolean | 文件是否存在。 | 109| boolean | 文件是否存在。 |
105 110
106### read_file 111### read_file
107 112
@@ -112,21 +117,22 @@ file_exist: function(filename: string): boolean
112读取源文件的函数。可以覆盖该函数以自定义行为。 117读取源文件的函数。可以覆盖该函数以自定义行为。
113 118
114**签名:** 119**签名:**
120
115```lua 121```lua
116read_file: function(filename: string): string 122read_file: function(filename: string): string
117``` 123```
118 124
119**参数:** 125**参数:**
120 126
121| 参数名 | 类型 | 描述 | 127| 参数名 | 类型 | 描述 |
122| --- | --- | --- | 128| -------- | ------ | -------- |
123| filename | string | 文件名。 | 129| filename | string | 文件名。 |
124 130
125**返回值:** 131**返回值:**
126 132
127| 返回类型 | 描述 | 133| 返回类型 | 描述 |
128| --- | --- | 134| -------- | ---------- |
129| string | 文件内容。 | 135| string | 文件内容。 |
130 136
131### insert_loader 137### insert_loader
132 138
@@ -137,21 +143,22 @@ read_file: function(filename: string): string
137将 YueScript 加载器插入到 Lua 包加载器(搜索器)中。 143将 YueScript 加载器插入到 Lua 包加载器(搜索器)中。
138 144
139**签名:** 145**签名:**
146
140```lua 147```lua
141insert_loader: function(pos?: integer): boolean 148insert_loader: function(pos?: integer): boolean
142``` 149```
143 150
144**参数:** 151**参数:**
145 152
146| 参数名 | 类型 | 描述 | 153| 参数名 | 类型 | 描述 |
147| --- | --- | --- | 154| ------ | ------- | ------------------------------------- |
148| pos | integer | [可选] 要插入加载器的位置。默认为 3。 | 155| pos | integer | [可选] 要插入加载器的位置。默认为 3。 |
149 156
150**返回值:** 157**返回值:**
151 158
152| 返回类型 | 描述 | 159| 返回类型 | 描述 |
153| --- | --- | 160| -------- | ---------------------------------------------------- |
154| boolean | 是否成功插入加载器。如果加载器已经插入,则返回失败。 | 161| boolean | 是否成功插入加载器。如果加载器已经插入,则返回失败。 |
155 162
156### remove_loader 163### remove_loader
157 164
@@ -162,15 +169,16 @@ insert_loader: function(pos?: integer): boolean
162从 Lua 包加载器(搜索器)中移除 YueScript 加载器。 169从 Lua 包加载器(搜索器)中移除 YueScript 加载器。
163 170
164**签名:** 171**签名:**
172
165```lua 173```lua
166remove_loader: function(): boolean 174remove_loader: function(): boolean
167``` 175```
168 176
169**返回值:** 177**返回值:**
170 178
171| 返回类型 | 描述 | 179| 返回类型 | 描述 |
172| --- | --- | 180| -------- | -------------------------------------------------- |
173| boolean | 是否成功移除加载器。如果加载器未插入,则返回失败。 | 181| boolean | 是否成功移除加载器。如果加载器未插入,则返回失败。 |
174 182
175### loadstring 183### loadstring
176 184
@@ -181,6 +189,7 @@ remove_loader: function(): boolean
181将 YueScript 代码字符串加载为一个函数。 189将 YueScript 代码字符串加载为一个函数。
182 190
183**签名:** 191**签名:**
192
184```lua 193```lua
185loadstring: function(input: string, chunkname: string, env: table, config?: Config): 194loadstring: function(input: string, chunkname: string, env: table, config?: Config):
186 --[[loaded function]] nil | function(...: any): (any...), 195 --[[loaded function]] nil | function(...: any): (any...),
@@ -189,19 +198,19 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf
189 198
190**参数:** 199**参数:**
191 200
192| 参数名 | 类型 | 描述 | 201| 参数名 | 类型 | 描述 |
193| --- | --- | --- | 202| --------- | ------ | ------------------- |
194| input | string | YueScript 代码。 | 203| input | string | YueScript 代码。 |
195| chunkname | string | 代码块的名称。 | 204| chunkname | string | 代码块的名称。 |
196| env | table | 环境表。 | 205| env | table | 环境表。 |
197| config | Config | [可选] 编译器选项。 | 206| config | Config | [可选] 编译器选项。 |
198 207
199**返回值:** 208**返回值:**
200 209
201| 返回类型 | 描述 | 210| 返回类型 | 描述 |
202| --- | --- | 211| --------------- | ---------------------------------- |
203| function \| nil | 加载的函数,如果加载失败则为 nil。 | 212| function \| nil | 加载的函数,如果加载失败则为 nil。 |
204| string \| nil | 错误消息,如果加载成功则为 nil。 | 213| string \| nil | 错误消息,如果加载成功则为 nil。 |
205 214
206### loadstring 215### loadstring
207 216
@@ -212,6 +221,7 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf
212将 YueScript 代码字符串加载为一个函数。 221将 YueScript 代码字符串加载为一个函数。
213 222
214**签名:** 223**签名:**
224
215```lua 225```lua
216loadstring: function(input: string, chunkname: string, config?: Config): 226loadstring: function(input: string, chunkname: string, config?: Config):
217 --[[loaded function]] nil | function(...: any): (any...), 227 --[[loaded function]] nil | function(...: any): (any...),
@@ -220,18 +230,18 @@ loadstring: function(input: string, chunkname: string, config?: Config):
220 230
221**参数:** 231**参数:**
222 232
223| 参数名 | 类型 | 描述 | 233| 参数名 | 类型 | 描述 |
224| --- | --- | --- | 234| --------- | ------ | ------------------- |
225| input | string | YueScript 代码。 | 235| input | string | YueScript 代码。 |
226| chunkname | string | 代码块的名称。 | 236| chunkname | string | 代码块的名称。 |
227| config | Config | [可选] 编译器选项。 | 237| config | Config | [可选] 编译器选项。 |
228 238
229**返回值:** 239**返回值:**
230 240
231| 返回类型 | 描述 | 241| 返回类型 | 描述 |
232| --- | --- | 242| --------------- | ---------------------------------- |
233| function \| nil | 加载的函数,如果加载失败则为 nil。 | 243| function \| nil | 加载的函数,如果加载失败则为 nil。 |
234| string \| nil | 错误消息,如果加载成功则为 nil。 | 244| string \| nil | 错误消息,如果加载成功则为 nil。 |
235 245
236### loadstring 246### loadstring
237 247
@@ -242,6 +252,7 @@ loadstring: function(input: string, chunkname: string, config?: Config):
242将 YueScript 代码字符串加载为一个函数。 252将 YueScript 代码字符串加载为一个函数。
243 253
244**签名:** 254**签名:**
255
245```lua 256```lua
246loadstring: function(input: string, config?: Config): 257loadstring: function(input: string, config?: Config):
247 --[[loaded function]] nil | function(...: any): (any...), 258 --[[loaded function]] nil | function(...: any): (any...),
@@ -250,17 +261,17 @@ loadstring: function(input: string, config?: Config):
250 261
251**参数:** 262**参数:**
252 263
253| 参数名 | 类型 | 描述 | 264| 参数名 | 类型 | 描述 |
254| --- | --- | --- | 265| ------ | ------ | ------------------- |
255| input | string | YueScript 代码。 | 266| input | string | YueScript 代码。 |
256| config | Config | [可选] 编译器选项。 | 267| config | Config | [可选] 编译器选项。 |
257 268
258**返回值:** 269**返回值:**
259 270
260| 返回类型 | 描述 | 271| 返回类型 | 描述 |
261| --- | --- | 272| --------------- | ---------------------------------- |
262| function \| nil | 加载的函数,如果加载失败则为 nil。 | 273| function \| nil | 加载的函数,如果加载失败则为 nil。 |
263| string \| nil | 错误消息,如果加载成功则为 nil。 | 274| string \| nil | 错误消息,如果加载成功则为 nil。 |
264 275
265### loadfile 276### loadfile
266 277
@@ -271,6 +282,7 @@ loadstring: function(input: string, config?: Config):
271将 YueScript 代码文件加载为一个函数。 282将 YueScript 代码文件加载为一个函数。
272 283
273**签名:** 284**签名:**
285
274```lua 286```lua
275loadfile: function(filename: string, env: table, config?: Config): 287loadfile: function(filename: string, env: table, config?: Config):
276 nil | function(...: any): (any...), 288 nil | function(...: any): (any...),
@@ -279,18 +291,18 @@ loadfile: function(filename: string, env: table, config?: Config):
279 291
280**参数:** 292**参数:**
281 293
282| 参数名 | 类型 | 描述 | 294| 参数名 | 类型 | 描述 |
283| --- | --- | --- | 295| -------- | ------ | ------------------- |
284| filename | string | 文件名。 | 296| filename | string | 文件名。 |
285| env | table | 环境表。 | 297| env | table | 环境表。 |
286| config | Config | [可选] 编译器选项。 | 298| config | Config | [可选] 编译器选项。 |
287 299
288**返回值:** 300**返回值:**
289 301
290| 返回类型 | 描述 | 302| 返回类型 | 描述 |
291| --- | --- | 303| --------------- | ---------------------------------- |
292| function \| nil | 加载的函数,如果加载失败则为 nil。 | 304| function \| nil | 加载的函数,如果加载失败则为 nil。 |
293| string \| nil | 错误消息,如果加载成功则为 nil。 | 305| string \| nil | 错误消息,如果加载成功则为 nil。 |
294 306
295### loadfile 307### loadfile
296 308
@@ -301,6 +313,7 @@ loadfile: function(filename: string, env: table, config?: Config):
301将 YueScript 代码文件加载为一个函数。 313将 YueScript 代码文件加载为一个函数。
302 314
303**签名:** 315**签名:**
316
304```lua 317```lua
305loadfile: function(filename: string, config?: Config): 318loadfile: function(filename: string, config?: Config):
306 nil | function(...: any): (any...), 319 nil | function(...: any): (any...),
@@ -309,17 +322,17 @@ loadfile: function(filename: string, config?: Config):
309 322
310**参数:** 323**参数:**
311 324
312| 参数名 | 类型 | 描述 | 325| 参数名 | 类型 | 描述 |
313| --- | --- | --- | 326| -------- | ------ | ------------------- |
314| filename | string | 文件名。 | 327| filename | string | 文件名。 |
315| config | Config | [可选] 编译器选项。 | 328| config | Config | [可选] 编译器选项。 |
316 329
317**返回值:** 330**返回值:**
318 331
319| 返回类型 | 描述 | 332| 返回类型 | 描述 |
320| --- | --- | 333| --------------- | ---------------------------------- |
321| function \| nil | 加载的函数,如果加载失败则为 nil。 | 334| function \| nil | 加载的函数,如果加载失败则为 nil。 |
322| string \| nil | 错误消息,如果加载成功则为 nil。 | 335| string \| nil | 错误消息,如果加载成功则为 nil。 |
323 336
324### dofile 337### dofile
325 338
@@ -330,23 +343,24 @@ loadfile: function(filename: string, config?: Config):
330将 YueScript 代码文件加载为一个函数并执行。 343将 YueScript 代码文件加载为一个函数并执行。
331 344
332**签名:** 345**签名:**
346
333```lua 347```lua
334dofile: function(filename: string, env: table, config?: Config): any... 348dofile: function(filename: string, env: table, config?: Config): any...
335``` 349```
336 350
337**参数:** 351**参数:**
338 352
339| 参数名 | 类型 | 描述 | 353| 参数名 | 类型 | 描述 |
340| --- | --- | --- | 354| -------- | ------ | ------------------- |
341| filename | string | 文件名。 | 355| filename | string | 文件名。 |
342| env | table | 环境表。 | 356| env | table | 环境表。 |
343| config | Config | [可选] 编译器选项。 | 357| config | Config | [可选] 编译器选项。 |
344 358
345**返回值:** 359**返回值:**
346 360
347| 返回类型 | 描述 | 361| 返回类型 | 描述 |
348| --- | --- | 362| -------- | -------------------------- |
349| any... | 加载的函数执行后的返回值。 | 363| any... | 加载的函数执行后的返回值。 |
350 364
351### dofile 365### dofile
352 366
@@ -357,22 +371,23 @@ dofile: function(filename: string, env: table, config?: Config): any...
357将 YueScript 代码文件加载为一个函数并执行。 371将 YueScript 代码文件加载为一个函数并执行。
358 372
359**签名:** 373**签名:**
374
360```lua 375```lua
361dofile: function(filename: string, config?: Config): any... 376dofile: function(filename: string, config?: Config): any...
362``` 377```
363 378
364**参数:** 379**参数:**
365 380
366| 参数名 | 类型 | 描述 | 381| 参数名 | 类型 | 描述 |
367| --- | --- | --- | 382| -------- | ------ | ------------------- |
368| filename | string | 文件名。 | 383| filename | string | 文件名。 |
369| config | Config | [可选] 编译器选项。 | 384| config | Config | [可选] 编译器选项。 |
370 385
371**返回值:** 386**返回值:**
372 387
373| 返回类型 | 描述 | 388| 返回类型 | 描述 |
374| --- | --- | 389| -------- | -------------------------- |
375| any... | 加载的函数执行后的返回值。 | 390| any... | 加载的函数执行后的返回值。 |
376 391
377### find_modulepath 392### find_modulepath
378 393
@@ -383,21 +398,22 @@ dofile: function(filename: string, config?: Config): any...
383将 YueScript 模块名解析为文件路径。 398将 YueScript 模块名解析为文件路径。
384 399
385**签名:** 400**签名:**
401
386```lua 402```lua
387find_modulepath: function(name: string): string 403find_modulepath: function(name: string): string
388``` 404```
389 405
390**参数:** 406**参数:**
391 407
392| 参数名 | 类型 | 描述 | 408| 参数名 | 类型 | 描述 |
393| --- | --- | --- | 409| ------ | ------ | -------- |
394| name | string | 模块名。 | 410| name | string | 模块名。 |
395 411
396**返回值:** 412**返回值:**
397 413
398| 返回类型 | 描述 | 414| 返回类型 | 描述 |
399| --- | --- | 415| -------- | ---------- |
400| string | 文件路径。 | 416| string | 文件路径。 |
401 417
402### pcall 418### pcall
403 419
@@ -410,21 +426,22 @@ find_modulepath: function(name: string): string
410当发生错误时,将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 426当发生错误时,将错误信息中的代码行号重写为 YueScript 代码中的原始行号。
411 427
412**签名:** 428**签名:**
429
413```lua 430```lua
414pcall: function(f: function, ...: any): boolean, any... 431pcall: function(f: function, ...: any): boolean, any...
415``` 432```
416 433
417**参数:** 434**参数:**
418 435
419| 参数名 | 类型 | 描述 | 436| 参数名 | 类型 | 描述 |
420| --- | --- | --- | 437| ------ | -------- | -------------------- |
421| f | function | 要调用的函数。 | 438| f | function | 要调用的函数。 |
422| ... | any | 要传递给函数的参数。 | 439| ... | any | 要传递给函数的参数。 |
423 440
424**返回值:** 441**返回值:**
425 442
426| 返回类型 | 描述 | 443| 返回类型 | 描述 |
427| --- | --- | 444| ------------ | ---------------------------- |
428| boolean, ... | 状态码和函数结果或错误信息。 | 445| boolean, ... | 状态码和函数结果或错误信息。 |
429 446
430### require 447### require
@@ -437,21 +454,22 @@ pcall: function(f: function, ...: any): boolean, any...
437如果模块是 YueScript 模块且加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 454如果模块是 YueScript 模块且加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。
438 455
439**签名:** 456**签名:**
457
440```lua 458```lua
441require: function(name: string): any... 459require: function(name: string): any...
442``` 460```
443 461
444**参数:** 462**参数:**
445 463
446| 参数名 | 类型 | 描述 | 464| 参数名 | 类型 | 描述 |
447| --- | --- | --- | 465| ------- | ------ | ---------------- |
448| modname | string | 要加载的模块名。 | 466| modname | string | 要加载的模块名。 |
449 467
450**返回值:** 468**返回值:**
451 469
452| 返回类型 | 描述 | 470| 返回类型 | 描述 |
453| --- | --- | 471| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
454| any | 如果模块已经加载,则返回 package.loaded[modname] 中存储的值。否则,尝试查找加载器并返回 package.loaded[modname] 的最终值和加载器数据作为第二个结果。 | 472| any | 如果模块已经加载,则返回 package.loaded[modname] 中存储的值。否则,尝试查找加载器并返回 package.loaded[modname] 的最终值和加载器数据作为第二个结果。 |
455 473
456### p 474### p
457 475
@@ -462,15 +480,16 @@ require: function(name: string): any...
462检查传递的值的内部结构,并打印值出它的字符串表示。 480检查传递的值的内部结构,并打印值出它的字符串表示。
463 481
464**签名:** 482**签名:**
483
465```lua 484```lua
466p: function(...: any) 485p: function(...: any)
467``` 486```
468 487
469**参数:** 488**参数:**
470 489
471| 参数名 | 类型 | 描述 | 490| 参数名 | 类型 | 描述 |
472| --- | --- | --- | 491| ------ | ---- | ------------ |
473| ... | any | 要检查的值。 | 492| ... | any | 要检查的值。 |
474 493
475### options 494### options
476 495
@@ -481,6 +500,7 @@ p: function(...: any)
481当前编译器选项。 500当前编译器选项。
482 501
483**签名:** 502**签名:**
503
484```lua 504```lua
485options: Config.Options 505options: Config.Options
486``` 506```
@@ -494,21 +514,22 @@ options: Config.Options
494重写堆栈跟踪中的行号为 YueScript 代码中的原始行号的 traceback 函数。 514重写堆栈跟踪中的行号为 YueScript 代码中的原始行号的 traceback 函数。
495 515
496**签名:** 516**签名:**
517
497```lua 518```lua
498traceback: function(message: string): string 519traceback: function(message: string): string
499``` 520```
500 521
501**参数:** 522**参数:**
502 523
503| 参数名 | 类型 | 描述 | 524| 参数名 | 类型 | 描述 |
504| --- | --- | --- | 525| ------- | ------ | -------------- |
505| message | string | 堆栈跟踪消息。 | 526| message | string | 堆栈跟踪消息。 |
506 527
507**返回值:** 528**返回值:**
508 529
509| 返回类型 | 描述 | 530| 返回类型 | 描述 |
510| --- | --- | 531| -------- | ---------------------- |
511| string | 重写后的堆栈跟踪消息。 | 532| string | 重写后的堆栈跟踪消息。 |
512 533
513### is_ast 534### is_ast
514 535
@@ -519,22 +540,23 @@ traceback: function(message: string): string
519检查代码是否匹配指定的 AST。 540检查代码是否匹配指定的 AST。
520 541
521**签名:** 542**签名:**
543
522```lua 544```lua
523is_ast: function(astName: string, code: string): boolean 545is_ast: function(astName: string, code: string): boolean
524``` 546```
525 547
526**参数:** 548**参数:**
527 549
528| 参数名 | 类型 | 描述 | 550| 参数名 | 类型 | 描述 |
529| --- | --- | --- | 551| ------- | ------ | ---------- |
530| astName | string | AST 名称。 | 552| astName | string | AST 名称。 |
531| code | string | 代码。 | 553| code | string | 代码。 |
532 554
533**返回值:** 555**返回值:**
534 556
535| 返回类型 | 描述 | 557| 返回类型 | 描述 |
536| --- | --- | 558| -------- | ------------------ |
537| boolean | 代码是否匹配 AST。 | 559| boolean | 代码是否匹配 AST。 |
538 560
539### AST 561### AST
540 562
@@ -545,6 +567,7 @@ is_ast: function(astName: string, code: string): boolean
545AST 类型定义,带有名称、行、列和子节点。 567AST 类型定义,带有名称、行、列和子节点。
546 568
547**签名:** 569**签名:**
570
548```lua 571```lua
549type AST = {string, integer, integer, any} 572type AST = {string, integer, integer, any}
550``` 573```
@@ -558,6 +581,7 @@ type AST = {string, integer, integer, any}
558将代码转换为 AST。 581将代码转换为 AST。
559 582
560**签名:** 583**签名:**
584
561```lua 585```lua
562to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): 586to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean):
563 --[[AST]] AST | nil, 587 --[[AST]] AST | nil,
@@ -566,18 +590,18 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC
566 590
567**参数:** 591**参数:**
568 592
569| 参数名 | 类型 | 描述 | 593| 参数名 | 类型 | 描述 |
570| --- | --- | --- | 594| -------------- | ------- | ------------------------------------------------------------------------------ |
571| code | string | 代码。 | 595| code | string | 代码。 |
572| flattenLevel | integer | [可选] 扁平化级别。级别越高,会消除更多的 AST 结构的嵌套。默认为 0。最大为 2。 | 596| flattenLevel | integer | [可选] 扁平化级别。级别越高,会消除更多的 AST 结构的嵌套。默认为 0。最大为 2。 |
573| astName | string | [可选] AST 名称。默认为 "File"。 | 597| astName | string | [可选] AST 名称。默认为 "File"。 |
574| reserveComment | boolean | [可选] 是否保留原始注释。默认为 false。 | 598| reserveComment | boolean | [可选] 是否保留原始注释。默认为 false。 |
575 599
576**返回值:** 600**返回值:**
577 601
578| 返回类型 | 描述 | 602| 返回类型 | 描述 |
579| --- | --- | 603| ------------- | -------------------------------- |
580| AST \| nil | AST,如果转换失败则为 nil。 | 604| AST \| nil | AST,如果转换失败则为 nil。 |
581| string \| nil | 错误消息,如果转换成功则为 nil。 | 605| string \| nil | 错误消息,如果转换成功则为 nil。 |
582 606
583### format 607### format
@@ -589,25 +613,26 @@ to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveC
589格式化 YueScript 代码。 613格式化 YueScript 代码。
590 614
591**签名:** 615**签名:**
616
592```lua 617```lua
593format: function(code: string, tabSize?: number, reserveComment?: boolean): string 618format: function(code: string, tabSize?: number, reserveComment?: boolean): string
594``` 619```
595 620
596**参数:** 621**参数:**
597 622
598| 参数名 | 类型 | 描述 | 623| 参数名 | 类型 | 描述 |
599| --- | --- | --- | 624| -------------- | ------- | -------------------------------------- |
600| code | string | 代码。 | 625| code | string | 代码。 |
601| tabSize | integer | [可选] 制表符大小。默认为 4。 | 626| tabSize | integer | [可选] 制表符大小。默认为 4。 |
602| reserveComment | boolean | [可选] 是否保留原始注释。默认为 true。 | 627| reserveComment | boolean | [可选] 是否保留原始注释。默认为 true。 |
603 628
604**返回值:** 629**返回值:**
605 630
606| 返回类型 | 描述 | 631| 返回类型 | 描述 |
607| --- | --- | 632| -------- | ---------------- |
608| string | 格式化后的代码。 | 633| string | 格式化后的代码。 |
609 634
610### __call 635### \_\_call
611 636
612**类型:** 元方法。 637**类型:** 元方法。
613 638
@@ -617,21 +642,22 @@ format: function(code: string, tabSize?: number, reserveComment?: boolean): stri
617如果发生加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。 642如果发生加载失败,则将错误信息中的代码行号重写为 YueScript 代码中的原始行号。
618 643
619**签名:** 644**签名:**
645
620```lua 646```lua
621metamethod __call: function(self: yue, module: string): any... 647metamethod __call: function(self: yue, module: string): any...
622``` 648```
623 649
624**参数:** 650**参数:**
625 651
626| 参数名 | 类型 | 描述 | 652| 参数名 | 类型 | 描述 |
627| --- | --- | --- | 653| ------ | ------ | -------- |
628| module | string | 模块名。 | 654| module | string | 模块名。 |
629 655
630**返回值:** 656**返回值:**
631 657
632| 返回类型 | 描述 | 658| 返回类型 | 描述 |
633| --- | --- | 659| -------- | -------- |
634| any | 模块值。 | 660| any | 模块值。 |
635 661
636## Config 662## Config
637 663
@@ -648,6 +674,7 @@ metamethod __call: function(self: yue, module: string): any...
648编译器是否应该收集代码中出现的全局变量。 674编译器是否应该收集代码中出现的全局变量。
649 675
650**签名:** 676**签名:**
677
651```lua 678```lua
652lint_global: boolean 679lint_global: boolean
653``` 680```
@@ -661,6 +688,7 @@ lint_global: boolean
661编译器是否应该对根层级的代码块进行隐式的表达式返回。 688编译器是否应该对根层级的代码块进行隐式的表达式返回。
662 689
663**签名:** 690**签名:**
691
664```lua 692```lua
665implicit_return_root: boolean 693implicit_return_root: boolean
666``` 694```
@@ -674,6 +702,7 @@ implicit_return_root: boolean
674编译器是否应该在编译后的代码中保留原始行号。 702编译器是否应该在编译后的代码中保留原始行号。
675 703
676**签名:** 704**签名:**
705
677```lua 706```lua
678reserve_line_number: boolean 707reserve_line_number: boolean
679``` 708```
@@ -687,6 +716,7 @@ reserve_line_number: boolean
687编译器是否应该在编译后的代码中保留原始注释。 716编译器是否应该在编译后的代码中保留原始注释。
688 717
689**签名:** 718**签名:**
719
690```lua 720```lua
691reserve_comment: boolean 721reserve_comment: boolean
692``` 722```
@@ -700,6 +730,7 @@ reserve_comment: boolean
700编译器是否应该在编译后的代码中使用空格字符而不是制表符字符。 730编译器是否应该在编译后的代码中使用空格字符而不是制表符字符。
701 731
702**签名:** 732**签名:**
733
703```lua 734```lua
704space_over_tab: boolean 735space_over_tab: boolean
705``` 736```
@@ -713,6 +744,7 @@ space_over_tab: boolean
713编译器是否应该将要编译的代码视为当前正在编译的模块。仅供编译器内部使用。 744编译器是否应该将要编译的代码视为当前正在编译的模块。仅供编译器内部使用。
714 745
715**签名:** 746**签名:**
747
716```lua 748```lua
717same_module: boolean 749same_module: boolean
718``` 750```
@@ -726,6 +758,7 @@ same_module: boolean
726编译器错误消息是否应该包含行号偏移量。仅供编译器内部使用。 758编译器错误消息是否应该包含行号偏移量。仅供编译器内部使用。
727 759
728**签名:** 760**签名:**
761
729```lua 762```lua
730line_offset: integer 763line_offset: integer
731``` 764```
@@ -739,6 +772,7 @@ line_offset: integer
739目标 Lua 版本枚举。 772目标 Lua 版本枚举。
740 773
741**签名:** 774**签名:**
775
742```lua 776```lua
743enum LuaTarget 777enum LuaTarget
744 "5.1" 778 "5.1"
@@ -758,6 +792,7 @@ end
758要传递给编译函数的额外选项。 792要传递给编译函数的额外选项。
759 793
760**签名:** 794**签名:**
795
761```lua 796```lua
762options: Options 797options: Options
763``` 798```
@@ -777,6 +812,7 @@ options: Options
777编译目标 Lua 版本。 812编译目标 Lua 版本。
778 813
779**签名:** 814**签名:**
815
780```lua 816```lua
781target: LuaTarget 817target: LuaTarget
782``` 818```
@@ -790,6 +826,7 @@ target: LuaTarget
790额外模块搜索路径。 826额外模块搜索路径。
791 827
792**签名:** 828**签名:**
829
793```lua 830```lua
794path: string 831path: string
795``` 832```
@@ -803,6 +840,7 @@ path: string
803是否在回溯错误消息中输出代码块的局部变量。默认为 false。 840是否在回溯错误消息中输出代码块的局部变量。默认为 false。
804 841
805**签名:** 842**签名:**
843
806```lua 844```lua
807dump_locals: boolean 845dump_locals: boolean
808``` 846```
@@ -816,6 +854,7 @@ dump_locals: boolean
816是否简化输出的错误消息。默认为 true。 854是否简化输出的错误消息。默认为 true。
817 855
818**签名:** 856**签名:**
857
819```lua 858```lua
820simplified: boolean 859simplified: boolean
821``` 860```
diff --git a/doc/docs/zh/try/index.md b/doc/docs/zh/try/index.md
index c5678b7..7e198b0 100755
--- a/doc/docs/zh/try/index.md
+++ b/doc/docs/zh/try/index.md
@@ -5,6 +5,7 @@ next: false
5--- 5---
6 6
7# 月之脚本的在线编译器 7# 月之脚本的在线编译器
8
8--- 9---
9 10
10在这里试试 WASM 版的 YueScript 吧。 11在这里试试 WASM 版的 YueScript 吧。