diff options
| author | Li Jin <dragon-fly@qq.com> | 2025-12-04 09:36:42 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2025-12-04 09:36:42 +0800 |
| commit | d7452147eaa1f47520269f881b3d06c4e164dfd3 (patch) | |
| tree | fdfa51c26ba2e9a0759b45eb2be3b4ddfb81ba0c /doc/docs/zh | |
| parent | b3aba7938aee0d4885d9243dc3f2f3d89d9812b6 (diff) | |
| download | yuescript-main.tar.gz yuescript-main.tar.bz2 yuescript-main.zip | |
Diffstat (limited to 'doc/docs/zh')
| -rwxr-xr-x | doc/docs/zh/doc/README.md | 156 |
1 files changed, 78 insertions, 78 deletions
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 |
| 409 | macro Enum = (...) -> | 409 | macro 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 | ||
| 416 | macro BodyType = $Enum( | 416 | macro BodyType = $Enum( |
| 417 | Static | 417 | Static |
| 418 | Dynamic | 418 | Dynamic |
| 419 | Kinematic | 419 | Kinematic |
| 420 | ) | 420 | ) |
| 421 | 421 | ||
| 422 | print "有效的枚举类型:", $BodyType Static | 422 | print "有效的枚举类型:", $BodyType Static |
| @@ -425,16 +425,16 @@ print "有效的枚举类型:", $BodyType Static | |||
| 425 | <YueDisplay> | 425 | <YueDisplay> |
| 426 | <pre> | 426 | <pre> |
| 427 | macro Enum = (...) -> | 427 | macro 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 | ||
| 434 | macro BodyType = $Enum( | 434 | macro BodyType = $Enum( |
| 435 | Static | 435 | Static |
| 436 | Dynamic | 436 | Dynamic |
| 437 | Kinematic | 437 | Kinematic |
| 438 | ) | 438 | ) |
| 439 | 439 | ||
| 440 | print "有效的枚举类型:", $BodyType Static | 440 | print "有效的枚举类型:", $BodyType Static |
| @@ -532,47 +532,47 @@ print 1 <= a <= 10 | |||
| 532 | 532 | ||
| 533 | ```moonscript | 533 | ```moonscript |
| 534 | v = (x) -> | 534 | v = (x) -> |
| 535 | print x | 535 | print x |
| 536 | x | 536 | x |
| 537 | 537 | ||
| 538 | print v(1) < v(2) <= v(3) | 538 | print 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 | ||
| 547 | print v(1) > v(2) <= v(3) | 547 | print 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> |
| 557 | v = (x) -> | 557 | v = (x) -> |
| 558 | print x | 558 | print x |
| 559 | x | 559 | x |
| 560 | 560 | ||
| 561 | print v(1) < v(2) <= v(3) | 561 | print 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 | ||
| 570 | print v(1) > v(2) <= v(3) | 570 | print 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 |
| 619 | parts = | 619 | parts = |
| 620 | * "shoulders" | 620 | * "shoulders" |
| 621 | * "knees" | 621 | * "knees" |
| 622 | lyrics = | 622 | lyrics = |
| 623 | * "head" | 623 | * "head" |
| 624 | * ...parts | 624 | * ...parts |
| 625 | * "and" | 625 | * "and" |
| 626 | * "toes" | 626 | * "toes" |
| 627 | 627 | ||
| 628 | copy = {...other} | 628 | copy = {...other} |
| 629 | 629 | ||
| @@ -634,13 +634,13 @@ merge = {...a, ...b} | |||
| 634 | <YueDisplay> | 634 | <YueDisplay> |
| 635 | <pre> | 635 | <pre> |
| 636 | parts = | 636 | parts = |
| 637 | * "shoulders" | 637 | * "shoulders" |
| 638 | * "knees" | 638 | * "knees" |
| 639 | lyrics = | 639 | lyrics = |
| 640 | * "head" | 640 | * "head" |
| 641 | * ...parts | 641 | * ...parts |
| 642 | * "and" | 642 | * "and" |
| 643 | * "toes" | 643 | * "toes" |
| 644 | 644 | ||
| 645 | copy = {...other} | 645 | copy = {...other} |
| 646 | 646 | ||
| @@ -3285,19 +3285,19 @@ switch tb | |||
| 3285 | ```moonscript | 3285 | ```moonscript |
| 3286 | segments = ["admin", "users", "logs", "view"] | 3286 | segments = ["admin", "users", "logs", "view"] |
| 3287 | switch segments | 3287 | switch 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> |
| 3295 | segments = ["admin", "users", "logs", "view"] | 3295 | segments = ["admin", "users", "logs", "view"] |
| 3296 | switch segments | 3296 | switch 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 |
| 4187 | to_lua: function(code: string, config?: Config): | 4187 | to_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 |
| 4312 | loadstring: function(input: string, chunkname: string, env: table, config?: Config): | 4312 | loadstring: 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 |
| 4343 | loadstring: function(input: string, chunkname: string, config?: Config): | 4343 | loadstring: 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 |
| 4373 | loadstring: function(input: string, config?: Config): | 4373 | loadstring: 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 |
| 4402 | loadfile: function(filename: string, env: table, config?: Config): | 4402 | loadfile: 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 |
| 4432 | loadfile: function(filename: string, config?: Config): | 4432 | loadfile: 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 |
| 4689 | to_ast: function(code: string, flattenLevel?: number, astName?: string, reserveComment?: boolean): | 4689 | to_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 |
| 4870 | enum LuaTarget | 4870 | enum 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" |
| 4876 | end | 4876 | end |
| 4877 | ``` | 4877 | ``` |
| 4878 | 4878 | ||
