@@ -408,16 +408,16 @@ In YueScript, macro functions allow you to generate code at compile time. By nes
408408
409409``` moonscript
410410macro Enum = (...) ->
411- items = {...}
412- itemSet = {item, true for item in *items}
413- (item) ->
414- error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
415- "\"#{item}\""
411+ items = {...}
412+ itemSet = {item, true for item in *items}
413+ (item) ->
414+ error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
415+ "\"#{item}\""
416416
417417macro BodyType = $Enum(
418- Static
419- Dynamic
420- Kinematic
418+ Static
419+ Dynamic
420+ Kinematic
421421)
422422
423423print "Valid enum type:", $BodyType Static
@@ -427,16 +427,16 @@ print "Valid enum type:", $BodyType Static
427427<YueDisplay >
428428<pre >
429429macro Enum = (...) ->
430- items = {...}
431- itemSet = {item, true for item in *items}
432- (item) ->
433- error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
434- "\"#{item}\""
430+ items = {...}
431+ itemSet = {item, true for item in *items}
432+ (item) ->
433+ error "got \"#{item}\", expecting one of #{table.concat items, ', '}" unless itemSet[item]
434+ "\"#{item}\""
435435
436436macro BodyType = $Enum(
437- Static
438- Dynamic
439- Kinematic
437+ Static
438+ Dynamic
439+ Kinematic
440440)
441441
442442print "Valid enum type:", $BodyType Static
@@ -534,47 +534,47 @@ Note the evaluation behavior of chained comparisons:
534534
535535``` moonscript
536536v = (x) ->
537- print x
538- x
537+ print x
538+ x
539539
540540print v(1) < v(2) <= v(3)
541541--[[
542- output:
543- 2
544- 1
545- 3
546- true
542+ output:
543+ 2
544+ 1
545+ 3
546+ true
547547]]
548548
549549print v(1) > v(2) <= v(3)
550550--[[
551- output:
552- 2
553- 1
554- false
551+ output:
552+ 2
553+ 1
554+ false
555555]]
556556```
557557<YueDisplay >
558558<pre >
559559v = (x) ->
560- print x
561- x
560+ print x
561+ x
562562
563563print v(1) < v(2) <= v(3)
564564--[[
565- output:
566- 2
567- 1
568- 3
569- true
565+ output:
566+ 2
567+ 1
568+ 3
569+ true
570570]]
571571
572572print v(1) > v(2) <= v(3)
573573--[[
574- output:
575- 2
576- 1
577- false
574+ output:
575+ 2
576+ 1
577+ false
578578]]
579579</pre >
580580</YueDisplay >
@@ -618,13 +618,13 @@ You can concatenate array tables or hash tables using spread operator `...` befo
618618
619619``` moonscript
620620parts =
621- * "shoulders"
622- * "knees"
621+ * "shoulders"
622+ * "knees"
623623lyrics =
624- * "head"
625- * ...parts
626- * "and"
627- * "toes"
624+ * "head"
625+ * ...parts
626+ * "and"
627+ * "toes"
628628
629629copy = {...other}
630630
@@ -635,13 +635,13 @@ merge = {...a, ...b}
635635<YueDisplay >
636636<pre >
637637parts =
638- * "shoulders"
639- * "knees"
638+ * "shoulders"
639+ * "knees"
640640lyrics =
641- * "head"
642- * ...parts
643- * "and"
644- * "toes"
641+ * "head"
642+ * ...parts
643+ * "and"
644+ * "toes"
645645
646646copy = {...other}
647647
@@ -3325,19 +3325,19 @@ Match against a list and capture a range of elements.
33253325``` moonscript
33263326segments = ["admin", "users", "logs", "view"]
33273327switch segments
3328- when [...groups, resource, action]
3329- print "Group:", groups -- prints: {"admin", "users"}
3330- print "Resource:", resource -- prints: "logs"
3331- print "Action:", action -- prints: "view"
3328+ when [...groups, resource, action]
3329+ print "Group:", groups -- prints: {"admin", "users"}
3330+ print "Resource:", resource -- prints: "logs"
3331+ print "Action:", action -- prints: "view"
33323332```
33333333<YueDisplay >
33343334<pre >
33353335segments = ["admin", "users", "logs", "view"]
33363336switch segments
3337- when [...groups, resource, action]
3338- print "Group:", groups -- prints: {"admin", "users"}
3339- print "Resource:", resource -- prints: "logs"
3340- print "Action:", action -- prints: "view"
3337+ when [...groups, resource, action]
3338+ print "Group:", groups -- prints: {"admin", "users"}
3339+ print "Resource:", resource -- prints: "logs"
3340+ print "Action:", action -- prints: "view"
33413341</pre >
33423342</YueDisplay >
33433343
@@ -4228,9 +4228,9 @@ The YueScript compiling function. It compiles the YueScript code to Lua code.
42284228** Signature:**
42294229``` lua
42304230to_lua : function (code : string , config ?: Config ):
4231- --[[ codes]] string | nil ,
4232- --[[ error]] string | nil ,
4233- --[[ globals]] {{string , integer , integer }} | nil
4231+ --[[ codes]] string | nil ,
4232+ --[[ error]] string | nil ,
4233+ --[[ globals]] {{string , integer , integer }} | nil
42344234```
42354235
42364236** Parameters:**
@@ -4353,8 +4353,8 @@ Loads YueScript code from a string into a function.
43534353** Signature:**
43544354``` lua
43554355loadstring : function (input : string , chunkname : string , env : table , config ?: Config ):
4356- --[[ loaded function]] nil | function (...: any ): (any ... ),
4357- --[[ error]] string | nil
4356+ --[[ loaded function]] nil | function (...: any ): (any ... ),
4357+ --[[ error]] string | nil
43584358```
43594359
43604360** Parameters:**
@@ -4384,8 +4384,8 @@ Loads YueScript code from a string into a function.
43844384** Signature:**
43854385``` lua
43864386loadstring : function (input : string , chunkname : string , config ?: Config ):
4387- --[[ loaded function]] nil | function (...: any ): (any ... ),
4388- --[[ error]] string | nil
4387+ --[[ loaded function]] nil | function (...: any ): (any ... ),
4388+ --[[ error]] string | nil
43894389```
43904390
43914391** Parameters:**
@@ -4414,8 +4414,8 @@ Loads YueScript code from a string into a function.
44144414** Signature:**
44154415``` lua
44164416loadstring : function (input : string , config ?: Config ):
4417- --[[ loaded function]] nil | function (...: any ): (any ... ),
4418- --[[ error]] string | nil
4417+ --[[ loaded function]] nil | function (...: any ): (any ... ),
4418+ --[[ error]] string | nil
44194419```
44204420
44214421** Parameters:**
@@ -4443,8 +4443,8 @@ Loads YueScript code from a file into a function.
44434443** Signature:**
44444444``` lua
44454445loadfile : function (filename : string , env : table , config ?: Config ):
4446- nil | function (...: any ): (any ... ),
4447- string | nil
4446+ nil | function (...: any ): (any ... ),
4447+ string | nil
44484448```
44494449
44504450** Parameters:**
@@ -4473,8 +4473,8 @@ Loads YueScript code from a file into a function.
44734473** Signature:**
44744474``` lua
44754475loadfile : function (filename : string , config ?: Config ):
4476- nil | function (...: any ): (any ... ),
4477- string | nil
4476+ nil | function (...: any ): (any ... ),
4477+ string | nil
44784478```
44794479
44804480** Parameters:**
@@ -4730,8 +4730,8 @@ Converts the code to the AST.
47304730** Signature:**
47314731``` lua
47324732to_ast : function (code : string , flattenLevel ?: number , astName ?: string , reserveComment ?: boolean ):
4733- --[[ AST]] AST | nil ,
4734- --[[ error]] nil | string
4733+ --[[ AST]] AST | nil ,
4734+ --[[ error]] nil | string
47354735```
47364736
47374737** Parameters:**
@@ -4911,11 +4911,11 @@ The target Lua version enumeration.
49114911** Signature:**
49124912``` lua
49134913enum LuaTarget
4914- " 5.1"
4915- " 5.2"
4916- " 5.3"
4917- " 5.4"
4918- " 5.5"
4914+ " 5.1"
4915+ " 5.2"
4916+ " 5.3"
4917+ " 5.4"
4918+ " 5.5"
49194919end
49204920```
49214921
0 commit comments