aboutsummaryrefslogtreecommitdiff
path: root/doc/docs
diff options
context:
space:
mode:
Diffstat (limited to 'doc/docs')
-rwxr-xr-xdoc/docs/doc/README.md156
-rwxr-xr-xdoc/docs/zh/doc/README.md156
2 files changed, 156 insertions, 156 deletions
diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md
index 11c9427..1a46e59 100755
--- a/doc/docs/doc/README.md
+++ b/doc/docs/doc/README.md
@@ -408,16 +408,16 @@ In YueScript, macro functions allow you to generate code at compile time. By nes
408 408
409```moonscript 409```moonscript
410macro Enum = (...) -> 410macro Enum = (...) ->
411 items = {...} 411 items = {...}
412 itemSet = {item, true for item in *items} 412 itemSet = {item, true for item in *items}
413 (item) -> 413 (item) ->
414 error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] 414 error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
415 "\"#{item}\"" 415 "\"#{item}\""
416 416
417macro BodyType = $Enum( 417macro BodyType = $Enum(
418 Static 418 Static
419 Dynamic 419 Dynamic
420 Kinematic 420 Kinematic
421) 421)
422 422
423print "Valid enum type:", $BodyType Static 423print "Valid enum type:", $BodyType Static
@@ -427,16 +427,16 @@ print "Valid enum type:", $BodyType Static
427<YueDisplay> 427<YueDisplay>
428<pre> 428<pre>
429macro Enum = (...) -> 429macro Enum = (...) ->
430 items = {...} 430 items = {...}
431 itemSet = {item, true for item in *items} 431 itemSet = {item, true for item in *items}
432 (item) -> 432 (item) ->
433 error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] 433 error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
434 "\"#{item}\"" 434 "\"#{item}\""
435 435
436macro BodyType = $Enum( 436macro BodyType = $Enum(
437 Static 437 Static
438 Dynamic 438 Dynamic
439 Kinematic 439 Kinematic
440) 440)
441 441
442print "Valid enum type:", $BodyType Static 442print "Valid enum type:", $BodyType Static
@@ -534,47 +534,47 @@ Note the evaluation behavior of chained comparisons:
534 534
535```moonscript 535```moonscript
536v = (x) -> 536v = (x) ->
537 print x 537 print x
538 x 538 x
539 539
540print v(1) < v(2) <= v(3) 540print v(1) < v(2) <= v(3)
541--[[ 541--[[
542 output: 542 output:
543 2 543 2
544 1 544 1
545 3 545 3
546 true 546 true
547]] 547]]
548 548
549print v(1) > v(2) <= v(3) 549print v(1) > v(2) <= v(3)
550--[[ 550--[[
551 output: 551 output:
552 2 552 2
553 1 553 1
554 false 554 false
555]] 555]]
556``` 556```
557<YueDisplay> 557<YueDisplay>
558<pre> 558<pre>
559v = (x) -> 559v = (x) ->
560 print x 560 print x
561 x 561 x
562 562
563print v(1) < v(2) <= v(3) 563print v(1) < v(2) <= v(3)
564--[[ 564--[[
565 output: 565 output:
566 2 566 2
567 1 567 1
568 3 568 3
569 true 569 true
570]] 570]]
571 571
572print v(1) > v(2) <= v(3) 572print v(1) > v(2) <= v(3)
573--[[ 573--[[
574 output: 574 output:
575 2 575 2
576 1 576 1
577 false 577 false
578]] 578]]
579</pre> 579</pre>
580</YueDisplay> 580</YueDisplay>
@@ -618,13 +618,13 @@ You can concatenate array tables or hash tables using spread operator `...` befo
618 618
619```moonscript 619```moonscript
620parts = 620parts =
621 * "shoulders" 621 * "shoulders"
622 * "knees" 622 * "knees"
623lyrics = 623lyrics =
624 * "head" 624 * "head"
625 * ...parts 625 * ...parts
626 * "and" 626 * "and"
627 * "toes" 627 * "toes"
628 628
629copy = {...other} 629copy = {...other}
630 630
@@ -635,13 +635,13 @@ merge = {...a, ...b}
635<YueDisplay> 635<YueDisplay>
636<pre> 636<pre>
637parts = 637parts =
638 * "shoulders" 638 * "shoulders"
639 * "knees" 639 * "knees"
640lyrics = 640lyrics =
641 * "head" 641 * "head"
642 * ...parts 642 * ...parts
643 * "and" 643 * "and"
644 * "toes" 644 * "toes"
645 645
646copy = {...other} 646copy = {...other}
647 647
@@ -3325,19 +3325,19 @@ Match against a list and capture a range of elements.
3325```moonscript 3325```moonscript
3326segments = ["admin", "users", "logs", "view"] 3326segments = ["admin", "users", "logs", "view"]
3327switch segments 3327switch segments
3328 when [...groups, resource, action] 3328 when [...groups, resource, action]
3329 print "Group:", groups -- prints: {"admin", "users"} 3329 print "Group:", groups -- prints: {"admin", "users"}
3330 print "Resource:", resource -- prints: "logs" 3330 print "Resource:", resource -- prints: "logs"
3331 print "Action:", action -- prints: "view" 3331 print "Action:", action -- prints: "view"
3332``` 3332```
3333<YueDisplay> 3333<YueDisplay>
3334<pre> 3334<pre>
3335segments = ["admin", "users", "logs", "view"] 3335segments = ["admin", "users", "logs", "view"]
3336switch segments 3336switch segments
3337 when [...groups, resource, action] 3337 when [...groups, resource, action]
3338 print "Group:", groups -- prints: {"admin", "users"} 3338 print "Group:", groups -- prints: {"admin", "users"}
3339 print "Resource:", resource -- prints: "logs" 3339 print "Resource:", resource -- prints: "logs"
3340 print "Action:", action -- prints: "view" 3340 print "Action:", action -- prints: "view"
3341</pre> 3341</pre>
3342</YueDisplay> 3342</YueDisplay>
3343 3343
@@ -4228,9 +4228,9 @@ The YueScript compiling function. It compiles the YueScript code to Lua code.
4228**Signature:** 4228**Signature:**
4229```lua 4229```lua
4230to_lua: function(code: string, config?: Config): 4230to_lua: function(code: string, config?: Config):
4231 --[[codes]] string | nil, 4231 --[[codes]] string | nil,
4232 --[[error]] string | nil, 4232 --[[error]] string | nil,
4233 --[[globals]] {{string, integer, integer}} | nil 4233 --[[globals]] {{string, integer, integer}} | nil
4234``` 4234```
4235 4235
4236**Parameters:** 4236**Parameters:**
@@ -4353,8 +4353,8 @@ Loads YueScript code from a string into a function.
4353**Signature:** 4353**Signature:**
4354```lua 4354```lua
4355loadstring: function(input: string, chunkname: string, env: table, config?: Config): 4355loadstring: function(input: string, chunkname: string, env: table, config?: Config):
4356 --[[loaded function]] nil | function(...: any): (any...), 4356 --[[loaded function]] nil | function(...: any): (any...),
4357 --[[error]] string | nil 4357 --[[error]] string | nil
4358``` 4358```
4359 4359
4360**Parameters:** 4360**Parameters:**
@@ -4384,8 +4384,8 @@ Loads YueScript code from a string into a function.
4384**Signature:** 4384**Signature:**
4385```lua 4385```lua
4386loadstring: function(input: string, chunkname: string, config?: Config): 4386loadstring: function(input: string, chunkname: string, config?: Config):
4387 --[[loaded function]] nil | function(...: any): (any...), 4387 --[[loaded function]] nil | function(...: any): (any...),
4388 --[[error]] string | nil 4388 --[[error]] string | nil
4389``` 4389```
4390 4390
4391**Parameters:** 4391**Parameters:**
@@ -4414,8 +4414,8 @@ Loads YueScript code from a string into a function.
4414**Signature:** 4414**Signature:**
4415```lua 4415```lua
4416loadstring: function(input: string, config?: Config): 4416loadstring: function(input: string, config?: Config):
4417 --[[loaded function]] nil | function(...: any): (any...), 4417 --[[loaded function]] nil | function(...: any): (any...),
4418 --[[error]] string | nil 4418 --[[error]] string | nil
4419``` 4419```
4420 4420
4421**Parameters:** 4421**Parameters:**
@@ -4443,8 +4443,8 @@ Loads YueScript code from a file into a function.
4443**Signature:** 4443**Signature:**
4444```lua 4444```lua
4445loadfile: function(filename: string, env: table, config?: Config): 4445loadfile: function(filename: string, env: table, config?: Config):
4446 nil | function(...: any): (any...), 4446 nil | function(...: any): (any...),
4447 string | nil 4447 string | nil
4448``` 4448```
4449 4449
4450**Parameters:** 4450**Parameters:**
@@ -4473,8 +4473,8 @@ Loads YueScript code from a file into a function.
4473**Signature:** 4473**Signature:**
4474```lua 4474```lua
4475loadfile: function(filename: string, config?: Config): 4475loadfile: function(filename: string, config?: Config):
4476 nil | function(...: any): (any...), 4476 nil | function(...: any): (any...),
4477 string | nil 4477 string | nil
4478``` 4478```
4479 4479
4480**Parameters:** 4480**Parameters:**
@@ -4730,8 +4730,8 @@ Converts the code to the AST.
4730**Signature:** 4730**Signature:**
4731```lua 4731```lua
4732to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): 4732to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean):
4733 --[[AST]] AST | nil, 4733 --[[AST]] AST | nil,
4734 --[[error]] nil | string 4734 --[[error]] nil | string
4735``` 4735```
4736 4736
4737**Parameters:** 4737**Parameters:**
@@ -4911,11 +4911,11 @@ The target Lua version enumeration.
4911**Signature:** 4911**Signature:**
4912```lua 4912```lua
4913enum LuaTarget 4913enum LuaTarget
4914 "5.1" 4914 "5.1"
4915 "5.2" 4915 "5.2"
4916 "5.3" 4916 "5.3"
4917 "5.4" 4917 "5.4"
4918 "5.5" 4918 "5.5"
4919end 4919end
4920``` 4920```
4921 4921
diff --git a/doc/docs/zh/doc/README.md b/doc/docs/zh/doc/README.md
index da69e22..b348e06 100755
--- a/doc/docs/zh/doc/README.md
+++ b/doc/docs/zh/doc/README.md
@@ -407,16 +407,16 @@ print $LINE -- 获取当前代码行数:2
407 407
408```moonscript 408```moonscript
409macro Enum = (...) -> 409macro Enum = (...) ->
410 items = {...} 410 items = {...}
411 itemSet = {item, true for item in *items} 411 itemSet = {item, true for item in *items}
412 (item) -> 412 (item) ->
413 error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] 413 error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
414 "\"#{item}\"" 414 "\"#{item}\""
415 415
416macro BodyType = $Enum( 416macro BodyType = $Enum(
417 Static 417 Static
418 Dynamic 418 Dynamic
419 Kinematic 419 Kinematic
420) 420)
421 421
422print "有效的枚举类型:", $BodyType Static 422print "有效的枚举类型:", $BodyType Static
@@ -425,16 +425,16 @@ print "有效的枚举类型:", $BodyType Static
425<YueDisplay> 425<YueDisplay>
426<pre> 426<pre>
427macro Enum = (...) -> 427macro Enum = (...) ->
428 items = {...} 428 items = {...}
429 itemSet = {item, true for item in *items} 429 itemSet = {item, true for item in *items}
430 (item) -> 430 (item) ->
431 error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item] 431 error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
432 "\"#{item}\"" 432 "\"#{item}\""
433 433
434macro BodyType = $Enum( 434macro BodyType = $Enum(
435 Static 435 Static
436 Dynamic 436 Dynamic
437 Kinematic 437 Kinematic
438) 438)
439 439
440print "有效的枚举类型:", $BodyType Static 440print "有效的枚举类型:", $BodyType Static
@@ -532,47 +532,47 @@ print 1 <= a <= 10
532 532
533```moonscript 533```moonscript
534v = (x) -> 534v = (x) ->
535 print x 535 print x
536 x 536 x
537 537
538print v(1) < v(2) <= v(3) 538print v(1) < v(2) <= v(3)
539--[[ 539--[[
540 输出: 540 输出:
541 2 541 2
542 1 542 1
543 3 543 3
544 true 544 true
545]] 545]]
546 546
547print v(1) > v(2) <= v(3) 547print v(1) > v(2) <= v(3)
548--[[ 548--[[
549 输出: 549 输出:
550 2 550 2
551 1 551 1
552 false 552 false
553]] 553]]
554``` 554```
555<YueDisplay> 555<YueDisplay>
556<pre> 556<pre>
557v = (x) -> 557v = (x) ->
558 print x 558 print x
559 x 559 x
560 560
561print v(1) < v(2) <= v(3) 561print v(1) < v(2) <= v(3)
562--[[ 562--[[
563 输出: 563 输出:
564 2 564 2
565 1 565 1
566 3 566 3
567 true 567 true
568]] 568]]
569 569
570print v(1) > v(2) <= v(3) 570print v(1) > v(2) <= v(3)
571--[[ 571--[[
572 输出: 572 输出:
573 2 573 2
574 1 574 1
575 false 575 false
576]] 576]]
577</pre> 577</pre>
578</YueDisplay> 578</YueDisplay>
@@ -617,13 +617,13 @@ tbA[] = ...tbB
617 617
618```moonscript 618```moonscript
619parts = 619parts =
620 * "shoulders" 620 * "shoulders"
621 * "knees" 621 * "knees"
622lyrics = 622lyrics =
623 * "head" 623 * "head"
624 * ...parts 624 * ...parts
625 * "and" 625 * "and"
626 * "toes" 626 * "toes"
627 627
628copy = {...other} 628copy = {...other}
629 629
@@ -634,13 +634,13 @@ merge = {...a, ...b}
634<YueDisplay> 634<YueDisplay>
635<pre> 635<pre>
636parts = 636parts =
637 * "shoulders" 637 * "shoulders"
638 * "knees" 638 * "knees"
639lyrics = 639lyrics =
640 * "head" 640 * "head"
641 * ...parts 641 * ...parts
642 * "and" 642 * "and"
643 * "toes" 643 * "toes"
644 644
645copy = {...other} 645copy = {...other}
646 646
@@ -3285,19 +3285,19 @@ switch tb
3285```moonscript 3285```moonscript
3286segments = ["admin", "users", "logs", "view"] 3286segments = ["admin", "users", "logs", "view"]
3287switch segments 3287switch segments
3288 when [...groups, resource, action] 3288 when [...groups, resource, action]
3289 print "Group:", groups -- 打印: {"admin", "users"} 3289 print "Group:", groups -- 打印: {"admin", "users"}
3290 print "Resource:", resource -- 打印: "logs" 3290 print "Resource:", resource -- 打印: "logs"
3291 print "Action:", action -- 打印: "view" 3291 print "Action:", action -- 打印: "view"
3292``` 3292```
3293<YueDisplay> 3293<YueDisplay>
3294<pre> 3294<pre>
3295segments = ["admin", "users", "logs", "view"] 3295segments = ["admin", "users", "logs", "view"]
3296switch segments 3296switch segments
3297 when [...groups, resource, action] 3297 when [...groups, resource, action]
3298 print "Group:", groups -- 打印: {"admin", "users"} 3298 print "Group:", groups -- 打印: {"admin", "users"}
3299 print "Resource:", resource -- 打印: "logs" 3299 print "Resource:", resource -- 打印: "logs"
3300 print "Action:", action -- 打印: "view" 3300 print "Action:", action -- 打印: "view"
3301</pre> 3301</pre>
3302</YueDisplay> 3302</YueDisplay>
3303 3303
@@ -4185,9 +4185,9 @@ yue_compiled: {string: string}
4185**签名:** 4185**签名:**
4186```lua 4186```lua
4187to_lua: function(code: string, config?: Config): 4187to_lua: function(code: string, config?: Config):
4188 --[[codes]] string | nil, 4188 --[[codes]] string | nil,
4189 --[[error]] string | nil, 4189 --[[error]] string | nil,
4190 --[[globals]] {{string, integer, integer}} | nil 4190 --[[globals]] {{string, integer, integer}} | nil
4191``` 4191```
4192 4192
4193**参数:** 4193**参数:**
@@ -4310,8 +4310,8 @@ remove_loader: function(): boolean
4310**签名:** 4310**签名:**
4311```lua 4311```lua
4312loadstring: function(input: string, chunkname: string, env: table, config?: Config): 4312loadstring: function(input: string, chunkname: string, env: table, config?: Config):
4313 --[[loaded function]] nil | function(...: any): (any...), 4313 --[[loaded function]] nil | function(...: any): (any...),
4314 --[[error]] string | nil 4314 --[[error]] string | nil
4315``` 4315```
4316 4316
4317**参数:** 4317**参数:**
@@ -4341,8 +4341,8 @@ loadstring: function(input: string, chunkname: string, env: table, config?: Conf
4341**签名:** 4341**签名:**
4342```lua 4342```lua
4343loadstring: function(input: string, chunkname: string, config?: Config): 4343loadstring: function(input: string, chunkname: string, config?: Config):
4344 --[[loaded function]] nil | function(...: any): (any...), 4344 --[[loaded function]] nil | function(...: any): (any...),
4345 --[[error]] string | nil 4345 --[[error]] string | nil
4346``` 4346```
4347 4347
4348**参数:** 4348**参数:**
@@ -4371,8 +4371,8 @@ loadstring: function(input: string, chunkname: string, config?: Config):
4371**签名:** 4371**签名:**
4372```lua 4372```lua
4373loadstring: function(input: string, config?: Config): 4373loadstring: function(input: string, config?: Config):
4374 --[[loaded function]] nil | function(...: any): (any...), 4374 --[[loaded function]] nil | function(...: any): (any...),
4375 --[[error]] string | nil 4375 --[[error]] string | nil
4376``` 4376```
4377 4377
4378**参数:** 4378**参数:**
@@ -4400,8 +4400,8 @@ loadstring: function(input: string, config?: Config):
4400**签名:** 4400**签名:**
4401```lua 4401```lua
4402loadfile: function(filename: string, env: table, config?: Config): 4402loadfile: function(filename: string, env: table, config?: Config):
4403 nil | function(...: any): (any...), 4403 nil | function(...: any): (any...),
4404 string | nil 4404 string | nil
4405``` 4405```
4406 4406
4407**参数:** 4407**参数:**
@@ -4430,8 +4430,8 @@ loadfile: function(filename: string, env: table, config?: Config):
4430**签名:** 4430**签名:**
4431```lua 4431```lua
4432loadfile: function(filename: string, config?: Config): 4432loadfile: function(filename: string, config?: Config):
4433 nil | function(...: any): (any...), 4433 nil | function(...: any): (any...),
4434 string | nil 4434 string | nil
4435``` 4435```
4436 4436
4437**参数:** 4437**参数:**
@@ -4687,8 +4687,8 @@ type AST = {string, integer, integer, any}
4687**签名:** 4687**签名:**
4688```lua 4688```lua
4689to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): 4689to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean):
4690 --[[AST]] AST | nil, 4690 --[[AST]] AST | nil,
4691 --[[error]] nil | string 4691 --[[error]] nil | string
4692``` 4692```
4693 4693
4694**参数:** 4694**参数:**
@@ -4868,11 +4868,11 @@ line_offset: integer
4868**签名:** 4868**签名:**
4869```lua 4869```lua
4870enum LuaTarget 4870enum LuaTarget
4871 "5.1" 4871 "5.1"
4872 "5.2" 4872 "5.2"
4873 "5.3" 4873 "5.3"
4874 "5.4" 4874 "5.4"
4875 "5.5" 4875 "5.5"
4876end 4876end
4877``` 4877```
4878 4878