aboutsummaryrefslogtreecommitdiff
path: root/doc/docs/doc/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/docs/doc/README.md')
-rwxr-xr-xdoc/docs/doc/README.md156
1 files changed, 78 insertions, 78 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