diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-12 10:29:07 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-12 10:29:07 +0800 |
| commit | d63779ec0a6f00854f53b48b0f6a67707879b6d1 (patch) | |
| tree | f9d7e736c31601dcfe1781a7f9eef9bfb3e3fed8 | |
| parent | 82e9b379db4eb77f82cf5693e476597feb18e40b (diff) | |
| download | yuescript-d63779ec0a6f00854f53b48b0f6a67707879b6d1.tar.gz yuescript-d63779ec0a6f00854f53b48b0f6a67707879b6d1.tar.bz2 yuescript-d63779ec0a6f00854f53b48b0f6a67707879b6d1.zip | |
Updated docs.
33 files changed, 2386 insertions, 1327 deletions
diff --git a/doc/docs/.vitepress/config.mts b/doc/docs/.vitepress/config.mts index cae1d89..c23301f 100644 --- a/doc/docs/.vitepress/config.mts +++ b/doc/docs/.vitepress/config.mts | |||
| @@ -299,6 +299,7 @@ function createSidebar(basePath: string, locale: SidebarLocale) { | |||
| 299 | text: text.attributes, | 299 | text: text.attributes, |
| 300 | link: `${basePath}/language-basics/attributes`, | 300 | link: `${basePath}/language-basics/attributes`, |
| 301 | }, | 301 | }, |
| 302 | { text: text.module, link: `${basePath}/language-basics/module` }, | ||
| 302 | ], | 303 | ], |
| 303 | }, | 304 | }, |
| 304 | { | 305 | { |
| @@ -389,7 +390,6 @@ function createSidebar(basePath: string, locale: SidebarLocale) { | |||
| 389 | collapsed: true, | 390 | collapsed: true, |
| 390 | items: [ | 391 | items: [ |
| 391 | { text: text.macro, link: `${basePath}/advanced/macro` }, | 392 | { text: text.macro, link: `${basePath}/advanced/macro` }, |
| 392 | { text: text.module, link: `${basePath}/advanced/module` }, | ||
| 393 | { | 393 | { |
| 394 | text: text.lineDecorators, | 394 | text: text.lineDecorators, |
| 395 | link: `${basePath}/advanced/line-decorators`, | 395 | link: `${basePath}/advanced/line-decorators`, |
| @@ -510,6 +510,11 @@ export default defineConfig({ | |||
| 510 | document.head.appendChild(s); | 510 | document.head.appendChild(s); |
| 511 | })();`, | 511 | })();`, |
| 512 | ], | 512 | ], |
| 513 | [ | ||
| 514 | "style", | ||
| 515 | {}, | ||
| 516 | ".dark .vp-code span{color:var(--shiki-dark,inherit)}html:not(.dark) .vp-code span{color:var(--shiki-light,inherit)}", | ||
| 517 | ], | ||
| 513 | ], | 518 | ], |
| 514 | vite: { | 519 | vite: { |
| 515 | publicDir: resolve(__dirname, "public"), | 520 | publicDir: resolve(__dirname, "public"), |
diff --git a/doc/docs/de/doc/advanced/do.md b/doc/docs/de/doc/advanced/do.md index 265a5ba..c6c41cf 100644 --- a/doc/docs/de/doc/advanced/do.md +++ b/doc/docs/de/doc/advanced/do.md | |||
| @@ -20,7 +20,27 @@ print var -- nil hier | |||
| 20 | 20 | ||
| 21 | </YueDisplay> | 21 | </YueDisplay> |
| 22 | 22 | ||
| 23 | YueScripts **do** kann auch als Ausdruck verwendet werden. So kannst du mehrere Zeilen in einem Ausdruck kombinieren. Das Ergebnis des `do`-Ausdrucks ist die letzte Anweisung im Block. | 23 | YueScripts **do** kann auch als Ausdruck verwendet werden. So kannst du mehrere Zeilen in einem Ausdruck kombinieren. Das Ergebnis des `do`-Ausdrucks ist die letzte Anweisung im Block. `do`-Ausdrücke unterstützen die Verwendung von `break`, um den Kontrollfluss zu unterbrechen und mehrere Rückgabewerte vorzeitig zurückzugeben. |
| 24 | |||
| 25 | ```yuescript | ||
| 26 | status, value = do | ||
| 27 | n = 12 | ||
| 28 | if n > 10 | ||
| 29 | break "large", n | ||
| 30 | break "small", n | ||
| 31 | ``` | ||
| 32 | |||
| 33 | <YueDisplay> | ||
| 34 | |||
| 35 | ```yue | ||
| 36 | status, value = do | ||
| 37 | n = 12 | ||
| 38 | if n > 10 | ||
| 39 | break "large", n | ||
| 40 | break "small", n | ||
| 41 | ``` | ||
| 42 | |||
| 43 | </YueDisplay> | ||
| 24 | 44 | ||
| 25 | ```yuescript | 45 | ```yuescript |
| 26 | counter = do | 46 | counter = do |
diff --git a/doc/docs/de/doc/control-flow/for-loop.md b/doc/docs/de/doc/control-flow/for-loop.md index 827d983..16b5418 100644 --- a/doc/docs/de/doc/control-flow/for-loop.md +++ b/doc/docs/de/doc/control-flow/for-loop.md | |||
| @@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20 | |||
| 86 | 86 | ||
| 87 | </YueDisplay> | 87 | </YueDisplay> |
| 88 | 88 | ||
| 89 | Zusätzlich unterstützen `for`-Schleifen `break` mit Rückgabewert, sodass die Schleife selbst als Ausdruck verwendet werden kann, der früh mit einem sinnvollen Ergebnis endet. | 89 | Zusätzlich unterstützen `for`-Schleifen `break` mit Rückgabewerten, sodass die Schleife selbst als Ausdruck verwendet werden kann, der früh mit einem sinnvollen Ergebnis endet. `for`-Ausdrücke unterstützen mehrere `break`-Werte. |
| 90 | 90 | ||
| 91 | Beispiel: die erste Zahl größer als 10 finden: | 91 | Beispiel: die erste Zahl größer als 10 finden: |
| 92 | 92 | ||
| @@ -106,6 +106,20 @@ first_large = for n in *numbers | |||
| 106 | 106 | ||
| 107 | Diese `break`-mit-Wert-Syntax ermöglicht knappe und ausdrucksstarke Such- bzw. Early-Exit-Muster direkt in Schleifenausdrücken. | 107 | Diese `break`-mit-Wert-Syntax ermöglicht knappe und ausdrucksstarke Such- bzw. Early-Exit-Muster direkt in Schleifenausdrücken. |
| 108 | 108 | ||
| 109 | ```yuescript | ||
| 110 | key, score = for k, v in pairs data | ||
| 111 | break k, v * 10 if k == "target" | ||
| 112 | ``` | ||
| 113 | |||
| 114 | <YueDisplay> | ||
| 115 | |||
| 116 | ```yue | ||
| 117 | key, score = for k, v in pairs data | ||
| 118 | break k, v * 10 if k == "target" | ||
| 119 | ``` | ||
| 120 | |||
| 121 | </YueDisplay> | ||
| 122 | |||
| 109 | Du kannst Werte auch filtern, indem du den `for`-Ausdruck mit `continue` kombinierst. | 123 | Du kannst Werte auch filtern, indem du den `for`-Ausdruck mit `continue` kombinierst. |
| 110 | 124 | ||
| 111 | `for`-Schleifen am Ende eines Funktionsrumpfs werden nicht in eine Tabelle für einen Rückgabewert gesammelt (stattdessen gibt die Funktion `nil` zurück). Du kannst entweder explizit `return` verwenden oder die Schleife in eine Listen-Comprehension umwandeln. | 125 | `for`-Schleifen am Ende eines Funktionsrumpfs werden nicht in eine Tabelle für einen Rückgabewert gesammelt (stattdessen gibt die Funktion `nil` zurück). Du kannst entweder explizit `return` verwenden oder die Schleife in eine Listen-Comprehension umwandeln. |
diff --git a/doc/docs/de/doc/control-flow/while-loop.md b/doc/docs/de/doc/control-flow/while-loop.md index 6d9f089..98776ec 100644 --- a/doc/docs/de/doc/control-flow/while-loop.md +++ b/doc/docs/de/doc/control-flow/while-loop.md | |||
| @@ -45,7 +45,25 @@ until running == false do my_function! | |||
| 45 | 45 | ||
| 46 | </YueDisplay> | 46 | </YueDisplay> |
| 47 | 47 | ||
| 48 | Wie bei `for`-Schleifen kann die `while`-Schleife auch als Ausdruck verwendet werden. Damit eine Funktion den akkumulierten Wert einer `while`-Schleife zurückgibt, muss die Anweisung explizit mit `return` zurückgegeben werden. | 48 | Wie bei `for`-Schleifen kann die `while`-Schleife auch als Ausdruck verwendet werden. `while`- und `until`-Ausdrücke unterstützen `break` mit mehreren Rückgabewerten. |
| 49 | |||
| 50 | ```yuescript | ||
| 51 | value, doubled = while true | ||
| 52 | n = get_next! | ||
| 53 | break n, n * 2 if n > 10 | ||
| 54 | ``` | ||
| 55 | |||
| 56 | <YueDisplay> | ||
| 57 | |||
| 58 | ```yue | ||
| 59 | value, doubled = while true | ||
| 60 | n = get_next! | ||
| 61 | break n, n * 2 if n > 10 | ||
| 62 | ``` | ||
| 63 | |||
| 64 | </YueDisplay> | ||
| 65 | |||
| 66 | Damit eine Funktion den akkumulierten Wert einer `while`-Schleife zurückgibt, muss die Anweisung explizit mit `return` zurückgegeben werden. | ||
| 49 | 67 | ||
| 50 | ## Repeat-Schleife | 68 | ## Repeat-Schleife |
| 51 | 69 | ||
| @@ -70,3 +88,25 @@ until i == 0 | |||
| 70 | ``` | 88 | ``` |
| 71 | 89 | ||
| 72 | </YueDisplay> | 90 | </YueDisplay> |
| 91 | |||
| 92 | `repeat`-Ausdrücke unterstützen ebenfalls `break` mit mehreren Rückgabewerten: | ||
| 93 | |||
| 94 | ```yuescript | ||
| 95 | i = 1 | ||
| 96 | value, scaled = repeat | ||
| 97 | break i, i * 100 if i > 3 | ||
| 98 | i += 1 | ||
| 99 | until false | ||
| 100 | ``` | ||
| 101 | |||
| 102 | <YueDisplay> | ||
| 103 | |||
| 104 | ```yue | ||
| 105 | i = 1 | ||
| 106 | value, scaled = repeat | ||
| 107 | break i, i * 100 if i > 3 | ||
| 108 | i += 1 | ||
| 109 | until false | ||
| 110 | ``` | ||
| 111 | |||
| 112 | </YueDisplay> | ||
diff --git a/doc/docs/de/doc/advanced/module.md b/doc/docs/de/doc/language-basics/module.md index f20deec..f20deec 100644 --- a/doc/docs/de/doc/advanced/module.md +++ b/doc/docs/de/doc/language-basics/module.md | |||
diff --git a/doc/docs/de/doc/objects/with-statement.md b/doc/docs/de/doc/objects/with-statement.md index adeeda6..f299902 100644 --- a/doc/docs/de/doc/objects/with-statement.md +++ b/doc/docs/de/doc/objects/with-statement.md | |||
| @@ -44,6 +44,50 @@ file = with File "Lieblingsessen.txt" | |||
| 44 | 44 | ||
| 45 | </YueDisplay> | 45 | </YueDisplay> |
| 46 | 46 | ||
| 47 | `with`-Ausdrücke unterstützen `break` mit genau einem Wert: | ||
| 48 | |||
| 49 | ```yuescript | ||
| 50 | result = with obj | ||
| 51 | break .value | ||
| 52 | ``` | ||
| 53 | |||
| 54 | <YueDisplay> | ||
| 55 | |||
| 56 | ```yue | ||
| 57 | result = with obj | ||
| 58 | break .value | ||
| 59 | ``` | ||
| 60 | |||
| 61 | </YueDisplay> | ||
| 62 | |||
| 63 | Sobald `break value` in `with` verwendet wird, gibt der `with`-Ausdruck nicht mehr sein Zielobjekt zurück, sondern den von `break` gelieferten Wert. | ||
| 64 | |||
| 65 | ```yuescript | ||
| 66 | a = with obj | ||
| 67 | .x = 1 | ||
| 68 | -- a ist obj | ||
| 69 | |||
| 70 | b = with obj | ||
| 71 | break .x | ||
| 72 | -- b ist .x, nicht obj | ||
| 73 | ``` | ||
| 74 | |||
| 75 | <YueDisplay> | ||
| 76 | |||
| 77 | ```yue | ||
| 78 | a = with obj | ||
| 79 | .x = 1 | ||
| 80 | -- a ist obj | ||
| 81 | |||
| 82 | b = with obj | ||
| 83 | break .x | ||
| 84 | -- b ist .x, nicht obj | ||
| 85 | ``` | ||
| 86 | |||
| 87 | </YueDisplay> | ||
| 88 | |||
| 89 | Im Unterschied zu `for` / `while` / `repeat` / `do` unterstützt `with` nur einen `break`-Wert. | ||
| 90 | |||
| 47 | Oder … | 91 | Oder … |
| 48 | 92 | ||
| 49 | ```yuescript | 93 | ```yuescript |
diff --git a/doc/docs/doc/advanced/do.md b/doc/docs/doc/advanced/do.md index c4b3e30..e13b025 100644 --- a/doc/docs/doc/advanced/do.md +++ b/doc/docs/doc/advanced/do.md | |||
| @@ -22,6 +22,28 @@ print var -- nil here | |||
| 22 | 22 | ||
| 23 | YueScript's **do** can also be used an expression . Allowing you to combine multiple lines into one. The result of the do expression is the last statement in its body. | 23 | YueScript's **do** can also be used an expression . Allowing you to combine multiple lines into one. The result of the do expression is the last statement in its body. |
| 24 | 24 | ||
| 25 | `do` expressions also support using `break` to interrupt control flow and return multiple values early: | ||
| 26 | |||
| 27 | ```yuescript | ||
| 28 | status, value = do | ||
| 29 | n = 12 | ||
| 30 | if n > 10 | ||
| 31 | break "large", n | ||
| 32 | break "small", n | ||
| 33 | ``` | ||
| 34 | |||
| 35 | <YueDisplay> | ||
| 36 | |||
| 37 | ```yue | ||
| 38 | status, value = do | ||
| 39 | n = 12 | ||
| 40 | if n > 10 | ||
| 41 | break "large", n | ||
| 42 | break "small", n | ||
| 43 | ``` | ||
| 44 | |||
| 45 | </YueDisplay> | ||
| 46 | |||
| 25 | ```yuescript | 47 | ```yuescript |
| 26 | counter = do | 48 | counter = do |
| 27 | i = 0 | 49 | i = 0 |
diff --git a/doc/docs/doc/control-flow/for-loop.md b/doc/docs/doc/control-flow/for-loop.md index b92e94e..763e6a7 100644 --- a/doc/docs/doc/control-flow/for-loop.md +++ b/doc/docs/doc/control-flow/for-loop.md | |||
| @@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20 | |||
| 86 | 86 | ||
| 87 | </YueDisplay> | 87 | </YueDisplay> |
| 88 | 88 | ||
| 89 | In addition, for loops support break with a return value, allowing the loop itself to be used as an expression that exits early with a meaningful result. | 89 | In addition, for loops support break with return values, allowing the loop itself to be used as an expression that exits early with meaningful results. |
| 90 | 90 | ||
| 91 | For example, to find the first number greater than 10: | 91 | For example, to find the first number greater than 10: |
| 92 | 92 | ||
| @@ -106,6 +106,22 @@ first_large = for n in *numbers | |||
| 106 | 106 | ||
| 107 | This break-with-value syntax enables concise and expressive search or early-exit patterns directly within loop expressions. | 107 | This break-with-value syntax enables concise and expressive search or early-exit patterns directly within loop expressions. |
| 108 | 108 | ||
| 109 | For loop expressions can break with multiple values: | ||
| 110 | |||
| 111 | ```yuescript | ||
| 112 | key, score = for k, v in pairs data | ||
| 113 | break k, v * 10 if k == "target" | ||
| 114 | ``` | ||
| 115 | |||
| 116 | <YueDisplay> | ||
| 117 | |||
| 118 | ```yue | ||
| 119 | key, score = for k, v in pairs data | ||
| 120 | break k, v * 10 if k == "target" | ||
| 121 | ``` | ||
| 122 | |||
| 123 | </YueDisplay> | ||
| 124 | |||
| 109 | You can also filter values by combining the for loop expression with the continue statement. | 125 | You can also filter values by combining the for loop expression with the continue statement. |
| 110 | 126 | ||
| 111 | For loops at the end of a function body are not accumulated into a table for a return value (Instead the function will return nil). Either an explicit return statement can be used, or the loop can be converted into a list comprehension. | 127 | For loops at the end of a function body are not accumulated into a table for a return value (Instead the function will return nil). Either an explicit return statement can be used, or the loop can be converted into a list comprehension. |
diff --git a/doc/docs/doc/control-flow/while-loop.md b/doc/docs/doc/control-flow/while-loop.md index 02e82d6..0dff342 100644 --- a/doc/docs/doc/control-flow/while-loop.md +++ b/doc/docs/doc/control-flow/while-loop.md | |||
| @@ -45,7 +45,25 @@ until running == false do my_function! | |||
| 45 | 45 | ||
| 46 | </YueDisplay> | 46 | </YueDisplay> |
| 47 | 47 | ||
| 48 | Like for loops, the while loop can also be used an expression. Additionally, for a function to return the accumulated value of a while loop, the statement must be explicitly returned. | 48 | Like for loops, the while loop can also be used as an expression. While and until loop expressions support `break` with multiple return values. |
| 49 | |||
| 50 | ```yuescript | ||
| 51 | value, doubled = while true | ||
| 52 | n = get_next! | ||
| 53 | break n, n * 2 if n > 10 | ||
| 54 | ``` | ||
| 55 | |||
| 56 | <YueDisplay> | ||
| 57 | |||
| 58 | ```yue | ||
| 59 | value, doubled = while true | ||
| 60 | n = get_next! | ||
| 61 | break n, n * 2 if n > 10 | ||
| 62 | ``` | ||
| 63 | |||
| 64 | </YueDisplay> | ||
| 65 | |||
| 66 | Additionally, for a function to return the accumulated value of a while loop, the statement must be explicitly returned. | ||
| 49 | 67 | ||
| 50 | ## Repeat Loop | 68 | ## Repeat Loop |
| 51 | 69 | ||
| @@ -70,3 +88,25 @@ until i == 0 | |||
| 70 | ``` | 88 | ``` |
| 71 | 89 | ||
| 72 | </YueDisplay> | 90 | </YueDisplay> |
| 91 | |||
| 92 | Repeat loop expressions also support `break` with multiple return values: | ||
| 93 | |||
| 94 | ```yuescript | ||
| 95 | i = 1 | ||
| 96 | value, scaled = repeat | ||
| 97 | break i, i * 100 if i > 3 | ||
| 98 | i += 1 | ||
| 99 | until false | ||
| 100 | ``` | ||
| 101 | |||
| 102 | <YueDisplay> | ||
| 103 | |||
| 104 | ```yue | ||
| 105 | i = 1 | ||
| 106 | value, scaled = repeat | ||
| 107 | break i, i * 100 if i > 3 | ||
| 108 | i += 1 | ||
| 109 | until false | ||
| 110 | ``` | ||
| 111 | |||
| 112 | </YueDisplay> | ||
diff --git a/doc/docs/doc/advanced/module.md b/doc/docs/doc/language-basics/module.md index 0ba2d90..0ba2d90 100644 --- a/doc/docs/doc/advanced/module.md +++ b/doc/docs/doc/language-basics/module.md | |||
diff --git a/doc/docs/doc/objects/with-statement.md b/doc/docs/doc/objects/with-statement.md index 5d7fea3..9173f9c 100644 --- a/doc/docs/doc/objects/with-statement.md +++ b/doc/docs/doc/objects/with-statement.md | |||
| @@ -44,6 +44,50 @@ file = with File "favorite_foods.txt" | |||
| 44 | 44 | ||
| 45 | </YueDisplay> | 45 | </YueDisplay> |
| 46 | 46 | ||
| 47 | `with` expressions support `break` with one value: | ||
| 48 | |||
| 49 | ```yuescript | ||
| 50 | result = with obj | ||
| 51 | break .value | ||
| 52 | ``` | ||
| 53 | |||
| 54 | <YueDisplay> | ||
| 55 | |||
| 56 | ```yue | ||
| 57 | result = with obj | ||
| 58 | break .value | ||
| 59 | ``` | ||
| 60 | |||
| 61 | </YueDisplay> | ||
| 62 | |||
| 63 | After `break value` is used inside `with`, the `with` expression no longer returns its target object. Instead, it returns the value from `break`. | ||
| 64 | |||
| 65 | ```yuescript | ||
| 66 | a = with obj | ||
| 67 | .x = 1 | ||
| 68 | -- a is obj | ||
| 69 | |||
| 70 | b = with obj | ||
| 71 | break .x | ||
| 72 | -- b is .x, not obj | ||
| 73 | ``` | ||
| 74 | |||
| 75 | <YueDisplay> | ||
| 76 | |||
| 77 | ```yue | ||
| 78 | a = with obj | ||
| 79 | .x = 1 | ||
| 80 | -- a is obj | ||
| 81 | |||
| 82 | b = with obj | ||
| 83 | break .x | ||
| 84 | -- b is .x, not obj | ||
| 85 | ``` | ||
| 86 | |||
| 87 | </YueDisplay> | ||
| 88 | |||
| 89 | Unlike `for` / `while` / `repeat` / `do`, `with` only supports one break value. | ||
| 90 | |||
| 47 | Or… | 91 | Or… |
| 48 | 92 | ||
| 49 | ```yuescript | 93 | ```yuescript |
diff --git a/doc/docs/id-id/doc/advanced/do.md b/doc/docs/id-id/doc/advanced/do.md index ac75531..52ef5dc 100644 --- a/doc/docs/id-id/doc/advanced/do.md +++ b/doc/docs/id-id/doc/advanced/do.md | |||
| @@ -20,7 +20,27 @@ print var -- nil di sini | |||
| 20 | 20 | ||
| 21 | </YueDisplay> | 21 | </YueDisplay> |
| 22 | 22 | ||
| 23 | `do` di YueScript juga bisa digunakan sebagai ekspresi, memungkinkan Anda menggabungkan beberapa baris menjadi satu. Hasil ekspresi `do` adalah pernyataan terakhir di badannya. | 23 | `do` di YueScript juga bisa digunakan sebagai ekspresi, memungkinkan Anda menggabungkan beberapa baris menjadi satu. Hasil ekspresi `do` adalah pernyataan terakhir di badannya. Ekspresi `do` mendukung penggunaan `break` untuk memutus alur eksekusi dan mengembalikan banyak nilai lebih awal. |
| 24 | |||
| 25 | ```yuescript | ||
| 26 | status, value = do | ||
| 27 | n = 12 | ||
| 28 | if n > 10 | ||
| 29 | break "large", n | ||
| 30 | break "small", n | ||
| 31 | ``` | ||
| 32 | |||
| 33 | <YueDisplay> | ||
| 34 | |||
| 35 | ```yue | ||
| 36 | status, value = do | ||
| 37 | n = 12 | ||
| 38 | if n > 10 | ||
| 39 | break "large", n | ||
| 40 | break "small", n | ||
| 41 | ``` | ||
| 42 | |||
| 43 | </YueDisplay> | ||
| 24 | 44 | ||
| 25 | ```yuescript | 45 | ```yuescript |
| 26 | counter = do | 46 | counter = do |
diff --git a/doc/docs/id-id/doc/control-flow/for-loop.md b/doc/docs/id-id/doc/control-flow/for-loop.md index 65386f7..3835cce 100644 --- a/doc/docs/id-id/doc/control-flow/for-loop.md +++ b/doc/docs/id-id/doc/control-flow/for-loop.md | |||
| @@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20 | |||
| 86 | 86 | ||
| 87 | </YueDisplay> | 87 | </YueDisplay> |
| 88 | 88 | ||
| 89 | Selain itu, loop for mendukung break dengan nilai kembalian, sehingga loop itu sendiri bisa dipakai sebagai ekspresi yang keluar lebih awal dengan hasil bermakna. | 89 | Selain itu, loop for mendukung break dengan nilai kembalian, sehingga loop itu sendiri bisa dipakai sebagai ekspresi yang keluar lebih awal dengan hasil bermakna. Ekspresi `for` mendukung `break` dengan banyak nilai. |
| 90 | 90 | ||
| 91 | Contohnya, untuk menemukan angka pertama yang lebih besar dari 10: | 91 | Contohnya, untuk menemukan angka pertama yang lebih besar dari 10: |
| 92 | 92 | ||
| @@ -106,6 +106,20 @@ first_large = for n in *numbers | |||
| 106 | 106 | ||
| 107 | Sintaks break-dengan-nilai ini memungkinkan pola pencarian atau keluar-lebih-awal yang ringkas langsung di dalam ekspresi loop. | 107 | Sintaks break-dengan-nilai ini memungkinkan pola pencarian atau keluar-lebih-awal yang ringkas langsung di dalam ekspresi loop. |
| 108 | 108 | ||
| 109 | ```yuescript | ||
| 110 | key, score = for k, v in pairs data | ||
| 111 | break k, v * 10 if k == "target" | ||
| 112 | ``` | ||
| 113 | |||
| 114 | <YueDisplay> | ||
| 115 | |||
| 116 | ```yue | ||
| 117 | key, score = for k, v in pairs data | ||
| 118 | break k, v * 10 if k == "target" | ||
| 119 | ``` | ||
| 120 | |||
| 121 | </YueDisplay> | ||
| 122 | |||
| 109 | Anda juga bisa memfilter nilai dengan menggabungkan ekspresi for dengan pernyataan continue. | 123 | Anda juga bisa memfilter nilai dengan menggabungkan ekspresi for dengan pernyataan continue. |
| 110 | 124 | ||
| 111 | Loop for di akhir badan fungsi tidak diakumulasikan menjadi tabel untuk nilai kembalian (sebaliknya fungsi akan mengembalikan nil). Gunakan pernyataan return eksplisit, atau ubah loop menjadi list comprehension. | 125 | Loop for di akhir badan fungsi tidak diakumulasikan menjadi tabel untuk nilai kembalian (sebaliknya fungsi akan mengembalikan nil). Gunakan pernyataan return eksplisit, atau ubah loop menjadi list comprehension. |
diff --git a/doc/docs/id-id/doc/control-flow/while-loop.md b/doc/docs/id-id/doc/control-flow/while-loop.md index 3e302cc..0c3a28d 100644 --- a/doc/docs/id-id/doc/control-flow/while-loop.md +++ b/doc/docs/id-id/doc/control-flow/while-loop.md | |||
| @@ -45,7 +45,25 @@ until running == false do my_function! | |||
| 45 | 45 | ||
| 46 | </YueDisplay> | 46 | </YueDisplay> |
| 47 | 47 | ||
| 48 | Seperti loop for, loop while juga bisa digunakan sebagai ekspresi. Selain itu, agar sebuah fungsi mengembalikan nilai akumulasi dari loop while, pernyataannya harus di-return secara eksplisit. | 48 | Seperti loop for, loop while juga bisa digunakan sebagai ekspresi. Ekspresi `while` dan `until` mendukung `break` dengan banyak nilai. |
| 49 | |||
| 50 | ```yuescript | ||
| 51 | value, doubled = while true | ||
| 52 | n = get_next! | ||
| 53 | break n, n * 2 if n > 10 | ||
| 54 | ``` | ||
| 55 | |||
| 56 | <YueDisplay> | ||
| 57 | |||
| 58 | ```yue | ||
| 59 | value, doubled = while true | ||
| 60 | n = get_next! | ||
| 61 | break n, n * 2 if n > 10 | ||
| 62 | ``` | ||
| 63 | |||
| 64 | </YueDisplay> | ||
| 65 | |||
| 66 | Selain itu, agar sebuah fungsi mengembalikan nilai akumulasi dari loop while, pernyataannya harus di-return secara eksplisit. | ||
| 49 | 67 | ||
| 50 | ## Repeat Loop | 68 | ## Repeat Loop |
| 51 | 69 | ||
| @@ -70,3 +88,25 @@ until i == 0 | |||
| 70 | ``` | 88 | ``` |
| 71 | 89 | ||
| 72 | </YueDisplay> | 90 | </YueDisplay> |
| 91 | |||
| 92 | Ekspresi `repeat` juga mendukung `break` dengan banyak nilai: | ||
| 93 | |||
| 94 | ```yuescript | ||
| 95 | i = 1 | ||
| 96 | value, scaled = repeat | ||
| 97 | break i, i * 100 if i > 3 | ||
| 98 | i += 1 | ||
| 99 | until false | ||
| 100 | ``` | ||
| 101 | |||
| 102 | <YueDisplay> | ||
| 103 | |||
| 104 | ```yue | ||
| 105 | i = 1 | ||
| 106 | value, scaled = repeat | ||
| 107 | break i, i * 100 if i > 3 | ||
| 108 | i += 1 | ||
| 109 | until false | ||
| 110 | ``` | ||
| 111 | |||
| 112 | </YueDisplay> | ||
diff --git a/doc/docs/id-id/doc/advanced/module.md b/doc/docs/id-id/doc/language-basics/module.md index 103e3f6..103e3f6 100644 --- a/doc/docs/id-id/doc/advanced/module.md +++ b/doc/docs/id-id/doc/language-basics/module.md | |||
diff --git a/doc/docs/id-id/doc/objects/with-statement.md b/doc/docs/id-id/doc/objects/with-statement.md index 96a3efd..b3dd520 100644 --- a/doc/docs/id-id/doc/objects/with-statement.md +++ b/doc/docs/id-id/doc/objects/with-statement.md | |||
| @@ -44,6 +44,50 @@ file = with File "favorite_foods.txt" | |||
| 44 | 44 | ||
| 45 | </YueDisplay> | 45 | </YueDisplay> |
| 46 | 46 | ||
| 47 | Ekspresi `with` mendukung `break` dengan satu nilai: | ||
| 48 | |||
| 49 | ```yuescript | ||
| 50 | result = with obj | ||
| 51 | break .value | ||
| 52 | ``` | ||
| 53 | |||
| 54 | <YueDisplay> | ||
| 55 | |||
| 56 | ```yue | ||
| 57 | result = with obj | ||
| 58 | break .value | ||
| 59 | ``` | ||
| 60 | |||
| 61 | </YueDisplay> | ||
| 62 | |||
| 63 | Setelah `break value` digunakan di dalam `with`, ekspresi `with` tidak lagi mengembalikan objek targetnya, melainkan mengembalikan nilai dari `break`. | ||
| 64 | |||
| 65 | ```yuescript | ||
| 66 | a = with obj | ||
| 67 | .x = 1 | ||
| 68 | -- a adalah obj | ||
| 69 | |||
| 70 | b = with obj | ||
| 71 | break .x | ||
| 72 | -- b adalah .x, bukan obj | ||
| 73 | ``` | ||
| 74 | |||
| 75 | <YueDisplay> | ||
| 76 | |||
| 77 | ```yue | ||
| 78 | a = with obj | ||
| 79 | .x = 1 | ||
| 80 | -- a adalah obj | ||
| 81 | |||
| 82 | b = with obj | ||
| 83 | break .x | ||
| 84 | -- b adalah .x, bukan obj | ||
| 85 | ``` | ||
| 86 | |||
| 87 | </YueDisplay> | ||
| 88 | |||
| 89 | Berbeda dari `for` / `while` / `repeat` / `do`, `with` hanya mendukung satu nilai `break`. | ||
| 90 | |||
| 47 | Atau… | 91 | Atau… |
| 48 | 92 | ||
| 49 | ```yuescript | 93 | ```yuescript |
diff --git a/doc/docs/pt-br/doc/advanced/do.md b/doc/docs/pt-br/doc/advanced/do.md index 503c551..aaf2c69 100644 --- a/doc/docs/pt-br/doc/advanced/do.md +++ b/doc/docs/pt-br/doc/advanced/do.md | |||
| @@ -20,7 +20,27 @@ print var -- nil aqui | |||
| 20 | 20 | ||
| 21 | </YueDisplay> | 21 | </YueDisplay> |
| 22 | 22 | ||
| 23 | O **do** do YueScript também pode ser usado como expressão. Permitindo combinar múltiplas linhas em uma. O resultado da expressão do é a última instrução em seu corpo. | 23 | O **do** do YueScript também pode ser usado como expressão. Permitindo combinar múltiplas linhas em uma. O resultado da expressão do é a última instrução em seu corpo. Expressões `do` suportam usar `break` para interromper o fluxo de execução e retornar múltiplos valores antecipadamente. |
| 24 | |||
| 25 | ```yuescript | ||
| 26 | status, value = do | ||
| 27 | n = 12 | ||
| 28 | if n > 10 | ||
| 29 | break "large", n | ||
| 30 | break "small", n | ||
| 31 | ``` | ||
| 32 | |||
| 33 | <YueDisplay> | ||
| 34 | |||
| 35 | ```yue | ||
| 36 | status, value = do | ||
| 37 | n = 12 | ||
| 38 | if n > 10 | ||
| 39 | break "large", n | ||
| 40 | break "small", n | ||
| 41 | ``` | ||
| 42 | |||
| 43 | </YueDisplay> | ||
| 24 | 44 | ||
| 25 | ```yuescript | 45 | ```yuescript |
| 26 | counter = do | 46 | counter = do |
diff --git a/doc/docs/pt-br/doc/control-flow/for-loop.md b/doc/docs/pt-br/doc/control-flow/for-loop.md index 4c99e6d..de5f9c2 100644 --- a/doc/docs/pt-br/doc/control-flow/for-loop.md +++ b/doc/docs/pt-br/doc/control-flow/for-loop.md | |||
| @@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20 | |||
| 86 | 86 | ||
| 87 | </YueDisplay> | 87 | </YueDisplay> |
| 88 | 88 | ||
| 89 | Além disso, os loops for suportam break com valor de retorno, permitindo que o próprio loop seja usado como expressão que sai antecipadamente com um resultado significativo. | 89 | Além disso, os loops for suportam break com valores de retorno, permitindo que o próprio loop seja usado como expressão que sai antecipadamente com um resultado significativo. Expressões `for` suportam `break` com múltiplos valores. |
| 90 | 90 | ||
| 91 | Por exemplo, para encontrar o primeiro número maior que 10: | 91 | Por exemplo, para encontrar o primeiro número maior que 10: |
| 92 | 92 | ||
| @@ -106,6 +106,20 @@ first_large = for n in *numbers | |||
| 106 | 106 | ||
| 107 | Esta sintaxe de break-com-valor permite padrões concisos e expressivos de busca ou saída antecipada diretamente em expressões de loop. | 107 | Esta sintaxe de break-com-valor permite padrões concisos e expressivos de busca ou saída antecipada diretamente em expressões de loop. |
| 108 | 108 | ||
| 109 | ```yuescript | ||
| 110 | key, score = for k, v in pairs data | ||
| 111 | break k, v * 10 if k == "target" | ||
| 112 | ``` | ||
| 113 | |||
| 114 | <YueDisplay> | ||
| 115 | |||
| 116 | ```yue | ||
| 117 | key, score = for k, v in pairs data | ||
| 118 | break k, v * 10 if k == "target" | ||
| 119 | ``` | ||
| 120 | |||
| 121 | </YueDisplay> | ||
| 122 | |||
| 109 | Você também pode filtrar valores combinando a expressão do loop for com a instrução continue. | 123 | Você também pode filtrar valores combinando a expressão do loop for com a instrução continue. |
| 110 | 124 | ||
| 111 | Loops for no final do corpo de uma função não são acumulados em uma tabela para valor de retorno (em vez disso, a função retornará nil). Uma instrução return explícita pode ser usada, ou o loop pode ser convertido em compreensão de lista. | 125 | Loops for no final do corpo de uma função não são acumulados em uma tabela para valor de retorno (em vez disso, a função retornará nil). Uma instrução return explícita pode ser usada, ou o loop pode ser convertido em compreensão de lista. |
diff --git a/doc/docs/pt-br/doc/control-flow/while-loop.md b/doc/docs/pt-br/doc/control-flow/while-loop.md index 2deb5aa..38df05a 100644 --- a/doc/docs/pt-br/doc/control-flow/while-loop.md +++ b/doc/docs/pt-br/doc/control-flow/while-loop.md | |||
| @@ -45,7 +45,25 @@ until running == false do my_function! | |||
| 45 | 45 | ||
| 46 | </YueDisplay> | 46 | </YueDisplay> |
| 47 | 47 | ||
| 48 | Como os loops for, o loop while também pode ser usado como expressão. Além disso, para uma função retornar o valor acumulado de um loop while, a instrução deve ser explicitamente retornada. | 48 | Como os loops for, o loop while também pode ser usado como expressão. Expressões `while` e `until` suportam `break` com múltiplos valores. |
| 49 | |||
| 50 | ```yuescript | ||
| 51 | value, doubled = while true | ||
| 52 | n = get_next! | ||
| 53 | break n, n * 2 if n > 10 | ||
| 54 | ``` | ||
| 55 | |||
| 56 | <YueDisplay> | ||
| 57 | |||
| 58 | ```yue | ||
| 59 | value, doubled = while true | ||
| 60 | n = get_next! | ||
| 61 | break n, n * 2 if n > 10 | ||
| 62 | ``` | ||
| 63 | |||
| 64 | </YueDisplay> | ||
| 65 | |||
| 66 | Além disso, para uma função retornar o valor acumulado de um loop while, a instrução deve ser explicitamente retornada. | ||
| 49 | 67 | ||
| 50 | ## Loop Repeat | 68 | ## Loop Repeat |
| 51 | 69 | ||
| @@ -70,3 +88,25 @@ until i == 0 | |||
| 70 | ``` | 88 | ``` |
| 71 | 89 | ||
| 72 | </YueDisplay> | 90 | </YueDisplay> |
| 91 | |||
| 92 | Expressões `repeat` também suportam `break` com múltiplos valores: | ||
| 93 | |||
| 94 | ```yuescript | ||
| 95 | i = 1 | ||
| 96 | value, scaled = repeat | ||
| 97 | break i, i * 100 if i > 3 | ||
| 98 | i += 1 | ||
| 99 | until false | ||
| 100 | ``` | ||
| 101 | |||
| 102 | <YueDisplay> | ||
| 103 | |||
| 104 | ```yue | ||
| 105 | i = 1 | ||
| 106 | value, scaled = repeat | ||
| 107 | break i, i * 100 if i > 3 | ||
| 108 | i += 1 | ||
| 109 | until false | ||
| 110 | ``` | ||
| 111 | |||
| 112 | </YueDisplay> | ||
diff --git a/doc/docs/pt-br/doc/advanced/module.md b/doc/docs/pt-br/doc/language-basics/module.md index ed13107..ed13107 100644 --- a/doc/docs/pt-br/doc/advanced/module.md +++ b/doc/docs/pt-br/doc/language-basics/module.md | |||
diff --git a/doc/docs/pt-br/doc/objects/with-statement.md b/doc/docs/pt-br/doc/objects/with-statement.md index e5a56e5..38efee7 100644 --- a/doc/docs/pt-br/doc/objects/with-statement.md +++ b/doc/docs/pt-br/doc/objects/with-statement.md | |||
| @@ -44,6 +44,50 @@ file = with File "favorite_foods.txt" | |||
| 44 | 44 | ||
| 45 | </YueDisplay> | 45 | </YueDisplay> |
| 46 | 46 | ||
| 47 | Expressões `with` suportam `break` com um valor: | ||
| 48 | |||
| 49 | ```yuescript | ||
| 50 | result = with obj | ||
| 51 | break .value | ||
| 52 | ``` | ||
| 53 | |||
| 54 | <YueDisplay> | ||
| 55 | |||
| 56 | ```yue | ||
| 57 | result = with obj | ||
| 58 | break .value | ||
| 59 | ``` | ||
| 60 | |||
| 61 | </YueDisplay> | ||
| 62 | |||
| 63 | Depois que `break value` é usado dentro de `with`, a expressão `with` deixa de retornar seu objeto-alvo e passa a retornar o valor de `break`. | ||
| 64 | |||
| 65 | ```yuescript | ||
| 66 | a = with obj | ||
| 67 | .x = 1 | ||
| 68 | -- a é obj | ||
| 69 | |||
| 70 | b = with obj | ||
| 71 | break .x | ||
| 72 | -- b é .x, não obj | ||
| 73 | ``` | ||
| 74 | |||
| 75 | <YueDisplay> | ||
| 76 | |||
| 77 | ```yue | ||
| 78 | a = with obj | ||
| 79 | .x = 1 | ||
| 80 | -- a é obj | ||
| 81 | |||
| 82 | b = with obj | ||
| 83 | break .x | ||
| 84 | -- b é .x, não obj | ||
| 85 | ``` | ||
| 86 | |||
| 87 | </YueDisplay> | ||
| 88 | |||
| 89 | Diferente de `for` / `while` / `repeat` / `do`, `with` suporta apenas um valor de `break`. | ||
| 90 | |||
| 47 | Ou… | 91 | Ou… |
| 48 | 92 | ||
| 49 | ```yuescript | 93 | ```yuescript |
diff --git a/doc/docs/zh/doc/advanced/do.md b/doc/docs/zh/doc/advanced/do.md index a2d5d19..b3f61af 100644 --- a/doc/docs/zh/doc/advanced/do.md +++ b/doc/docs/zh/doc/advanced/do.md | |||
| @@ -20,7 +20,27 @@ print var -- 这里是nil | |||
| 20 | 20 | ||
| 21 | </YueDisplay> | 21 | </YueDisplay> |
| 22 | 22 | ||
| 23 |   月之脚本的 **do** 也可以用作表达式。允许你将多行代码的处理合并为一个表达式,并将 do 语句代码块的最后一个语句作为表达式返回的结果。 | 23 |   月之脚本的 **do** 也可以用作表达式。允许你将多行代码的处理合并为一个表达式,并将 do 语句代码块的最后一个语句作为表达式返回的结果。`do` 表达式支持通过 `break` 打断执行流并提前返回多个值。 |
| 24 | |||
| 25 | ```yuescript | ||
| 26 | status, value = do | ||
| 27 | n = 12 | ||
| 28 | if n > 10 | ||
| 29 | break "large", n | ||
| 30 | break "small", n | ||
| 31 | ``` | ||
| 32 | |||
| 33 | <YueDisplay> | ||
| 34 | |||
| 35 | ```yue | ||
| 36 | status, value = do | ||
| 37 | n = 12 | ||
| 38 | if n > 10 | ||
| 39 | break "large", n | ||
| 40 | break "small", n | ||
| 41 | ``` | ||
| 42 | |||
| 43 | </YueDisplay> | ||
| 24 | 44 | ||
| 25 | ```yuescript | 45 | ```yuescript |
| 26 | counter = do | 46 | counter = do |
diff --git a/doc/docs/zh/doc/control-flow/for-loop.md b/doc/docs/zh/doc/control-flow/for-loop.md index 52180b7..97e66f9 100644 --- a/doc/docs/zh/doc/control-flow/for-loop.md +++ b/doc/docs/zh/doc/control-flow/for-loop.md | |||
| @@ -86,7 +86,7 @@ doubled_evens = for i = 1, 20 | |||
| 86 | 86 | ||
| 87 | </YueDisplay> | 87 | </YueDisplay> |
| 88 | 88 | ||
| 89 |   此外,for 循环还支持带返回值的 break 语句,这样循环本身就可以作为一个表达式,在满足条件时提前退出并返回有意义的结果。 | 89 |   此外,for 循环还支持带返回值的 break 语句,这样循环本身就可以作为一个表达式,在满足条件时提前退出并返回有意义的结果。for 循环表达式支持 `break` 返回多个值。 |
| 90 | 90 | ||
| 91 |   例如,查找第一个大于 10 的数字: | 91 |   例如,查找第一个大于 10 的数字: |
| 92 | 92 | ||
| @@ -104,6 +104,20 @@ first_large = for n in *numbers | |||
| 104 | 104 | ||
| 105 | </YueDisplay> | 105 | </YueDisplay> |
| 106 | 106 | ||
| 107 | ```yuescript | ||
| 108 | key, score = for k, v in pairs data | ||
| 109 | break k, v * 10 if k == "target" | ||
| 110 | ``` | ||
| 111 | |||
| 112 | <YueDisplay> | ||
| 113 | |||
| 114 | ```yue | ||
| 115 | key, score = for k, v in pairs data | ||
| 116 | break k, v * 10 if k == "target" | ||
| 117 | ``` | ||
| 118 | |||
| 119 | </YueDisplay> | ||
| 120 | |||
| 107 |   你还可以结合 for 循环表达式与 continue 语句来过滤值。 | 121 |   你还可以结合 for 循环表达式与 continue 语句来过滤值。 |
| 108 | 122 | ||
| 109 |   注意出现在函数体末尾的 for 循环,不会被当作是一个表达式并将循环结果累积到一个列表中作为返回值(相反,函数将返回 nil)。如果要函数末尾的循环转换为列表表达式,可以显式地使用返回语句加 for 循环表达式。 | 123 |   注意出现在函数体末尾的 for 循环,不会被当作是一个表达式并将循环结果累积到一个列表中作为返回值(相反,函数将返回 nil)。如果要函数末尾的循环转换为列表表达式,可以显式地使用返回语句加 for 循环表达式。 |
diff --git a/doc/docs/zh/doc/control-flow/while-loop.md b/doc/docs/zh/doc/control-flow/while-loop.md index 3c624fe..0138d85 100644 --- a/doc/docs/zh/doc/control-flow/while-loop.md +++ b/doc/docs/zh/doc/control-flow/while-loop.md | |||
| @@ -45,7 +45,25 @@ until running == false do my_function! | |||
| 45 | 45 | ||
| 46 | </YueDisplay> | 46 | </YueDisplay> |
| 47 | 47 | ||
| 48 |   像 for 循环的语法一样,while 循环也可以作为一个表达式使用。为了使函数返回 while 循环的累积列表值,必须明确使用返回语句返回 while 循环表达式。 | 48 |   像 for 循环的语法一样,while 循环也可以作为一个表达式使用。while / until 循环表达式支持 `break` 返回多个值。 |
| 49 | |||
| 50 | ```yuescript | ||
| 51 | value, doubled = while true | ||
| 52 | n = get_next! | ||
| 53 | break n, n * 2 if n > 10 | ||
| 54 | ``` | ||
| 55 | |||
| 56 | <YueDisplay> | ||
| 57 | |||
| 58 | ```yue | ||
| 59 | value, doubled = while true | ||
| 60 | n = get_next! | ||
| 61 | break n, n * 2 if n > 10 | ||
| 62 | ``` | ||
| 63 | |||
| 64 | </YueDisplay> | ||
| 65 | |||
| 66 |   为了使函数返回 while 循环的累积列表值,必须明确使用返回语句返回 while 循环表达式。 | ||
| 49 | 67 | ||
| 50 | ## repeat 循环 | 68 | ## repeat 循环 |
| 51 | 69 | ||
| @@ -70,3 +88,25 @@ until i == 0 | |||
| 70 | ``` | 88 | ``` |
| 71 | 89 | ||
| 72 | </YueDisplay> | 90 | </YueDisplay> |
| 91 | |||
| 92 |   repeat 循环表达式同样支持 `break` 返回多个值: | ||
| 93 | |||
| 94 | ```yuescript | ||
| 95 | i = 1 | ||
| 96 | value, scaled = repeat | ||
| 97 | break i, i * 100 if i > 3 | ||
| 98 | i += 1 | ||
| 99 | until false | ||
| 100 | ``` | ||
| 101 | |||
| 102 | <YueDisplay> | ||
| 103 | |||
| 104 | ```yue | ||
| 105 | i = 1 | ||
| 106 | value, scaled = repeat | ||
| 107 | break i, i * 100 if i > 3 | ||
| 108 | i += 1 | ||
| 109 | until false | ||
| 110 | ``` | ||
| 111 | |||
| 112 | </YueDisplay> | ||
diff --git a/doc/docs/zh/doc/advanced/module.md b/doc/docs/zh/doc/language-basics/module.md index 6c90f0e..6c90f0e 100644 --- a/doc/docs/zh/doc/advanced/module.md +++ b/doc/docs/zh/doc/language-basics/module.md | |||
diff --git a/doc/docs/zh/doc/objects/with-statement.md b/doc/docs/zh/doc/objects/with-statement.md index 0925050..338e2cc 100644 --- a/doc/docs/zh/doc/objects/with-statement.md +++ b/doc/docs/zh/doc/objects/with-statement.md | |||
| @@ -44,6 +44,50 @@ file = with File "favorite_foods.txt" | |||
| 44 | 44 | ||
| 45 | </YueDisplay> | 45 | </YueDisplay> |
| 46 | 46 | ||
| 47 | `with` 表达式支持 `break` 返回一个值: | ||
| 48 | |||
| 49 | ```yuescript | ||
| 50 | result = with obj | ||
| 51 | break .value | ||
| 52 | ``` | ||
| 53 | |||
| 54 | <YueDisplay> | ||
| 55 | |||
| 56 | ```yue | ||
| 57 | result = with obj | ||
| 58 | break .value | ||
| 59 | ``` | ||
| 60 | |||
| 61 | </YueDisplay> | ||
| 62 | |||
| 63 | 在 `with` 中使用 `break value` 后,`with` 表达式将不再返回其目标对象,而是返回 `break` 给出的值。 | ||
| 64 | |||
| 65 | ```yuescript | ||
| 66 | a = with obj | ||
| 67 | .x = 1 | ||
| 68 | -- a 是 obj | ||
| 69 | |||
| 70 | b = with obj | ||
| 71 | break .x | ||
| 72 | -- b 是 .x,不是 obj | ||
| 73 | ``` | ||
| 74 | |||
| 75 | <YueDisplay> | ||
| 76 | |||
| 77 | ```yue | ||
| 78 | a = with obj | ||
| 79 | .x = 1 | ||
| 80 | -- a 是 obj | ||
| 81 | |||
| 82 | b = with obj | ||
| 83 | break .x | ||
| 84 | -- b 是 .x,不是 obj | ||
| 85 | ``` | ||
| 86 | |||
| 87 | </YueDisplay> | ||
| 88 | |||
| 89 | 与 `for` / `while` / `repeat` / `do` 不同,`with` 只支持一个 break 返回值。 | ||
| 90 | |||
| 47 | 或者… | 91 | 或者… |
| 48 | 92 | ||
| 49 | ```yuescript | 93 | ```yuescript |
diff --git a/spec/inputs/compile_doc.yue b/spec/inputs/compile_doc.yue index 20f68df..ab621f8 100644 --- a/spec/inputs/compile_doc.yue +++ b/spec/inputs/compile_doc.yue | |||
| @@ -7,7 +7,6 @@ getFiles = (locale) -> | |||
| 7 | "doc/docs/#{locale}doc/advanced/do.md" | 7 | "doc/docs/#{locale}doc/advanced/do.md" |
| 8 | "doc/docs/#{locale}doc/advanced/line-decorators.md" | 8 | "doc/docs/#{locale}doc/advanced/line-decorators.md" |
| 9 | "doc/docs/#{locale}doc/advanced/macro.md" | 9 | "doc/docs/#{locale}doc/advanced/macro.md" |
| 10 | "doc/docs/#{locale}doc/advanced/module.md" | ||
| 11 | "doc/docs/#{locale}doc/advanced/try.md" | 10 | "doc/docs/#{locale}doc/advanced/try.md" |
| 12 | "doc/docs/#{locale}doc/data-structures/table-literals.md" | 11 | "doc/docs/#{locale}doc/data-structures/table-literals.md" |
| 13 | "doc/docs/#{locale}doc/data-structures/comprehensions.md" | 12 | "doc/docs/#{locale}doc/data-structures/comprehensions.md" |
| @@ -34,6 +33,7 @@ getFiles = (locale) -> | |||
| 34 | "doc/docs/#{locale}doc/language-basics/attributes.md" | 33 | "doc/docs/#{locale}doc/language-basics/attributes.md" |
| 35 | "doc/docs/#{locale}doc/language-basics/operator.md" | 34 | "doc/docs/#{locale}doc/language-basics/operator.md" |
| 36 | "doc/docs/#{locale}doc/language-basics/literals.md" | 35 | "doc/docs/#{locale}doc/language-basics/literals.md" |
| 36 | "doc/docs/#{locale}doc/language-basics/module.md" | ||
| 37 | "doc/docs/#{locale}doc/reference/license-mit.md" | 37 | "doc/docs/#{locale}doc/reference/license-mit.md" |
| 38 | "doc/docs/#{locale}doc/reference/the-yuescript-library.md" | 38 | "doc/docs/#{locale}doc/reference/the-yuescript-library.md" |
| 39 | ] | 39 | ] |
diff --git a/spec/outputs/codes_from_doc_de.lua b/spec/outputs/codes_from_doc_de.lua index 7de1a35..428f788 100644 --- a/spec/outputs/codes_from_doc_de.lua +++ b/spec/outputs/codes_from_doc_de.lua | |||
| @@ -3,6 +3,18 @@ do | |||
| 3 | print(var) | 3 | print(var) |
| 4 | end | 4 | end |
| 5 | print(var) | 5 | print(var) |
| 6 | local status, value | ||
| 7 | do | ||
| 8 | repeat | ||
| 9 | local n = 12 | ||
| 10 | if n > 10 then | ||
| 11 | status, value = "large", n | ||
| 12 | break | ||
| 13 | end | ||
| 14 | status, value = "small", n | ||
| 15 | break | ||
| 16 | until true | ||
| 17 | end | ||
| 6 | local counter | 18 | local counter |
| 7 | do | 19 | do |
| 8 | local i = 0 | 20 | local i = 0 |
| @@ -24,6 +36,18 @@ do | |||
| 24 | print(var) | 36 | print(var) |
| 25 | end | 37 | end |
| 26 | print(var) | 38 | print(var) |
| 39 | local status, value | ||
| 40 | do | ||
| 41 | repeat | ||
| 42 | local n = 12 | ||
| 43 | if n > 10 then | ||
| 44 | status, value = "large", n | ||
| 45 | break | ||
| 46 | end | ||
| 47 | status, value = "small", n | ||
| 48 | break | ||
| 49 | until true | ||
| 50 | end | ||
| 27 | local counter | 51 | local counter |
| 28 | do | 52 | do |
| 29 | local i = 0 | 53 | local i = 0 |
| @@ -146,268 +170,6 @@ end | |||
| 146 | do | 170 | do |
| 147 | print(123, "hallo") | 171 | print(123, "hallo") |
| 148 | end | 172 | end |
| 149 | do | ||
| 150 | local insert, concat = table.insert, table.concat | ||
| 151 | local C, Ct, Cmt | ||
| 152 | do | ||
| 153 | local _obj_0 = require("lpeg") | ||
| 154 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 155 | end | ||
| 156 | local x, y, z | ||
| 157 | do | ||
| 158 | local _obj_0 = require('mymodule') | ||
| 159 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 160 | end | ||
| 161 | local a, b, c | ||
| 162 | local _obj_0 = require('module') | ||
| 163 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 164 | end | ||
| 165 | do | ||
| 166 | local module = require('module') | ||
| 167 | local module_x = require('module_x') | ||
| 168 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 169 | local part = require("module.part") | ||
| 170 | end | ||
| 171 | do | ||
| 172 | local PlayerModule = require("player") | ||
| 173 | local C, Ct, Cmt | ||
| 174 | do | ||
| 175 | local _obj_0 = require("lpeg") | ||
| 176 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 177 | end | ||
| 178 | local one, two, ch | ||
| 179 | local _obj_0 = require("export") | ||
| 180 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 181 | end | ||
| 182 | do | ||
| 183 | local tostring <const> = tostring | ||
| 184 | local concat <const> = table.concat | ||
| 185 | print(concat({ | ||
| 186 | "a", | ||
| 187 | tostring(1) | ||
| 188 | })) | ||
| 189 | end | ||
| 190 | do | ||
| 191 | local print <const> = print | ||
| 192 | local math <const> = math | ||
| 193 | print("hallo") | ||
| 194 | math.random(3) | ||
| 195 | end | ||
| 196 | do | ||
| 197 | local print <const> = print | ||
| 198 | print(FLAG) | ||
| 199 | FLAG = 123 | ||
| 200 | end | ||
| 201 | local _module_0 = { } | ||
| 202 | local a, b, c = 1, 2, 3 | ||
| 203 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 204 | local cool = "Katze" | ||
| 205 | _module_0["cool"] = cool | ||
| 206 | local What | ||
| 207 | if this then | ||
| 208 | What = "abc" | ||
| 209 | else | ||
| 210 | What = "def" | ||
| 211 | end | ||
| 212 | _module_0["What"] = What | ||
| 213 | local y | ||
| 214 | y = function() | ||
| 215 | local hallo = 3434 | ||
| 216 | end | ||
| 217 | _module_0["y"] = y | ||
| 218 | local Something | ||
| 219 | local _class_0 | ||
| 220 | local _base_0 = { | ||
| 221 | umm = "cool" | ||
| 222 | } | ||
| 223 | if _base_0.__index == nil then | ||
| 224 | _base_0.__index = _base_0 | ||
| 225 | end | ||
| 226 | _class_0 = setmetatable({ | ||
| 227 | __init = function() end, | ||
| 228 | __base = _base_0, | ||
| 229 | __name = "Something" | ||
| 230 | }, { | ||
| 231 | __index = _base_0, | ||
| 232 | __call = function(cls, ...) | ||
| 233 | local _self_0 = setmetatable({ }, _base_0) | ||
| 234 | cls.__init(_self_0, ...) | ||
| 235 | return _self_0 | ||
| 236 | end | ||
| 237 | }) | ||
| 238 | _base_0.__class = _class_0 | ||
| 239 | Something = _class_0 | ||
| 240 | _module_0["Something"] = Something | ||
| 241 | return _module_0 | ||
| 242 | local _module_0 = { } | ||
| 243 | local loadstring, tolua | ||
| 244 | do | ||
| 245 | local _obj_0 = yue | ||
| 246 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 247 | end | ||
| 248 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 249 | local fieldA = tb.itemA.fieldA | ||
| 250 | if fieldA == nil then | ||
| 251 | fieldA = 'default' | ||
| 252 | end | ||
| 253 | _module_0["fieldA"] = fieldA | ||
| 254 | return _module_0 | ||
| 255 | local _module_0 = setmetatable({ }, { }) | ||
| 256 | _module_0.itemA = tb | ||
| 257 | getmetatable(_module_0).__index = items | ||
| 258 | _module_0["a-b-c"] = 123 | ||
| 259 | return _module_0 | ||
| 260 | local _module_0 = { } | ||
| 261 | local d, e, f = 3, 2, 1 | ||
| 262 | _module_0[#_module_0 + 1] = d | ||
| 263 | _module_0[#_module_0 + 1] = e | ||
| 264 | _module_0[#_module_0 + 1] = f | ||
| 265 | if this then | ||
| 266 | _module_0[#_module_0 + 1] = 123 | ||
| 267 | else | ||
| 268 | _module_0[#_module_0 + 1] = 456 | ||
| 269 | end | ||
| 270 | local _with_0 = tmp | ||
| 271 | local j = 2000 | ||
| 272 | _module_0[#_module_0 + 1] = _with_0 | ||
| 273 | return _module_0 | ||
| 274 | local _module_0 = nil | ||
| 275 | _module_0 = function() | ||
| 276 | print("hallo") | ||
| 277 | return 123 | ||
| 278 | end | ||
| 279 | return _module_0 | ||
| 280 | do | ||
| 281 | local insert, concat = table.insert, table.concat | ||
| 282 | local C, Ct, Cmt | ||
| 283 | do | ||
| 284 | local _obj_0 = require("lpeg") | ||
| 285 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 286 | end | ||
| 287 | local x, y, z | ||
| 288 | do | ||
| 289 | local _obj_0 = require('mymodule') | ||
| 290 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 291 | end | ||
| 292 | local a, b, c | ||
| 293 | local _obj_0 = require('module') | ||
| 294 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 295 | end | ||
| 296 | do | ||
| 297 | local module = require('module') | ||
| 298 | local module_x = require('module_x') | ||
| 299 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 300 | local part = require("module.part") | ||
| 301 | end | ||
| 302 | do | ||
| 303 | local PlayerModule = require("player") | ||
| 304 | local C, Ct, Cmt | ||
| 305 | do | ||
| 306 | local _obj_0 = require("lpeg") | ||
| 307 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 308 | end | ||
| 309 | local one, two, ch | ||
| 310 | local _obj_0 = require("export") | ||
| 311 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 312 | end | ||
| 313 | do | ||
| 314 | local tostring <const> = tostring | ||
| 315 | local concat <const> = table.concat | ||
| 316 | print(concat({ | ||
| 317 | "a", | ||
| 318 | tostring(1) | ||
| 319 | })) | ||
| 320 | end | ||
| 321 | do | ||
| 322 | local print <const> = print | ||
| 323 | local math <const> = math | ||
| 324 | print("hallo") | ||
| 325 | math.random(3) | ||
| 326 | end | ||
| 327 | do | ||
| 328 | local print <const> = print | ||
| 329 | print(FLAG) | ||
| 330 | FLAG = 123 | ||
| 331 | end | ||
| 332 | local _module_0 = { } | ||
| 333 | local a, b, c = 1, 2, 3 | ||
| 334 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 335 | local cool = "Katze" | ||
| 336 | _module_0["cool"] = cool | ||
| 337 | local What | ||
| 338 | if this then | ||
| 339 | What = "abc" | ||
| 340 | else | ||
| 341 | What = "def" | ||
| 342 | end | ||
| 343 | _module_0["What"] = What | ||
| 344 | local y | ||
| 345 | y = function() | ||
| 346 | local hallo = 3434 | ||
| 347 | end | ||
| 348 | _module_0["y"] = y | ||
| 349 | local Something | ||
| 350 | local _class_0 | ||
| 351 | local _base_0 = { | ||
| 352 | umm = "cool" | ||
| 353 | } | ||
| 354 | if _base_0.__index == nil then | ||
| 355 | _base_0.__index = _base_0 | ||
| 356 | end | ||
| 357 | _class_0 = setmetatable({ | ||
| 358 | __init = function() end, | ||
| 359 | __base = _base_0, | ||
| 360 | __name = "Something" | ||
| 361 | }, { | ||
| 362 | __index = _base_0, | ||
| 363 | __call = function(cls, ...) | ||
| 364 | local _self_0 = setmetatable({ }, _base_0) | ||
| 365 | cls.__init(_self_0, ...) | ||
| 366 | return _self_0 | ||
| 367 | end | ||
| 368 | }) | ||
| 369 | _base_0.__class = _class_0 | ||
| 370 | Something = _class_0 | ||
| 371 | _module_0["Something"] = Something | ||
| 372 | return _module_0 | ||
| 373 | local _module_0 = { } | ||
| 374 | local loadstring, tolua | ||
| 375 | do | ||
| 376 | local _obj_0 = yue | ||
| 377 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 378 | end | ||
| 379 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 380 | local fieldA = tb.itemA.fieldA | ||
| 381 | if fieldA == nil then | ||
| 382 | fieldA = 'default' | ||
| 383 | end | ||
| 384 | _module_0["fieldA"] = fieldA | ||
| 385 | return _module_0 | ||
| 386 | local _module_0 = setmetatable({ }, { }) | ||
| 387 | _module_0.itemA = tb | ||
| 388 | getmetatable(_module_0).__index = items | ||
| 389 | _module_0["a-b-c"] = 123 | ||
| 390 | return _module_0 | ||
| 391 | local _module_0 = { } | ||
| 392 | local d, e, f = 3, 2, 1 | ||
| 393 | _module_0[#_module_0 + 1] = d | ||
| 394 | _module_0[#_module_0 + 1] = e | ||
| 395 | _module_0[#_module_0 + 1] = f | ||
| 396 | if this then | ||
| 397 | _module_0[#_module_0 + 1] = 123 | ||
| 398 | else | ||
| 399 | _module_0[#_module_0 + 1] = 456 | ||
| 400 | end | ||
| 401 | local _with_0 = tmp | ||
| 402 | local j = 2000 | ||
| 403 | _module_0[#_module_0 + 1] = _with_0 | ||
| 404 | return _module_0 | ||
| 405 | local _module_0 = nil | ||
| 406 | _module_0 = function() | ||
| 407 | print("hallo") | ||
| 408 | return 123 | ||
| 409 | end | ||
| 410 | return _module_0 | ||
| 411 | xpcall(function() | 173 | xpcall(function() |
| 412 | return func(1, 2, 3) | 174 | return func(1, 2, 3) |
| 413 | end, function(err) | 175 | end, function(err) |
| @@ -2395,6 +2157,12 @@ local file | |||
| 2395 | local _with_0 = File("Lieblingsessen.txt") | 2157 | local _with_0 = File("Lieblingsessen.txt") |
| 2396 | _with_0:set_encoding("utf8") | 2158 | _with_0:set_encoding("utf8") |
| 2397 | file = _with_0 | 2159 | file = _with_0 |
| 2160 | local result | ||
| 2161 | local _with_0 = obj | ||
| 2162 | repeat | ||
| 2163 | result = _with_0.value | ||
| 2164 | break | ||
| 2165 | until true | ||
| 2398 | local create_person | 2166 | local create_person |
| 2399 | create_person = function(name, relatives) | 2167 | create_person = function(name, relatives) |
| 2400 | local _with_0 = Person() | 2168 | local _with_0 = Person() |
| @@ -2435,6 +2203,12 @@ local file | |||
| 2435 | local _with_0 = File("Lieblingsessen.txt") | 2203 | local _with_0 = File("Lieblingsessen.txt") |
| 2436 | _with_0:set_encoding("utf8") | 2204 | _with_0:set_encoding("utf8") |
| 2437 | file = _with_0 | 2205 | file = _with_0 |
| 2206 | local result | ||
| 2207 | local _with_0 = obj | ||
| 2208 | repeat | ||
| 2209 | result = _with_0.value | ||
| 2210 | break | ||
| 2211 | until true | ||
| 2438 | local create_person | 2212 | local create_person |
| 2439 | create_person = function(name, relatives) | 2213 | create_person = function(name, relatives) |
| 2440 | local _with_0 = Person() | 2214 | local _with_0 = Person() |
| @@ -3268,6 +3042,13 @@ for _index_0 = 1, #_list_0 do | |||
| 3268 | break | 3042 | break |
| 3269 | end | 3043 | end |
| 3270 | end | 3044 | end |
| 3045 | local key, score | ||
| 3046 | for k, v in pairs(data) do | ||
| 3047 | if k == "target" then | ||
| 3048 | key, score = k, v * 10 | ||
| 3049 | break | ||
| 3050 | end | ||
| 3051 | end | ||
| 3271 | local func_a | 3052 | local func_a |
| 3272 | func_a = function() | 3053 | func_a = function() |
| 3273 | for i = 1, 10 do | 3054 | for i = 1, 10 do |
| @@ -3330,6 +3111,13 @@ for _index_0 = 1, #_list_0 do | |||
| 3330 | break | 3111 | break |
| 3331 | end | 3112 | end |
| 3332 | end | 3113 | end |
| 3114 | local key, score | ||
| 3115 | for k, v in pairs(data) do | ||
| 3116 | if k == "target" then | ||
| 3117 | key, score = k, v * 10 | ||
| 3118 | break | ||
| 3119 | end | ||
| 3120 | end | ||
| 3333 | local func_a | 3121 | local func_a |
| 3334 | func_a = function() | 3122 | func_a = function() |
| 3335 | for i = 1, 10 do | 3123 | for i = 1, 10 do |
| @@ -4008,11 +3796,32 @@ end | |||
| 4008 | while not (running == false) do | 3796 | while not (running == false) do |
| 4009 | my_function() | 3797 | my_function() |
| 4010 | end | 3798 | end |
| 3799 | local value, doubled | ||
| 3800 | local _val_0, _val_1 | ||
| 3801 | while true do | ||
| 3802 | local n = get_next() | ||
| 3803 | if n > 10 then | ||
| 3804 | _val_0, _val_1 = n, n * 2 | ||
| 3805 | break | ||
| 3806 | end | ||
| 3807 | end | ||
| 3808 | value, doubled = _val_0, _val_1 | ||
| 4011 | local i = 10 | 3809 | local i = 10 |
| 4012 | repeat | 3810 | repeat |
| 4013 | print(i) | 3811 | print(i) |
| 4014 | i = i - 1 | 3812 | i = i - 1 |
| 4015 | until i == 0 | 3813 | until i == 0 |
| 3814 | local i = 1 | ||
| 3815 | local value, scaled | ||
| 3816 | local _val_0, _val_1 | ||
| 3817 | repeat | ||
| 3818 | if i > 3 then | ||
| 3819 | _val_0, _val_1 = i, i * 100 | ||
| 3820 | break | ||
| 3821 | end | ||
| 3822 | i = i + 1 | ||
| 3823 | until false | ||
| 3824 | value, scaled = _val_0, _val_1 | ||
| 4016 | local i = 10 | 3825 | local i = 10 |
| 4017 | while i > 0 do | 3826 | while i > 0 do |
| 4018 | print(i) | 3827 | print(i) |
| @@ -4029,11 +3838,32 @@ end | |||
| 4029 | while not (running == false) do | 3838 | while not (running == false) do |
| 4030 | my_function() | 3839 | my_function() |
| 4031 | end | 3840 | end |
| 3841 | local value, doubled | ||
| 3842 | local _val_0, _val_1 | ||
| 3843 | while true do | ||
| 3844 | local n = get_next() | ||
| 3845 | if n > 10 then | ||
| 3846 | _val_0, _val_1 = n, n * 2 | ||
| 3847 | break | ||
| 3848 | end | ||
| 3849 | end | ||
| 3850 | value, doubled = _val_0, _val_1 | ||
| 4032 | local i = 10 | 3851 | local i = 10 |
| 4033 | repeat | 3852 | repeat |
| 4034 | print(i) | 3853 | print(i) |
| 4035 | i = i - 1 | 3854 | i = i - 1 |
| 4036 | until i == 0 | 3855 | until i == 0 |
| 3856 | local i = 1 | ||
| 3857 | local value, scaled | ||
| 3858 | local _val_0, _val_1 | ||
| 3859 | repeat | ||
| 3860 | if i > 3 then | ||
| 3861 | _val_0, _val_1 = i, i * 100 | ||
| 3862 | break | ||
| 3863 | end | ||
| 3864 | i = i + 1 | ||
| 3865 | until false | ||
| 3866 | value, scaled = _val_0, _val_1 | ||
| 4037 | local my_object = { | 3867 | local my_object = { |
| 4038 | value = 1000, | 3868 | value = 1000, |
| 4039 | write = function(self) | 3869 | write = function(self) |
| @@ -5136,3 +4966,265 @@ fn = function() | |||
| 5136 | return str | 4966 | return str |
| 5137 | end | 4967 | end |
| 5138 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" | 4968 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" |
| 4969 | do | ||
| 4970 | local insert, concat = table.insert, table.concat | ||
| 4971 | local C, Ct, Cmt | ||
| 4972 | do | ||
| 4973 | local _obj_0 = require("lpeg") | ||
| 4974 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 4975 | end | ||
| 4976 | local x, y, z | ||
| 4977 | do | ||
| 4978 | local _obj_0 = require('mymodule') | ||
| 4979 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 4980 | end | ||
| 4981 | local a, b, c | ||
| 4982 | local _obj_0 = require('module') | ||
| 4983 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 4984 | end | ||
| 4985 | do | ||
| 4986 | local module = require('module') | ||
| 4987 | local module_x = require('module_x') | ||
| 4988 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 4989 | local part = require("module.part") | ||
| 4990 | end | ||
| 4991 | do | ||
| 4992 | local PlayerModule = require("player") | ||
| 4993 | local C, Ct, Cmt | ||
| 4994 | do | ||
| 4995 | local _obj_0 = require("lpeg") | ||
| 4996 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 4997 | end | ||
| 4998 | local one, two, ch | ||
| 4999 | local _obj_0 = require("export") | ||
| 5000 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 5001 | end | ||
| 5002 | do | ||
| 5003 | local tostring <const> = tostring | ||
| 5004 | local concat <const> = table.concat | ||
| 5005 | print(concat({ | ||
| 5006 | "a", | ||
| 5007 | tostring(1) | ||
| 5008 | })) | ||
| 5009 | end | ||
| 5010 | do | ||
| 5011 | local print <const> = print | ||
| 5012 | local math <const> = math | ||
| 5013 | print("hallo") | ||
| 5014 | math.random(3) | ||
| 5015 | end | ||
| 5016 | do | ||
| 5017 | local print <const> = print | ||
| 5018 | print(FLAG) | ||
| 5019 | FLAG = 123 | ||
| 5020 | end | ||
| 5021 | local _module_0 = { } | ||
| 5022 | local a, b, c = 1, 2, 3 | ||
| 5023 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 5024 | local cool = "Katze" | ||
| 5025 | _module_0["cool"] = cool | ||
| 5026 | local What | ||
| 5027 | if this then | ||
| 5028 | What = "abc" | ||
| 5029 | else | ||
| 5030 | What = "def" | ||
| 5031 | end | ||
| 5032 | _module_0["What"] = What | ||
| 5033 | local y | ||
| 5034 | y = function() | ||
| 5035 | local hallo = 3434 | ||
| 5036 | end | ||
| 5037 | _module_0["y"] = y | ||
| 5038 | local Something | ||
| 5039 | local _class_0 | ||
| 5040 | local _base_0 = { | ||
| 5041 | umm = "cool" | ||
| 5042 | } | ||
| 5043 | if _base_0.__index == nil then | ||
| 5044 | _base_0.__index = _base_0 | ||
| 5045 | end | ||
| 5046 | _class_0 = setmetatable({ | ||
| 5047 | __init = function() end, | ||
| 5048 | __base = _base_0, | ||
| 5049 | __name = "Something" | ||
| 5050 | }, { | ||
| 5051 | __index = _base_0, | ||
| 5052 | __call = function(cls, ...) | ||
| 5053 | local _self_0 = setmetatable({ }, _base_0) | ||
| 5054 | cls.__init(_self_0, ...) | ||
| 5055 | return _self_0 | ||
| 5056 | end | ||
| 5057 | }) | ||
| 5058 | _base_0.__class = _class_0 | ||
| 5059 | Something = _class_0 | ||
| 5060 | _module_0["Something"] = Something | ||
| 5061 | return _module_0 | ||
| 5062 | local _module_0 = { } | ||
| 5063 | local loadstring, tolua | ||
| 5064 | do | ||
| 5065 | local _obj_0 = yue | ||
| 5066 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 5067 | end | ||
| 5068 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 5069 | local fieldA = tb.itemA.fieldA | ||
| 5070 | if fieldA == nil then | ||
| 5071 | fieldA = 'default' | ||
| 5072 | end | ||
| 5073 | _module_0["fieldA"] = fieldA | ||
| 5074 | return _module_0 | ||
| 5075 | local _module_0 = setmetatable({ }, { }) | ||
| 5076 | _module_0.itemA = tb | ||
| 5077 | getmetatable(_module_0).__index = items | ||
| 5078 | _module_0["a-b-c"] = 123 | ||
| 5079 | return _module_0 | ||
| 5080 | local _module_0 = { } | ||
| 5081 | local d, e, f = 3, 2, 1 | ||
| 5082 | _module_0[#_module_0 + 1] = d | ||
| 5083 | _module_0[#_module_0 + 1] = e | ||
| 5084 | _module_0[#_module_0 + 1] = f | ||
| 5085 | if this then | ||
| 5086 | _module_0[#_module_0 + 1] = 123 | ||
| 5087 | else | ||
| 5088 | _module_0[#_module_0 + 1] = 456 | ||
| 5089 | end | ||
| 5090 | local _with_0 = tmp | ||
| 5091 | local j = 2000 | ||
| 5092 | _module_0[#_module_0 + 1] = _with_0 | ||
| 5093 | return _module_0 | ||
| 5094 | local _module_0 = nil | ||
| 5095 | _module_0 = function() | ||
| 5096 | print("hallo") | ||
| 5097 | return 123 | ||
| 5098 | end | ||
| 5099 | return _module_0 | ||
| 5100 | do | ||
| 5101 | local insert, concat = table.insert, table.concat | ||
| 5102 | local C, Ct, Cmt | ||
| 5103 | do | ||
| 5104 | local _obj_0 = require("lpeg") | ||
| 5105 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 5106 | end | ||
| 5107 | local x, y, z | ||
| 5108 | do | ||
| 5109 | local _obj_0 = require('mymodule') | ||
| 5110 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 5111 | end | ||
| 5112 | local a, b, c | ||
| 5113 | local _obj_0 = require('module') | ||
| 5114 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 5115 | end | ||
| 5116 | do | ||
| 5117 | local module = require('module') | ||
| 5118 | local module_x = require('module_x') | ||
| 5119 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 5120 | local part = require("module.part") | ||
| 5121 | end | ||
| 5122 | do | ||
| 5123 | local PlayerModule = require("player") | ||
| 5124 | local C, Ct, Cmt | ||
| 5125 | do | ||
| 5126 | local _obj_0 = require("lpeg") | ||
| 5127 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 5128 | end | ||
| 5129 | local one, two, ch | ||
| 5130 | local _obj_0 = require("export") | ||
| 5131 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 5132 | end | ||
| 5133 | do | ||
| 5134 | local tostring <const> = tostring | ||
| 5135 | local concat <const> = table.concat | ||
| 5136 | print(concat({ | ||
| 5137 | "a", | ||
| 5138 | tostring(1) | ||
| 5139 | })) | ||
| 5140 | end | ||
| 5141 | do | ||
| 5142 | local print <const> = print | ||
| 5143 | local math <const> = math | ||
| 5144 | print("hallo") | ||
| 5145 | math.random(3) | ||
| 5146 | end | ||
| 5147 | do | ||
| 5148 | local print <const> = print | ||
| 5149 | print(FLAG) | ||
| 5150 | FLAG = 123 | ||
| 5151 | end | ||
| 5152 | local _module_0 = { } | ||
| 5153 | local a, b, c = 1, 2, 3 | ||
| 5154 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 5155 | local cool = "Katze" | ||
| 5156 | _module_0["cool"] = cool | ||
| 5157 | local What | ||
| 5158 | if this then | ||
| 5159 | What = "abc" | ||
| 5160 | else | ||
| 5161 | What = "def" | ||
| 5162 | end | ||
| 5163 | _module_0["What"] = What | ||
| 5164 | local y | ||
| 5165 | y = function() | ||
| 5166 | local hallo = 3434 | ||
| 5167 | end | ||
| 5168 | _module_0["y"] = y | ||
| 5169 | local Something | ||
| 5170 | local _class_0 | ||
| 5171 | local _base_0 = { | ||
| 5172 | umm = "cool" | ||
| 5173 | } | ||
| 5174 | if _base_0.__index == nil then | ||
| 5175 | _base_0.__index = _base_0 | ||
| 5176 | end | ||
| 5177 | _class_0 = setmetatable({ | ||
| 5178 | __init = function() end, | ||
| 5179 | __base = _base_0, | ||
| 5180 | __name = "Something" | ||
| 5181 | }, { | ||
| 5182 | __index = _base_0, | ||
| 5183 | __call = function(cls, ...) | ||
| 5184 | local _self_0 = setmetatable({ }, _base_0) | ||
| 5185 | cls.__init(_self_0, ...) | ||
| 5186 | return _self_0 | ||
| 5187 | end | ||
| 5188 | }) | ||
| 5189 | _base_0.__class = _class_0 | ||
| 5190 | Something = _class_0 | ||
| 5191 | _module_0["Something"] = Something | ||
| 5192 | return _module_0 | ||
| 5193 | local _module_0 = { } | ||
| 5194 | local loadstring, tolua | ||
| 5195 | do | ||
| 5196 | local _obj_0 = yue | ||
| 5197 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 5198 | end | ||
| 5199 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 5200 | local fieldA = tb.itemA.fieldA | ||
| 5201 | if fieldA == nil then | ||
| 5202 | fieldA = 'default' | ||
| 5203 | end | ||
| 5204 | _module_0["fieldA"] = fieldA | ||
| 5205 | return _module_0 | ||
| 5206 | local _module_0 = setmetatable({ }, { }) | ||
| 5207 | _module_0.itemA = tb | ||
| 5208 | getmetatable(_module_0).__index = items | ||
| 5209 | _module_0["a-b-c"] = 123 | ||
| 5210 | return _module_0 | ||
| 5211 | local _module_0 = { } | ||
| 5212 | local d, e, f = 3, 2, 1 | ||
| 5213 | _module_0[#_module_0 + 1] = d | ||
| 5214 | _module_0[#_module_0 + 1] = e | ||
| 5215 | _module_0[#_module_0 + 1] = f | ||
| 5216 | if this then | ||
| 5217 | _module_0[#_module_0 + 1] = 123 | ||
| 5218 | else | ||
| 5219 | _module_0[#_module_0 + 1] = 456 | ||
| 5220 | end | ||
| 5221 | local _with_0 = tmp | ||
| 5222 | local j = 2000 | ||
| 5223 | _module_0[#_module_0 + 1] = _with_0 | ||
| 5224 | return _module_0 | ||
| 5225 | local _module_0 = nil | ||
| 5226 | _module_0 = function() | ||
| 5227 | print("hallo") | ||
| 5228 | return 123 | ||
| 5229 | end | ||
| 5230 | return _module_0 | ||
diff --git a/spec/outputs/codes_from_doc_en.lua b/spec/outputs/codes_from_doc_en.lua index cd83bbf..4006605 100644 --- a/spec/outputs/codes_from_doc_en.lua +++ b/spec/outputs/codes_from_doc_en.lua | |||
| @@ -3,6 +3,18 @@ do | |||
| 3 | print(var) | 3 | print(var) |
| 4 | end | 4 | end |
| 5 | print(var) | 5 | print(var) |
| 6 | local status, value | ||
| 7 | do | ||
| 8 | repeat | ||
| 9 | local n = 12 | ||
| 10 | if n > 10 then | ||
| 11 | status, value = "large", n | ||
| 12 | break | ||
| 13 | end | ||
| 14 | status, value = "small", n | ||
| 15 | break | ||
| 16 | until true | ||
| 17 | end | ||
| 6 | local counter | 18 | local counter |
| 7 | do | 19 | do |
| 8 | local i = 0 | 20 | local i = 0 |
| @@ -24,6 +36,18 @@ do | |||
| 24 | print(var) | 36 | print(var) |
| 25 | end | 37 | end |
| 26 | print(var) | 38 | print(var) |
| 39 | local status, value | ||
| 40 | do | ||
| 41 | repeat | ||
| 42 | local n = 12 | ||
| 43 | if n > 10 then | ||
| 44 | status, value = "large", n | ||
| 45 | break | ||
| 46 | end | ||
| 47 | status, value = "small", n | ||
| 48 | break | ||
| 49 | until true | ||
| 50 | end | ||
| 27 | local counter | 51 | local counter |
| 28 | do | 52 | do |
| 29 | local i = 0 | 53 | local i = 0 |
| @@ -146,268 +170,6 @@ end | |||
| 146 | do | 170 | do |
| 147 | print(123, "hello") | 171 | print(123, "hello") |
| 148 | end | 172 | end |
| 149 | do | ||
| 150 | local insert, concat = table.insert, table.concat | ||
| 151 | local C, Ct, Cmt | ||
| 152 | do | ||
| 153 | local _obj_0 = require("lpeg") | ||
| 154 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 155 | end | ||
| 156 | local x, y, z | ||
| 157 | do | ||
| 158 | local _obj_0 = require('mymodule') | ||
| 159 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 160 | end | ||
| 161 | local a, b, c | ||
| 162 | local _obj_0 = require('module') | ||
| 163 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 164 | end | ||
| 165 | do | ||
| 166 | local module = require('module') | ||
| 167 | local module_x = require('module_x') | ||
| 168 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 169 | local part = require("module.part") | ||
| 170 | end | ||
| 171 | do | ||
| 172 | local PlayerModule = require("player") | ||
| 173 | local C, Ct, Cmt | ||
| 174 | do | ||
| 175 | local _obj_0 = require("lpeg") | ||
| 176 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 177 | end | ||
| 178 | local one, two, ch | ||
| 179 | local _obj_0 = require("export") | ||
| 180 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 181 | end | ||
| 182 | do | ||
| 183 | local tostring <const> = tostring | ||
| 184 | local concat <const> = table.concat | ||
| 185 | print(concat({ | ||
| 186 | "a", | ||
| 187 | tostring(1) | ||
| 188 | })) | ||
| 189 | end | ||
| 190 | do | ||
| 191 | local print <const> = print | ||
| 192 | local math <const> = math | ||
| 193 | print("hello") | ||
| 194 | math.random(3) | ||
| 195 | end | ||
| 196 | do | ||
| 197 | local print <const> = print | ||
| 198 | print(FLAG) | ||
| 199 | FLAG = 123 | ||
| 200 | end | ||
| 201 | local _module_0 = { } | ||
| 202 | local a, b, c = 1, 2, 3 | ||
| 203 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 204 | local cool = "cat" | ||
| 205 | _module_0["cool"] = cool | ||
| 206 | local What | ||
| 207 | if this then | ||
| 208 | What = "abc" | ||
| 209 | else | ||
| 210 | What = "def" | ||
| 211 | end | ||
| 212 | _module_0["What"] = What | ||
| 213 | local y | ||
| 214 | y = function() | ||
| 215 | local hallo = 3434 | ||
| 216 | end | ||
| 217 | _module_0["y"] = y | ||
| 218 | local Something | ||
| 219 | local _class_0 | ||
| 220 | local _base_0 = { | ||
| 221 | umm = "cool" | ||
| 222 | } | ||
| 223 | if _base_0.__index == nil then | ||
| 224 | _base_0.__index = _base_0 | ||
| 225 | end | ||
| 226 | _class_0 = setmetatable({ | ||
| 227 | __init = function() end, | ||
| 228 | __base = _base_0, | ||
| 229 | __name = "Something" | ||
| 230 | }, { | ||
| 231 | __index = _base_0, | ||
| 232 | __call = function(cls, ...) | ||
| 233 | local _self_0 = setmetatable({ }, _base_0) | ||
| 234 | cls.__init(_self_0, ...) | ||
| 235 | return _self_0 | ||
| 236 | end | ||
| 237 | }) | ||
| 238 | _base_0.__class = _class_0 | ||
| 239 | Something = _class_0 | ||
| 240 | _module_0["Something"] = Something | ||
| 241 | return _module_0 | ||
| 242 | local _module_0 = { } | ||
| 243 | local loadstring, tolua | ||
| 244 | do | ||
| 245 | local _obj_0 = yue | ||
| 246 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 247 | end | ||
| 248 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 249 | local fieldA = tb.itemA.fieldA | ||
| 250 | if fieldA == nil then | ||
| 251 | fieldA = 'default' | ||
| 252 | end | ||
| 253 | _module_0["fieldA"] = fieldA | ||
| 254 | return _module_0 | ||
| 255 | local _module_0 = setmetatable({ }, { }) | ||
| 256 | _module_0.itemA = tb | ||
| 257 | getmetatable(_module_0).__index = items | ||
| 258 | _module_0["a-b-c"] = 123 | ||
| 259 | return _module_0 | ||
| 260 | local _module_0 = { } | ||
| 261 | local d, e, f = 3, 2, 1 | ||
| 262 | _module_0[#_module_0 + 1] = d | ||
| 263 | _module_0[#_module_0 + 1] = e | ||
| 264 | _module_0[#_module_0 + 1] = f | ||
| 265 | if this then | ||
| 266 | _module_0[#_module_0 + 1] = 123 | ||
| 267 | else | ||
| 268 | _module_0[#_module_0 + 1] = 456 | ||
| 269 | end | ||
| 270 | local _with_0 = tmp | ||
| 271 | local j = 2000 | ||
| 272 | _module_0[#_module_0 + 1] = _with_0 | ||
| 273 | return _module_0 | ||
| 274 | local _module_0 = nil | ||
| 275 | _module_0 = function() | ||
| 276 | print("hello") | ||
| 277 | return 123 | ||
| 278 | end | ||
| 279 | return _module_0 | ||
| 280 | do | ||
| 281 | local insert, concat = table.insert, table.concat | ||
| 282 | local C, Ct, Cmt | ||
| 283 | do | ||
| 284 | local _obj_0 = require("lpeg") | ||
| 285 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 286 | end | ||
| 287 | local x, y, z | ||
| 288 | do | ||
| 289 | local _obj_0 = require('mymodule') | ||
| 290 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 291 | end | ||
| 292 | local a, b, c | ||
| 293 | local _obj_0 = require('module') | ||
| 294 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 295 | end | ||
| 296 | do | ||
| 297 | local module = require('module') | ||
| 298 | local module_x = require('module_x') | ||
| 299 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 300 | local part = require("module.part") | ||
| 301 | end | ||
| 302 | do | ||
| 303 | local PlayerModule = require("player") | ||
| 304 | local C, Ct, Cmt | ||
| 305 | do | ||
| 306 | local _obj_0 = require("lpeg") | ||
| 307 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 308 | end | ||
| 309 | local one, two, ch | ||
| 310 | local _obj_0 = require("export") | ||
| 311 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 312 | end | ||
| 313 | do | ||
| 314 | local tostring <const> = tostring | ||
| 315 | local concat <const> = table.concat | ||
| 316 | print(concat({ | ||
| 317 | "a", | ||
| 318 | tostring(1) | ||
| 319 | })) | ||
| 320 | end | ||
| 321 | do | ||
| 322 | local print <const> = print | ||
| 323 | local math <const> = math | ||
| 324 | print("hello") | ||
| 325 | math.random(3) | ||
| 326 | end | ||
| 327 | do | ||
| 328 | local print <const> = print | ||
| 329 | print(FLAG) | ||
| 330 | FLAG = 123 | ||
| 331 | end | ||
| 332 | local _module_0 = { } | ||
| 333 | local a, b, c = 1, 2, 3 | ||
| 334 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 335 | local cool = "cat" | ||
| 336 | _module_0["cool"] = cool | ||
| 337 | local What | ||
| 338 | if this then | ||
| 339 | What = "abc" | ||
| 340 | else | ||
| 341 | What = "def" | ||
| 342 | end | ||
| 343 | _module_0["What"] = What | ||
| 344 | local y | ||
| 345 | y = function() | ||
| 346 | local hallo = 3434 | ||
| 347 | end | ||
| 348 | _module_0["y"] = y | ||
| 349 | local Something | ||
| 350 | local _class_0 | ||
| 351 | local _base_0 = { | ||
| 352 | umm = "cool" | ||
| 353 | } | ||
| 354 | if _base_0.__index == nil then | ||
| 355 | _base_0.__index = _base_0 | ||
| 356 | end | ||
| 357 | _class_0 = setmetatable({ | ||
| 358 | __init = function() end, | ||
| 359 | __base = _base_0, | ||
| 360 | __name = "Something" | ||
| 361 | }, { | ||
| 362 | __index = _base_0, | ||
| 363 | __call = function(cls, ...) | ||
| 364 | local _self_0 = setmetatable({ }, _base_0) | ||
| 365 | cls.__init(_self_0, ...) | ||
| 366 | return _self_0 | ||
| 367 | end | ||
| 368 | }) | ||
| 369 | _base_0.__class = _class_0 | ||
| 370 | Something = _class_0 | ||
| 371 | _module_0["Something"] = Something | ||
| 372 | return _module_0 | ||
| 373 | local _module_0 = { } | ||
| 374 | local loadstring, tolua | ||
| 375 | do | ||
| 376 | local _obj_0 = yue | ||
| 377 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 378 | end | ||
| 379 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 380 | local fieldA = tb.itemA.fieldA | ||
| 381 | if fieldA == nil then | ||
| 382 | fieldA = 'default' | ||
| 383 | end | ||
| 384 | _module_0["fieldA"] = fieldA | ||
| 385 | return _module_0 | ||
| 386 | local _module_0 = setmetatable({ }, { }) | ||
| 387 | _module_0.itemA = tb | ||
| 388 | getmetatable(_module_0).__index = items | ||
| 389 | _module_0["a-b-c"] = 123 | ||
| 390 | return _module_0 | ||
| 391 | local _module_0 = { } | ||
| 392 | local d, e, f = 3, 2, 1 | ||
| 393 | _module_0[#_module_0 + 1] = d | ||
| 394 | _module_0[#_module_0 + 1] = e | ||
| 395 | _module_0[#_module_0 + 1] = f | ||
| 396 | if this then | ||
| 397 | _module_0[#_module_0 + 1] = 123 | ||
| 398 | else | ||
| 399 | _module_0[#_module_0 + 1] = 456 | ||
| 400 | end | ||
| 401 | local _with_0 = tmp | ||
| 402 | local j = 2000 | ||
| 403 | _module_0[#_module_0 + 1] = _with_0 | ||
| 404 | return _module_0 | ||
| 405 | local _module_0 = nil | ||
| 406 | _module_0 = function() | ||
| 407 | print("hello") | ||
| 408 | return 123 | ||
| 409 | end | ||
| 410 | return _module_0 | ||
| 411 | xpcall(function() | 173 | xpcall(function() |
| 412 | return func(1, 2, 3) | 174 | return func(1, 2, 3) |
| 413 | end, function(err) | 175 | end, function(err) |
| @@ -2395,6 +2157,12 @@ local file | |||
| 2395 | local _with_0 = File("favorite_foods.txt") | 2157 | local _with_0 = File("favorite_foods.txt") |
| 2396 | _with_0:set_encoding("utf8") | 2158 | _with_0:set_encoding("utf8") |
| 2397 | file = _with_0 | 2159 | file = _with_0 |
| 2160 | local result | ||
| 2161 | local _with_0 = obj | ||
| 2162 | repeat | ||
| 2163 | result = _with_0.value | ||
| 2164 | break | ||
| 2165 | until true | ||
| 2398 | local create_person | 2166 | local create_person |
| 2399 | create_person = function(name, relatives) | 2167 | create_person = function(name, relatives) |
| 2400 | local _with_0 = Person() | 2168 | local _with_0 = Person() |
| @@ -2435,6 +2203,12 @@ local file | |||
| 2435 | local _with_0 = File("favorite_foods.txt") | 2203 | local _with_0 = File("favorite_foods.txt") |
| 2436 | _with_0:set_encoding("utf8") | 2204 | _with_0:set_encoding("utf8") |
| 2437 | file = _with_0 | 2205 | file = _with_0 |
| 2206 | local result | ||
| 2207 | local _with_0 = obj | ||
| 2208 | repeat | ||
| 2209 | result = _with_0.value | ||
| 2210 | break | ||
| 2211 | until true | ||
| 2438 | local create_person | 2212 | local create_person |
| 2439 | create_person = function(name, relatives) | 2213 | create_person = function(name, relatives) |
| 2440 | local _with_0 = Person() | 2214 | local _with_0 = Person() |
| @@ -3268,6 +3042,13 @@ for _index_0 = 1, #_list_0 do | |||
| 3268 | break | 3042 | break |
| 3269 | end | 3043 | end |
| 3270 | end | 3044 | end |
| 3045 | local key, score | ||
| 3046 | for k, v in pairs(data) do | ||
| 3047 | if k == "target" then | ||
| 3048 | key, score = k, v * 10 | ||
| 3049 | break | ||
| 3050 | end | ||
| 3051 | end | ||
| 3271 | local func_a | 3052 | local func_a |
| 3272 | func_a = function() | 3053 | func_a = function() |
| 3273 | for i = 1, 10 do | 3054 | for i = 1, 10 do |
| @@ -3330,6 +3111,13 @@ for _index_0 = 1, #_list_0 do | |||
| 3330 | break | 3111 | break |
| 3331 | end | 3112 | end |
| 3332 | end | 3113 | end |
| 3114 | local key, score | ||
| 3115 | for k, v in pairs(data) do | ||
| 3116 | if k == "target" then | ||
| 3117 | key, score = k, v * 10 | ||
| 3118 | break | ||
| 3119 | end | ||
| 3120 | end | ||
| 3333 | local func_a | 3121 | local func_a |
| 3334 | func_a = function() | 3122 | func_a = function() |
| 3335 | for i = 1, 10 do | 3123 | for i = 1, 10 do |
| @@ -4008,11 +3796,32 @@ end | |||
| 4008 | while not (running == false) do | 3796 | while not (running == false) do |
| 4009 | my_function() | 3797 | my_function() |
| 4010 | end | 3798 | end |
| 3799 | local value, doubled | ||
| 3800 | local _val_0, _val_1 | ||
| 3801 | while true do | ||
| 3802 | local n = get_next() | ||
| 3803 | if n > 10 then | ||
| 3804 | _val_0, _val_1 = n, n * 2 | ||
| 3805 | break | ||
| 3806 | end | ||
| 3807 | end | ||
| 3808 | value, doubled = _val_0, _val_1 | ||
| 4011 | local i = 10 | 3809 | local i = 10 |
| 4012 | repeat | 3810 | repeat |
| 4013 | print(i) | 3811 | print(i) |
| 4014 | i = i - 1 | 3812 | i = i - 1 |
| 4015 | until i == 0 | 3813 | until i == 0 |
| 3814 | local i = 1 | ||
| 3815 | local value, scaled | ||
| 3816 | local _val_0, _val_1 | ||
| 3817 | repeat | ||
| 3818 | if i > 3 then | ||
| 3819 | _val_0, _val_1 = i, i * 100 | ||
| 3820 | break | ||
| 3821 | end | ||
| 3822 | i = i + 1 | ||
| 3823 | until false | ||
| 3824 | value, scaled = _val_0, _val_1 | ||
| 4016 | local i = 10 | 3825 | local i = 10 |
| 4017 | while i > 0 do | 3826 | while i > 0 do |
| 4018 | print(i) | 3827 | print(i) |
| @@ -4029,11 +3838,32 @@ end | |||
| 4029 | while not (running == false) do | 3838 | while not (running == false) do |
| 4030 | my_function() | 3839 | my_function() |
| 4031 | end | 3840 | end |
| 3841 | local value, doubled | ||
| 3842 | local _val_0, _val_1 | ||
| 3843 | while true do | ||
| 3844 | local n = get_next() | ||
| 3845 | if n > 10 then | ||
| 3846 | _val_0, _val_1 = n, n * 2 | ||
| 3847 | break | ||
| 3848 | end | ||
| 3849 | end | ||
| 3850 | value, doubled = _val_0, _val_1 | ||
| 4032 | local i = 10 | 3851 | local i = 10 |
| 4033 | repeat | 3852 | repeat |
| 4034 | print(i) | 3853 | print(i) |
| 4035 | i = i - 1 | 3854 | i = i - 1 |
| 4036 | until i == 0 | 3855 | until i == 0 |
| 3856 | local i = 1 | ||
| 3857 | local value, scaled | ||
| 3858 | local _val_0, _val_1 | ||
| 3859 | repeat | ||
| 3860 | if i > 3 then | ||
| 3861 | _val_0, _val_1 = i, i * 100 | ||
| 3862 | break | ||
| 3863 | end | ||
| 3864 | i = i + 1 | ||
| 3865 | until false | ||
| 3866 | value, scaled = _val_0, _val_1 | ||
| 4037 | local my_object = { | 3867 | local my_object = { |
| 4038 | value = 1000, | 3868 | value = 1000, |
| 4039 | write = function(self) | 3869 | write = function(self) |
| @@ -5136,3 +4966,265 @@ fn = function() | |||
| 5136 | return str | 4966 | return str |
| 5137 | end | 4967 | end |
| 5138 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" | 4968 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" |
| 4969 | do | ||
| 4970 | local insert, concat = table.insert, table.concat | ||
| 4971 | local C, Ct, Cmt | ||
| 4972 | do | ||
| 4973 | local _obj_0 = require("lpeg") | ||
| 4974 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 4975 | end | ||
| 4976 | local x, y, z | ||
| 4977 | do | ||
| 4978 | local _obj_0 = require('mymodule') | ||
| 4979 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 4980 | end | ||
| 4981 | local a, b, c | ||
| 4982 | local _obj_0 = require('module') | ||
| 4983 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 4984 | end | ||
| 4985 | do | ||
| 4986 | local module = require('module') | ||
| 4987 | local module_x = require('module_x') | ||
| 4988 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 4989 | local part = require("module.part") | ||
| 4990 | end | ||
| 4991 | do | ||
| 4992 | local PlayerModule = require("player") | ||
| 4993 | local C, Ct, Cmt | ||
| 4994 | do | ||
| 4995 | local _obj_0 = require("lpeg") | ||
| 4996 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 4997 | end | ||
| 4998 | local one, two, ch | ||
| 4999 | local _obj_0 = require("export") | ||
| 5000 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 5001 | end | ||
| 5002 | do | ||
| 5003 | local tostring <const> = tostring | ||
| 5004 | local concat <const> = table.concat | ||
| 5005 | print(concat({ | ||
| 5006 | "a", | ||
| 5007 | tostring(1) | ||
| 5008 | })) | ||
| 5009 | end | ||
| 5010 | do | ||
| 5011 | local print <const> = print | ||
| 5012 | local math <const> = math | ||
| 5013 | print("hello") | ||
| 5014 | math.random(3) | ||
| 5015 | end | ||
| 5016 | do | ||
| 5017 | local print <const> = print | ||
| 5018 | print(FLAG) | ||
| 5019 | FLAG = 123 | ||
| 5020 | end | ||
| 5021 | local _module_0 = { } | ||
| 5022 | local a, b, c = 1, 2, 3 | ||
| 5023 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 5024 | local cool = "cat" | ||
| 5025 | _module_0["cool"] = cool | ||
| 5026 | local What | ||
| 5027 | if this then | ||
| 5028 | What = "abc" | ||
| 5029 | else | ||
| 5030 | What = "def" | ||
| 5031 | end | ||
| 5032 | _module_0["What"] = What | ||
| 5033 | local y | ||
| 5034 | y = function() | ||
| 5035 | local hallo = 3434 | ||
| 5036 | end | ||
| 5037 | _module_0["y"] = y | ||
| 5038 | local Something | ||
| 5039 | local _class_0 | ||
| 5040 | local _base_0 = { | ||
| 5041 | umm = "cool" | ||
| 5042 | } | ||
| 5043 | if _base_0.__index == nil then | ||
| 5044 | _base_0.__index = _base_0 | ||
| 5045 | end | ||
| 5046 | _class_0 = setmetatable({ | ||
| 5047 | __init = function() end, | ||
| 5048 | __base = _base_0, | ||
| 5049 | __name = "Something" | ||
| 5050 | }, { | ||
| 5051 | __index = _base_0, | ||
| 5052 | __call = function(cls, ...) | ||
| 5053 | local _self_0 = setmetatable({ }, _base_0) | ||
| 5054 | cls.__init(_self_0, ...) | ||
| 5055 | return _self_0 | ||
| 5056 | end | ||
| 5057 | }) | ||
| 5058 | _base_0.__class = _class_0 | ||
| 5059 | Something = _class_0 | ||
| 5060 | _module_0["Something"] = Something | ||
| 5061 | return _module_0 | ||
| 5062 | local _module_0 = { } | ||
| 5063 | local loadstring, tolua | ||
| 5064 | do | ||
| 5065 | local _obj_0 = yue | ||
| 5066 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 5067 | end | ||
| 5068 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 5069 | local fieldA = tb.itemA.fieldA | ||
| 5070 | if fieldA == nil then | ||
| 5071 | fieldA = 'default' | ||
| 5072 | end | ||
| 5073 | _module_0["fieldA"] = fieldA | ||
| 5074 | return _module_0 | ||
| 5075 | local _module_0 = setmetatable({ }, { }) | ||
| 5076 | _module_0.itemA = tb | ||
| 5077 | getmetatable(_module_0).__index = items | ||
| 5078 | _module_0["a-b-c"] = 123 | ||
| 5079 | return _module_0 | ||
| 5080 | local _module_0 = { } | ||
| 5081 | local d, e, f = 3, 2, 1 | ||
| 5082 | _module_0[#_module_0 + 1] = d | ||
| 5083 | _module_0[#_module_0 + 1] = e | ||
| 5084 | _module_0[#_module_0 + 1] = f | ||
| 5085 | if this then | ||
| 5086 | _module_0[#_module_0 + 1] = 123 | ||
| 5087 | else | ||
| 5088 | _module_0[#_module_0 + 1] = 456 | ||
| 5089 | end | ||
| 5090 | local _with_0 = tmp | ||
| 5091 | local j = 2000 | ||
| 5092 | _module_0[#_module_0 + 1] = _with_0 | ||
| 5093 | return _module_0 | ||
| 5094 | local _module_0 = nil | ||
| 5095 | _module_0 = function() | ||
| 5096 | print("hello") | ||
| 5097 | return 123 | ||
| 5098 | end | ||
| 5099 | return _module_0 | ||
| 5100 | do | ||
| 5101 | local insert, concat = table.insert, table.concat | ||
| 5102 | local C, Ct, Cmt | ||
| 5103 | do | ||
| 5104 | local _obj_0 = require("lpeg") | ||
| 5105 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 5106 | end | ||
| 5107 | local x, y, z | ||
| 5108 | do | ||
| 5109 | local _obj_0 = require('mymodule') | ||
| 5110 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 5111 | end | ||
| 5112 | local a, b, c | ||
| 5113 | local _obj_0 = require('module') | ||
| 5114 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 5115 | end | ||
| 5116 | do | ||
| 5117 | local module = require('module') | ||
| 5118 | local module_x = require('module_x') | ||
| 5119 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 5120 | local part = require("module.part") | ||
| 5121 | end | ||
| 5122 | do | ||
| 5123 | local PlayerModule = require("player") | ||
| 5124 | local C, Ct, Cmt | ||
| 5125 | do | ||
| 5126 | local _obj_0 = require("lpeg") | ||
| 5127 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 5128 | end | ||
| 5129 | local one, two, ch | ||
| 5130 | local _obj_0 = require("export") | ||
| 5131 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 5132 | end | ||
| 5133 | do | ||
| 5134 | local tostring <const> = tostring | ||
| 5135 | local concat <const> = table.concat | ||
| 5136 | print(concat({ | ||
| 5137 | "a", | ||
| 5138 | tostring(1) | ||
| 5139 | })) | ||
| 5140 | end | ||
| 5141 | do | ||
| 5142 | local print <const> = print | ||
| 5143 | local math <const> = math | ||
| 5144 | print("hello") | ||
| 5145 | math.random(3) | ||
| 5146 | end | ||
| 5147 | do | ||
| 5148 | local print <const> = print | ||
| 5149 | print(FLAG) | ||
| 5150 | FLAG = 123 | ||
| 5151 | end | ||
| 5152 | local _module_0 = { } | ||
| 5153 | local a, b, c = 1, 2, 3 | ||
| 5154 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 5155 | local cool = "cat" | ||
| 5156 | _module_0["cool"] = cool | ||
| 5157 | local What | ||
| 5158 | if this then | ||
| 5159 | What = "abc" | ||
| 5160 | else | ||
| 5161 | What = "def" | ||
| 5162 | end | ||
| 5163 | _module_0["What"] = What | ||
| 5164 | local y | ||
| 5165 | y = function() | ||
| 5166 | local hallo = 3434 | ||
| 5167 | end | ||
| 5168 | _module_0["y"] = y | ||
| 5169 | local Something | ||
| 5170 | local _class_0 | ||
| 5171 | local _base_0 = { | ||
| 5172 | umm = "cool" | ||
| 5173 | } | ||
| 5174 | if _base_0.__index == nil then | ||
| 5175 | _base_0.__index = _base_0 | ||
| 5176 | end | ||
| 5177 | _class_0 = setmetatable({ | ||
| 5178 | __init = function() end, | ||
| 5179 | __base = _base_0, | ||
| 5180 | __name = "Something" | ||
| 5181 | }, { | ||
| 5182 | __index = _base_0, | ||
| 5183 | __call = function(cls, ...) | ||
| 5184 | local _self_0 = setmetatable({ }, _base_0) | ||
| 5185 | cls.__init(_self_0, ...) | ||
| 5186 | return _self_0 | ||
| 5187 | end | ||
| 5188 | }) | ||
| 5189 | _base_0.__class = _class_0 | ||
| 5190 | Something = _class_0 | ||
| 5191 | _module_0["Something"] = Something | ||
| 5192 | return _module_0 | ||
| 5193 | local _module_0 = { } | ||
| 5194 | local loadstring, tolua | ||
| 5195 | do | ||
| 5196 | local _obj_0 = yue | ||
| 5197 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 5198 | end | ||
| 5199 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 5200 | local fieldA = tb.itemA.fieldA | ||
| 5201 | if fieldA == nil then | ||
| 5202 | fieldA = 'default' | ||
| 5203 | end | ||
| 5204 | _module_0["fieldA"] = fieldA | ||
| 5205 | return _module_0 | ||
| 5206 | local _module_0 = setmetatable({ }, { }) | ||
| 5207 | _module_0.itemA = tb | ||
| 5208 | getmetatable(_module_0).__index = items | ||
| 5209 | _module_0["a-b-c"] = 123 | ||
| 5210 | return _module_0 | ||
| 5211 | local _module_0 = { } | ||
| 5212 | local d, e, f = 3, 2, 1 | ||
| 5213 | _module_0[#_module_0 + 1] = d | ||
| 5214 | _module_0[#_module_0 + 1] = e | ||
| 5215 | _module_0[#_module_0 + 1] = f | ||
| 5216 | if this then | ||
| 5217 | _module_0[#_module_0 + 1] = 123 | ||
| 5218 | else | ||
| 5219 | _module_0[#_module_0 + 1] = 456 | ||
| 5220 | end | ||
| 5221 | local _with_0 = tmp | ||
| 5222 | local j = 2000 | ||
| 5223 | _module_0[#_module_0 + 1] = _with_0 | ||
| 5224 | return _module_0 | ||
| 5225 | local _module_0 = nil | ||
| 5226 | _module_0 = function() | ||
| 5227 | print("hello") | ||
| 5228 | return 123 | ||
| 5229 | end | ||
| 5230 | return _module_0 | ||
diff --git a/spec/outputs/codes_from_doc_id-id.lua b/spec/outputs/codes_from_doc_id-id.lua index b024989..7d95eaa 100644 --- a/spec/outputs/codes_from_doc_id-id.lua +++ b/spec/outputs/codes_from_doc_id-id.lua | |||
| @@ -3,6 +3,18 @@ do | |||
| 3 | print(var) | 3 | print(var) |
| 4 | end | 4 | end |
| 5 | print(var) | 5 | print(var) |
| 6 | local status, value | ||
| 7 | do | ||
| 8 | repeat | ||
| 9 | local n = 12 | ||
| 10 | if n > 10 then | ||
| 11 | status, value = "large", n | ||
| 12 | break | ||
| 13 | end | ||
| 14 | status, value = "small", n | ||
| 15 | break | ||
| 16 | until true | ||
| 17 | end | ||
| 6 | local counter | 18 | local counter |
| 7 | do | 19 | do |
| 8 | local i = 0 | 20 | local i = 0 |
| @@ -24,6 +36,18 @@ do | |||
| 24 | print(var) | 36 | print(var) |
| 25 | end | 37 | end |
| 26 | print(var) | 38 | print(var) |
| 39 | local status, value | ||
| 40 | do | ||
| 41 | repeat | ||
| 42 | local n = 12 | ||
| 43 | if n > 10 then | ||
| 44 | status, value = "large", n | ||
| 45 | break | ||
| 46 | end | ||
| 47 | status, value = "small", n | ||
| 48 | break | ||
| 49 | until true | ||
| 50 | end | ||
| 27 | local counter | 51 | local counter |
| 28 | do | 52 | do |
| 29 | local i = 0 | 53 | local i = 0 |
| @@ -146,268 +170,6 @@ end | |||
| 146 | do | 170 | do |
| 147 | print(123, "hello") | 171 | print(123, "hello") |
| 148 | end | 172 | end |
| 149 | do | ||
| 150 | local insert, concat = table.insert, table.concat | ||
| 151 | local C, Ct, Cmt | ||
| 152 | do | ||
| 153 | local _obj_0 = require("lpeg") | ||
| 154 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 155 | end | ||
| 156 | local x, y, z | ||
| 157 | do | ||
| 158 | local _obj_0 = require('mymodule') | ||
| 159 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 160 | end | ||
| 161 | local a, b, c | ||
| 162 | local _obj_0 = require('module') | ||
| 163 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 164 | end | ||
| 165 | do | ||
| 166 | local module = require('module') | ||
| 167 | local module_x = require('module_x') | ||
| 168 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 169 | local part = require("module.part") | ||
| 170 | end | ||
| 171 | do | ||
| 172 | local PlayerModule = require("player") | ||
| 173 | local C, Ct, Cmt | ||
| 174 | do | ||
| 175 | local _obj_0 = require("lpeg") | ||
| 176 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 177 | end | ||
| 178 | local one, two, ch | ||
| 179 | local _obj_0 = require("export") | ||
| 180 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 181 | end | ||
| 182 | do | ||
| 183 | local tostring <const> = tostring | ||
| 184 | local concat <const> = table.concat | ||
| 185 | print(concat({ | ||
| 186 | "a", | ||
| 187 | tostring(1) | ||
| 188 | })) | ||
| 189 | end | ||
| 190 | do | ||
| 191 | local print <const> = print | ||
| 192 | local math <const> = math | ||
| 193 | print("hello") | ||
| 194 | math.random(3) | ||
| 195 | end | ||
| 196 | do | ||
| 197 | local print <const> = print | ||
| 198 | print(FLAG) | ||
| 199 | FLAG = 123 | ||
| 200 | end | ||
| 201 | local _module_0 = { } | ||
| 202 | local a, b, c = 1, 2, 3 | ||
| 203 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 204 | local cool = "cat" | ||
| 205 | _module_0["cool"] = cool | ||
| 206 | local What | ||
| 207 | if this then | ||
| 208 | What = "abc" | ||
| 209 | else | ||
| 210 | What = "def" | ||
| 211 | end | ||
| 212 | _module_0["What"] = What | ||
| 213 | local y | ||
| 214 | y = function() | ||
| 215 | local hallo = 3434 | ||
| 216 | end | ||
| 217 | _module_0["y"] = y | ||
| 218 | local Something | ||
| 219 | local _class_0 | ||
| 220 | local _base_0 = { | ||
| 221 | umm = "cool" | ||
| 222 | } | ||
| 223 | if _base_0.__index == nil then | ||
| 224 | _base_0.__index = _base_0 | ||
| 225 | end | ||
| 226 | _class_0 = setmetatable({ | ||
| 227 | __init = function() end, | ||
| 228 | __base = _base_0, | ||
| 229 | __name = "Something" | ||
| 230 | }, { | ||
| 231 | __index = _base_0, | ||
| 232 | __call = function(cls, ...) | ||
| 233 | local _self_0 = setmetatable({ }, _base_0) | ||
| 234 | cls.__init(_self_0, ...) | ||
| 235 | return _self_0 | ||
| 236 | end | ||
| 237 | }) | ||
| 238 | _base_0.__class = _class_0 | ||
| 239 | Something = _class_0 | ||
| 240 | _module_0["Something"] = Something | ||
| 241 | return _module_0 | ||
| 242 | local _module_0 = { } | ||
| 243 | local loadstring, tolua | ||
| 244 | do | ||
| 245 | local _obj_0 = yue | ||
| 246 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 247 | end | ||
| 248 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 249 | local fieldA = tb.itemA.fieldA | ||
| 250 | if fieldA == nil then | ||
| 251 | fieldA = 'default' | ||
| 252 | end | ||
| 253 | _module_0["fieldA"] = fieldA | ||
| 254 | return _module_0 | ||
| 255 | local _module_0 = setmetatable({ }, { }) | ||
| 256 | _module_0.itemA = tb | ||
| 257 | getmetatable(_module_0).__index = items | ||
| 258 | _module_0["a-b-c"] = 123 | ||
| 259 | return _module_0 | ||
| 260 | local _module_0 = { } | ||
| 261 | local d, e, f = 3, 2, 1 | ||
| 262 | _module_0[#_module_0 + 1] = d | ||
| 263 | _module_0[#_module_0 + 1] = e | ||
| 264 | _module_0[#_module_0 + 1] = f | ||
| 265 | if this then | ||
| 266 | _module_0[#_module_0 + 1] = 123 | ||
| 267 | else | ||
| 268 | _module_0[#_module_0 + 1] = 456 | ||
| 269 | end | ||
| 270 | local _with_0 = tmp | ||
| 271 | local j = 2000 | ||
| 272 | _module_0[#_module_0 + 1] = _with_0 | ||
| 273 | return _module_0 | ||
| 274 | local _module_0 = nil | ||
| 275 | _module_0 = function() | ||
| 276 | print("hello") | ||
| 277 | return 123 | ||
| 278 | end | ||
| 279 | return _module_0 | ||
| 280 | do | ||
| 281 | local insert, concat = table.insert, table.concat | ||
| 282 | local C, Ct, Cmt | ||
| 283 | do | ||
| 284 | local _obj_0 = require("lpeg") | ||
| 285 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 286 | end | ||
| 287 | local x, y, z | ||
| 288 | do | ||
| 289 | local _obj_0 = require('mymodule') | ||
| 290 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 291 | end | ||
| 292 | local a, b, c | ||
| 293 | local _obj_0 = require('module') | ||
| 294 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 295 | end | ||
| 296 | do | ||
| 297 | local module = require('module') | ||
| 298 | local module_x = require('module_x') | ||
| 299 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 300 | local part = require("module.part") | ||
| 301 | end | ||
| 302 | do | ||
| 303 | local PlayerModule = require("player") | ||
| 304 | local C, Ct, Cmt | ||
| 305 | do | ||
| 306 | local _obj_0 = require("lpeg") | ||
| 307 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 308 | end | ||
| 309 | local one, two, ch | ||
| 310 | local _obj_0 = require("export") | ||
| 311 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 312 | end | ||
| 313 | do | ||
| 314 | local tostring <const> = tostring | ||
| 315 | local concat <const> = table.concat | ||
| 316 | print(concat({ | ||
| 317 | "a", | ||
| 318 | tostring(1) | ||
| 319 | })) | ||
| 320 | end | ||
| 321 | do | ||
| 322 | local print <const> = print | ||
| 323 | local math <const> = math | ||
| 324 | print("hello") | ||
| 325 | math.random(3) | ||
| 326 | end | ||
| 327 | do | ||
| 328 | local print <const> = print | ||
| 329 | print(FLAG) | ||
| 330 | FLAG = 123 | ||
| 331 | end | ||
| 332 | local _module_0 = { } | ||
| 333 | local a, b, c = 1, 2, 3 | ||
| 334 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 335 | local cool = "cat" | ||
| 336 | _module_0["cool"] = cool | ||
| 337 | local What | ||
| 338 | if this then | ||
| 339 | What = "abc" | ||
| 340 | else | ||
| 341 | What = "def" | ||
| 342 | end | ||
| 343 | _module_0["What"] = What | ||
| 344 | local y | ||
| 345 | y = function() | ||
| 346 | local hallo = 3434 | ||
| 347 | end | ||
| 348 | _module_0["y"] = y | ||
| 349 | local Something | ||
| 350 | local _class_0 | ||
| 351 | local _base_0 = { | ||
| 352 | umm = "cool" | ||
| 353 | } | ||
| 354 | if _base_0.__index == nil then | ||
| 355 | _base_0.__index = _base_0 | ||
| 356 | end | ||
| 357 | _class_0 = setmetatable({ | ||
| 358 | __init = function() end, | ||
| 359 | __base = _base_0, | ||
| 360 | __name = "Something" | ||
| 361 | }, { | ||
| 362 | __index = _base_0, | ||
| 363 | __call = function(cls, ...) | ||
| 364 | local _self_0 = setmetatable({ }, _base_0) | ||
| 365 | cls.__init(_self_0, ...) | ||
| 366 | return _self_0 | ||
| 367 | end | ||
| 368 | }) | ||
| 369 | _base_0.__class = _class_0 | ||
| 370 | Something = _class_0 | ||
| 371 | _module_0["Something"] = Something | ||
| 372 | return _module_0 | ||
| 373 | local _module_0 = { } | ||
| 374 | local loadstring, tolua | ||
| 375 | do | ||
| 376 | local _obj_0 = yue | ||
| 377 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 378 | end | ||
| 379 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 380 | local fieldA = tb.itemA.fieldA | ||
| 381 | if fieldA == nil then | ||
| 382 | fieldA = 'default' | ||
| 383 | end | ||
| 384 | _module_0["fieldA"] = fieldA | ||
| 385 | return _module_0 | ||
| 386 | local _module_0 = setmetatable({ }, { }) | ||
| 387 | _module_0.itemA = tb | ||
| 388 | getmetatable(_module_0).__index = items | ||
| 389 | _module_0["a-b-c"] = 123 | ||
| 390 | return _module_0 | ||
| 391 | local _module_0 = { } | ||
| 392 | local d, e, f = 3, 2, 1 | ||
| 393 | _module_0[#_module_0 + 1] = d | ||
| 394 | _module_0[#_module_0 + 1] = e | ||
| 395 | _module_0[#_module_0 + 1] = f | ||
| 396 | if this then | ||
| 397 | _module_0[#_module_0 + 1] = 123 | ||
| 398 | else | ||
| 399 | _module_0[#_module_0 + 1] = 456 | ||
| 400 | end | ||
| 401 | local _with_0 = tmp | ||
| 402 | local j = 2000 | ||
| 403 | _module_0[#_module_0 + 1] = _with_0 | ||
| 404 | return _module_0 | ||
| 405 | local _module_0 = nil | ||
| 406 | _module_0 = function() | ||
| 407 | print("hello") | ||
| 408 | return 123 | ||
| 409 | end | ||
| 410 | return _module_0 | ||
| 411 | xpcall(function() | 173 | xpcall(function() |
| 412 | return func(1, 2, 3) | 174 | return func(1, 2, 3) |
| 413 | end, function(err) | 175 | end, function(err) |
| @@ -2395,6 +2157,12 @@ local file | |||
| 2395 | local _with_0 = File("favorite_foods.txt") | 2157 | local _with_0 = File("favorite_foods.txt") |
| 2396 | _with_0:set_encoding("utf8") | 2158 | _with_0:set_encoding("utf8") |
| 2397 | file = _with_0 | 2159 | file = _with_0 |
| 2160 | local result | ||
| 2161 | local _with_0 = obj | ||
| 2162 | repeat | ||
| 2163 | result = _with_0.value | ||
| 2164 | break | ||
| 2165 | until true | ||
| 2398 | local create_person | 2166 | local create_person |
| 2399 | create_person = function(name, relatives) | 2167 | create_person = function(name, relatives) |
| 2400 | local _with_0 = Person() | 2168 | local _with_0 = Person() |
| @@ -2435,6 +2203,12 @@ local file | |||
| 2435 | local _with_0 = File("favorite_foods.txt") | 2203 | local _with_0 = File("favorite_foods.txt") |
| 2436 | _with_0:set_encoding("utf8") | 2204 | _with_0:set_encoding("utf8") |
| 2437 | file = _with_0 | 2205 | file = _with_0 |
| 2206 | local result | ||
| 2207 | local _with_0 = obj | ||
| 2208 | repeat | ||
| 2209 | result = _with_0.value | ||
| 2210 | break | ||
| 2211 | until true | ||
| 2438 | local create_person | 2212 | local create_person |
| 2439 | create_person = function(name, relatives) | 2213 | create_person = function(name, relatives) |
| 2440 | local _with_0 = Person() | 2214 | local _with_0 = Person() |
| @@ -3268,6 +3042,13 @@ for _index_0 = 1, #_list_0 do | |||
| 3268 | break | 3042 | break |
| 3269 | end | 3043 | end |
| 3270 | end | 3044 | end |
| 3045 | local key, score | ||
| 3046 | for k, v in pairs(data) do | ||
| 3047 | if k == "target" then | ||
| 3048 | key, score = k, v * 10 | ||
| 3049 | break | ||
| 3050 | end | ||
| 3051 | end | ||
| 3271 | local func_a | 3052 | local func_a |
| 3272 | func_a = function() | 3053 | func_a = function() |
| 3273 | for i = 1, 10 do | 3054 | for i = 1, 10 do |
| @@ -3330,6 +3111,13 @@ for _index_0 = 1, #_list_0 do | |||
| 3330 | break | 3111 | break |
| 3331 | end | 3112 | end |
| 3332 | end | 3113 | end |
| 3114 | local key, score | ||
| 3115 | for k, v in pairs(data) do | ||
| 3116 | if k == "target" then | ||
| 3117 | key, score = k, v * 10 | ||
| 3118 | break | ||
| 3119 | end | ||
| 3120 | end | ||
| 3333 | local func_a | 3121 | local func_a |
| 3334 | func_a = function() | 3122 | func_a = function() |
| 3335 | for i = 1, 10 do | 3123 | for i = 1, 10 do |
| @@ -4008,11 +3796,32 @@ end | |||
| 4008 | while not (running == false) do | 3796 | while not (running == false) do |
| 4009 | my_function() | 3797 | my_function() |
| 4010 | end | 3798 | end |
| 3799 | local value, doubled | ||
| 3800 | local _val_0, _val_1 | ||
| 3801 | while true do | ||
| 3802 | local n = get_next() | ||
| 3803 | if n > 10 then | ||
| 3804 | _val_0, _val_1 = n, n * 2 | ||
| 3805 | break | ||
| 3806 | end | ||
| 3807 | end | ||
| 3808 | value, doubled = _val_0, _val_1 | ||
| 4011 | local i = 10 | 3809 | local i = 10 |
| 4012 | repeat | 3810 | repeat |
| 4013 | print(i) | 3811 | print(i) |
| 4014 | i = i - 1 | 3812 | i = i - 1 |
| 4015 | until i == 0 | 3813 | until i == 0 |
| 3814 | local i = 1 | ||
| 3815 | local value, scaled | ||
| 3816 | local _val_0, _val_1 | ||
| 3817 | repeat | ||
| 3818 | if i > 3 then | ||
| 3819 | _val_0, _val_1 = i, i * 100 | ||
| 3820 | break | ||
| 3821 | end | ||
| 3822 | i = i + 1 | ||
| 3823 | until false | ||
| 3824 | value, scaled = _val_0, _val_1 | ||
| 4016 | local i = 10 | 3825 | local i = 10 |
| 4017 | while i > 0 do | 3826 | while i > 0 do |
| 4018 | print(i) | 3827 | print(i) |
| @@ -4029,11 +3838,32 @@ end | |||
| 4029 | while not (running == false) do | 3838 | while not (running == false) do |
| 4030 | my_function() | 3839 | my_function() |
| 4031 | end | 3840 | end |
| 3841 | local value, doubled | ||
| 3842 | local _val_0, _val_1 | ||
| 3843 | while true do | ||
| 3844 | local n = get_next() | ||
| 3845 | if n > 10 then | ||
| 3846 | _val_0, _val_1 = n, n * 2 | ||
| 3847 | break | ||
| 3848 | end | ||
| 3849 | end | ||
| 3850 | value, doubled = _val_0, _val_1 | ||
| 4032 | local i = 10 | 3851 | local i = 10 |
| 4033 | repeat | 3852 | repeat |
| 4034 | print(i) | 3853 | print(i) |
| 4035 | i = i - 1 | 3854 | i = i - 1 |
| 4036 | until i == 0 | 3855 | until i == 0 |
| 3856 | local i = 1 | ||
| 3857 | local value, scaled | ||
| 3858 | local _val_0, _val_1 | ||
| 3859 | repeat | ||
| 3860 | if i > 3 then | ||
| 3861 | _val_0, _val_1 = i, i * 100 | ||
| 3862 | break | ||
| 3863 | end | ||
| 3864 | i = i + 1 | ||
| 3865 | until false | ||
| 3866 | value, scaled = _val_0, _val_1 | ||
| 4037 | local my_object = { | 3867 | local my_object = { |
| 4038 | value = 1000, | 3868 | value = 1000, |
| 4039 | write = function(self) | 3869 | write = function(self) |
| @@ -5136,3 +4966,265 @@ fn = function() | |||
| 5136 | return str | 4966 | return str |
| 5137 | end | 4967 | end |
| 5138 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" | 4968 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" |
| 4969 | do | ||
| 4970 | local insert, concat = table.insert, table.concat | ||
| 4971 | local C, Ct, Cmt | ||
| 4972 | do | ||
| 4973 | local _obj_0 = require("lpeg") | ||
| 4974 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 4975 | end | ||
| 4976 | local x, y, z | ||
| 4977 | do | ||
| 4978 | local _obj_0 = require('mymodule') | ||
| 4979 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 4980 | end | ||
| 4981 | local a, b, c | ||
| 4982 | local _obj_0 = require('module') | ||
| 4983 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 4984 | end | ||
| 4985 | do | ||
| 4986 | local module = require('module') | ||
| 4987 | local module_x = require('module_x') | ||
| 4988 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 4989 | local part = require("module.part") | ||
| 4990 | end | ||
| 4991 | do | ||
| 4992 | local PlayerModule = require("player") | ||
| 4993 | local C, Ct, Cmt | ||
| 4994 | do | ||
| 4995 | local _obj_0 = require("lpeg") | ||
| 4996 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 4997 | end | ||
| 4998 | local one, two, ch | ||
| 4999 | local _obj_0 = require("export") | ||
| 5000 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 5001 | end | ||
| 5002 | do | ||
| 5003 | local tostring <const> = tostring | ||
| 5004 | local concat <const> = table.concat | ||
| 5005 | print(concat({ | ||
| 5006 | "a", | ||
| 5007 | tostring(1) | ||
| 5008 | })) | ||
| 5009 | end | ||
| 5010 | do | ||
| 5011 | local print <const> = print | ||
| 5012 | local math <const> = math | ||
| 5013 | print("hello") | ||
| 5014 | math.random(3) | ||
| 5015 | end | ||
| 5016 | do | ||
| 5017 | local print <const> = print | ||
| 5018 | print(FLAG) | ||
| 5019 | FLAG = 123 | ||
| 5020 | end | ||
| 5021 | local _module_0 = { } | ||
| 5022 | local a, b, c = 1, 2, 3 | ||
| 5023 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 5024 | local cool = "cat" | ||
| 5025 | _module_0["cool"] = cool | ||
| 5026 | local What | ||
| 5027 | if this then | ||
| 5028 | What = "abc" | ||
| 5029 | else | ||
| 5030 | What = "def" | ||
| 5031 | end | ||
| 5032 | _module_0["What"] = What | ||
| 5033 | local y | ||
| 5034 | y = function() | ||
| 5035 | local hallo = 3434 | ||
| 5036 | end | ||
| 5037 | _module_0["y"] = y | ||
| 5038 | local Something | ||
| 5039 | local _class_0 | ||
| 5040 | local _base_0 = { | ||
| 5041 | umm = "cool" | ||
| 5042 | } | ||
| 5043 | if _base_0.__index == nil then | ||
| 5044 | _base_0.__index = _base_0 | ||
| 5045 | end | ||
| 5046 | _class_0 = setmetatable({ | ||
| 5047 | __init = function() end, | ||
| 5048 | __base = _base_0, | ||
| 5049 | __name = "Something" | ||
| 5050 | }, { | ||
| 5051 | __index = _base_0, | ||
| 5052 | __call = function(cls, ...) | ||
| 5053 | local _self_0 = setmetatable({ }, _base_0) | ||
| 5054 | cls.__init(_self_0, ...) | ||
| 5055 | return _self_0 | ||
| 5056 | end | ||
| 5057 | }) | ||
| 5058 | _base_0.__class = _class_0 | ||
| 5059 | Something = _class_0 | ||
| 5060 | _module_0["Something"] = Something | ||
| 5061 | return _module_0 | ||
| 5062 | local _module_0 = { } | ||
| 5063 | local loadstring, tolua | ||
| 5064 | do | ||
| 5065 | local _obj_0 = yue | ||
| 5066 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 5067 | end | ||
| 5068 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 5069 | local fieldA = tb.itemA.fieldA | ||
| 5070 | if fieldA == nil then | ||
| 5071 | fieldA = 'default' | ||
| 5072 | end | ||
| 5073 | _module_0["fieldA"] = fieldA | ||
| 5074 | return _module_0 | ||
| 5075 | local _module_0 = setmetatable({ }, { }) | ||
| 5076 | _module_0.itemA = tb | ||
| 5077 | getmetatable(_module_0).__index = items | ||
| 5078 | _module_0["a-b-c"] = 123 | ||
| 5079 | return _module_0 | ||
| 5080 | local _module_0 = { } | ||
| 5081 | local d, e, f = 3, 2, 1 | ||
| 5082 | _module_0[#_module_0 + 1] = d | ||
| 5083 | _module_0[#_module_0 + 1] = e | ||
| 5084 | _module_0[#_module_0 + 1] = f | ||
| 5085 | if this then | ||
| 5086 | _module_0[#_module_0 + 1] = 123 | ||
| 5087 | else | ||
| 5088 | _module_0[#_module_0 + 1] = 456 | ||
| 5089 | end | ||
| 5090 | local _with_0 = tmp | ||
| 5091 | local j = 2000 | ||
| 5092 | _module_0[#_module_0 + 1] = _with_0 | ||
| 5093 | return _module_0 | ||
| 5094 | local _module_0 = nil | ||
| 5095 | _module_0 = function() | ||
| 5096 | print("hello") | ||
| 5097 | return 123 | ||
| 5098 | end | ||
| 5099 | return _module_0 | ||
| 5100 | do | ||
| 5101 | local insert, concat = table.insert, table.concat | ||
| 5102 | local C, Ct, Cmt | ||
| 5103 | do | ||
| 5104 | local _obj_0 = require("lpeg") | ||
| 5105 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 5106 | end | ||
| 5107 | local x, y, z | ||
| 5108 | do | ||
| 5109 | local _obj_0 = require('mymodule') | ||
| 5110 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 5111 | end | ||
| 5112 | local a, b, c | ||
| 5113 | local _obj_0 = require('module') | ||
| 5114 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 5115 | end | ||
| 5116 | do | ||
| 5117 | local module = require('module') | ||
| 5118 | local module_x = require('module_x') | ||
| 5119 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 5120 | local part = require("module.part") | ||
| 5121 | end | ||
| 5122 | do | ||
| 5123 | local PlayerModule = require("player") | ||
| 5124 | local C, Ct, Cmt | ||
| 5125 | do | ||
| 5126 | local _obj_0 = require("lpeg") | ||
| 5127 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 5128 | end | ||
| 5129 | local one, two, ch | ||
| 5130 | local _obj_0 = require("export") | ||
| 5131 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 5132 | end | ||
| 5133 | do | ||
| 5134 | local tostring <const> = tostring | ||
| 5135 | local concat <const> = table.concat | ||
| 5136 | print(concat({ | ||
| 5137 | "a", | ||
| 5138 | tostring(1) | ||
| 5139 | })) | ||
| 5140 | end | ||
| 5141 | do | ||
| 5142 | local print <const> = print | ||
| 5143 | local math <const> = math | ||
| 5144 | print("hello") | ||
| 5145 | math.random(3) | ||
| 5146 | end | ||
| 5147 | do | ||
| 5148 | local print <const> = print | ||
| 5149 | print(FLAG) | ||
| 5150 | FLAG = 123 | ||
| 5151 | end | ||
| 5152 | local _module_0 = { } | ||
| 5153 | local a, b, c = 1, 2, 3 | ||
| 5154 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 5155 | local cool = "cat" | ||
| 5156 | _module_0["cool"] = cool | ||
| 5157 | local What | ||
| 5158 | if this then | ||
| 5159 | What = "abc" | ||
| 5160 | else | ||
| 5161 | What = "def" | ||
| 5162 | end | ||
| 5163 | _module_0["What"] = What | ||
| 5164 | local y | ||
| 5165 | y = function() | ||
| 5166 | local hallo = 3434 | ||
| 5167 | end | ||
| 5168 | _module_0["y"] = y | ||
| 5169 | local Something | ||
| 5170 | local _class_0 | ||
| 5171 | local _base_0 = { | ||
| 5172 | umm = "cool" | ||
| 5173 | } | ||
| 5174 | if _base_0.__index == nil then | ||
| 5175 | _base_0.__index = _base_0 | ||
| 5176 | end | ||
| 5177 | _class_0 = setmetatable({ | ||
| 5178 | __init = function() end, | ||
| 5179 | __base = _base_0, | ||
| 5180 | __name = "Something" | ||
| 5181 | }, { | ||
| 5182 | __index = _base_0, | ||
| 5183 | __call = function(cls, ...) | ||
| 5184 | local _self_0 = setmetatable({ }, _base_0) | ||
| 5185 | cls.__init(_self_0, ...) | ||
| 5186 | return _self_0 | ||
| 5187 | end | ||
| 5188 | }) | ||
| 5189 | _base_0.__class = _class_0 | ||
| 5190 | Something = _class_0 | ||
| 5191 | _module_0["Something"] = Something | ||
| 5192 | return _module_0 | ||
| 5193 | local _module_0 = { } | ||
| 5194 | local loadstring, tolua | ||
| 5195 | do | ||
| 5196 | local _obj_0 = yue | ||
| 5197 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 5198 | end | ||
| 5199 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 5200 | local fieldA = tb.itemA.fieldA | ||
| 5201 | if fieldA == nil then | ||
| 5202 | fieldA = 'default' | ||
| 5203 | end | ||
| 5204 | _module_0["fieldA"] = fieldA | ||
| 5205 | return _module_0 | ||
| 5206 | local _module_0 = setmetatable({ }, { }) | ||
| 5207 | _module_0.itemA = tb | ||
| 5208 | getmetatable(_module_0).__index = items | ||
| 5209 | _module_0["a-b-c"] = 123 | ||
| 5210 | return _module_0 | ||
| 5211 | local _module_0 = { } | ||
| 5212 | local d, e, f = 3, 2, 1 | ||
| 5213 | _module_0[#_module_0 + 1] = d | ||
| 5214 | _module_0[#_module_0 + 1] = e | ||
| 5215 | _module_0[#_module_0 + 1] = f | ||
| 5216 | if this then | ||
| 5217 | _module_0[#_module_0 + 1] = 123 | ||
| 5218 | else | ||
| 5219 | _module_0[#_module_0 + 1] = 456 | ||
| 5220 | end | ||
| 5221 | local _with_0 = tmp | ||
| 5222 | local j = 2000 | ||
| 5223 | _module_0[#_module_0 + 1] = _with_0 | ||
| 5224 | return _module_0 | ||
| 5225 | local _module_0 = nil | ||
| 5226 | _module_0 = function() | ||
| 5227 | print("hello") | ||
| 5228 | return 123 | ||
| 5229 | end | ||
| 5230 | return _module_0 | ||
diff --git a/spec/outputs/codes_from_doc_pt-br.lua b/spec/outputs/codes_from_doc_pt-br.lua index f5643c8..caa15d6 100644 --- a/spec/outputs/codes_from_doc_pt-br.lua +++ b/spec/outputs/codes_from_doc_pt-br.lua | |||
| @@ -3,6 +3,18 @@ do | |||
| 3 | print(var) | 3 | print(var) |
| 4 | end | 4 | end |
| 5 | print(var) | 5 | print(var) |
| 6 | local status, value | ||
| 7 | do | ||
| 8 | repeat | ||
| 9 | local n = 12 | ||
| 10 | if n > 10 then | ||
| 11 | status, value = "large", n | ||
| 12 | break | ||
| 13 | end | ||
| 14 | status, value = "small", n | ||
| 15 | break | ||
| 16 | until true | ||
| 17 | end | ||
| 6 | local counter | 18 | local counter |
| 7 | do | 19 | do |
| 8 | local i = 0 | 20 | local i = 0 |
| @@ -24,6 +36,18 @@ do | |||
| 24 | print(var) | 36 | print(var) |
| 25 | end | 37 | end |
| 26 | print(var) | 38 | print(var) |
| 39 | local status, value | ||
| 40 | do | ||
| 41 | repeat | ||
| 42 | local n = 12 | ||
| 43 | if n > 10 then | ||
| 44 | status, value = "large", n | ||
| 45 | break | ||
| 46 | end | ||
| 47 | status, value = "small", n | ||
| 48 | break | ||
| 49 | until true | ||
| 50 | end | ||
| 27 | local counter | 51 | local counter |
| 28 | do | 52 | do |
| 29 | local i = 0 | 53 | local i = 0 |
| @@ -146,268 +170,6 @@ end | |||
| 146 | do | 170 | do |
| 147 | print(123, "hello") | 171 | print(123, "hello") |
| 148 | end | 172 | end |
| 149 | do | ||
| 150 | local insert, concat = table.insert, table.concat | ||
| 151 | local C, Ct, Cmt | ||
| 152 | do | ||
| 153 | local _obj_0 = require("lpeg") | ||
| 154 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 155 | end | ||
| 156 | local x, y, z | ||
| 157 | do | ||
| 158 | local _obj_0 = require('mymodule') | ||
| 159 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 160 | end | ||
| 161 | local a, b, c | ||
| 162 | local _obj_0 = require('module') | ||
| 163 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 164 | end | ||
| 165 | do | ||
| 166 | local module = require('module') | ||
| 167 | local module_x = require('module_x') | ||
| 168 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 169 | local part = require("module.part") | ||
| 170 | end | ||
| 171 | do | ||
| 172 | local PlayerModule = require("player") | ||
| 173 | local C, Ct, Cmt | ||
| 174 | do | ||
| 175 | local _obj_0 = require("lpeg") | ||
| 176 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 177 | end | ||
| 178 | local one, two, ch | ||
| 179 | local _obj_0 = require("export") | ||
| 180 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 181 | end | ||
| 182 | do | ||
| 183 | local tostring <const> = tostring | ||
| 184 | local concat <const> = table.concat | ||
| 185 | print(concat({ | ||
| 186 | "a", | ||
| 187 | tostring(1) | ||
| 188 | })) | ||
| 189 | end | ||
| 190 | do | ||
| 191 | local print <const> = print | ||
| 192 | local math <const> = math | ||
| 193 | print("hello") | ||
| 194 | math.random(3) | ||
| 195 | end | ||
| 196 | do | ||
| 197 | local print <const> = print | ||
| 198 | print(FLAG) | ||
| 199 | FLAG = 123 | ||
| 200 | end | ||
| 201 | local _module_0 = { } | ||
| 202 | local a, b, c = 1, 2, 3 | ||
| 203 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 204 | local cool = "cat" | ||
| 205 | _module_0["cool"] = cool | ||
| 206 | local What | ||
| 207 | if this then | ||
| 208 | What = "abc" | ||
| 209 | else | ||
| 210 | What = "def" | ||
| 211 | end | ||
| 212 | _module_0["What"] = What | ||
| 213 | local y | ||
| 214 | y = function() | ||
| 215 | local hallo = 3434 | ||
| 216 | end | ||
| 217 | _module_0["y"] = y | ||
| 218 | local Something | ||
| 219 | local _class_0 | ||
| 220 | local _base_0 = { | ||
| 221 | umm = "cool" | ||
| 222 | } | ||
| 223 | if _base_0.__index == nil then | ||
| 224 | _base_0.__index = _base_0 | ||
| 225 | end | ||
| 226 | _class_0 = setmetatable({ | ||
| 227 | __init = function() end, | ||
| 228 | __base = _base_0, | ||
| 229 | __name = "Something" | ||
| 230 | }, { | ||
| 231 | __index = _base_0, | ||
| 232 | __call = function(cls, ...) | ||
| 233 | local _self_0 = setmetatable({ }, _base_0) | ||
| 234 | cls.__init(_self_0, ...) | ||
| 235 | return _self_0 | ||
| 236 | end | ||
| 237 | }) | ||
| 238 | _base_0.__class = _class_0 | ||
| 239 | Something = _class_0 | ||
| 240 | _module_0["Something"] = Something | ||
| 241 | return _module_0 | ||
| 242 | local _module_0 = { } | ||
| 243 | local loadstring, tolua | ||
| 244 | do | ||
| 245 | local _obj_0 = yue | ||
| 246 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 247 | end | ||
| 248 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 249 | local fieldA = tb.itemA.fieldA | ||
| 250 | if fieldA == nil then | ||
| 251 | fieldA = 'default' | ||
| 252 | end | ||
| 253 | _module_0["fieldA"] = fieldA | ||
| 254 | return _module_0 | ||
| 255 | local _module_0 = setmetatable({ }, { }) | ||
| 256 | _module_0.itemA = tb | ||
| 257 | getmetatable(_module_0).__index = items | ||
| 258 | _module_0["a-b-c"] = 123 | ||
| 259 | return _module_0 | ||
| 260 | local _module_0 = { } | ||
| 261 | local d, e, f = 3, 2, 1 | ||
| 262 | _module_0[#_module_0 + 1] = d | ||
| 263 | _module_0[#_module_0 + 1] = e | ||
| 264 | _module_0[#_module_0 + 1] = f | ||
| 265 | if this then | ||
| 266 | _module_0[#_module_0 + 1] = 123 | ||
| 267 | else | ||
| 268 | _module_0[#_module_0 + 1] = 456 | ||
| 269 | end | ||
| 270 | local _with_0 = tmp | ||
| 271 | local j = 2000 | ||
| 272 | _module_0[#_module_0 + 1] = _with_0 | ||
| 273 | return _module_0 | ||
| 274 | local _module_0 = nil | ||
| 275 | _module_0 = function() | ||
| 276 | print("hello") | ||
| 277 | return 123 | ||
| 278 | end | ||
| 279 | return _module_0 | ||
| 280 | do | ||
| 281 | local insert, concat = table.insert, table.concat | ||
| 282 | local C, Ct, Cmt | ||
| 283 | do | ||
| 284 | local _obj_0 = require("lpeg") | ||
| 285 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 286 | end | ||
| 287 | local x, y, z | ||
| 288 | do | ||
| 289 | local _obj_0 = require('mymodule') | ||
| 290 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 291 | end | ||
| 292 | local a, b, c | ||
| 293 | local _obj_0 = require('module') | ||
| 294 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 295 | end | ||
| 296 | do | ||
| 297 | local module = require('module') | ||
| 298 | local module_x = require('module_x') | ||
| 299 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 300 | local part = require("module.part") | ||
| 301 | end | ||
| 302 | do | ||
| 303 | local PlayerModule = require("player") | ||
| 304 | local C, Ct, Cmt | ||
| 305 | do | ||
| 306 | local _obj_0 = require("lpeg") | ||
| 307 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 308 | end | ||
| 309 | local one, two, ch | ||
| 310 | local _obj_0 = require("export") | ||
| 311 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 312 | end | ||
| 313 | do | ||
| 314 | local tostring <const> = tostring | ||
| 315 | local concat <const> = table.concat | ||
| 316 | print(concat({ | ||
| 317 | "a", | ||
| 318 | tostring(1) | ||
| 319 | })) | ||
| 320 | end | ||
| 321 | do | ||
| 322 | local print <const> = print | ||
| 323 | local math <const> = math | ||
| 324 | print("hello") | ||
| 325 | math.random(3) | ||
| 326 | end | ||
| 327 | do | ||
| 328 | local print <const> = print | ||
| 329 | print(FLAG) | ||
| 330 | FLAG = 123 | ||
| 331 | end | ||
| 332 | local _module_0 = { } | ||
| 333 | local a, b, c = 1, 2, 3 | ||
| 334 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 335 | local cool = "cat" | ||
| 336 | _module_0["cool"] = cool | ||
| 337 | local What | ||
| 338 | if this then | ||
| 339 | What = "abc" | ||
| 340 | else | ||
| 341 | What = "def" | ||
| 342 | end | ||
| 343 | _module_0["What"] = What | ||
| 344 | local y | ||
| 345 | y = function() | ||
| 346 | local hallo = 3434 | ||
| 347 | end | ||
| 348 | _module_0["y"] = y | ||
| 349 | local Something | ||
| 350 | local _class_0 | ||
| 351 | local _base_0 = { | ||
| 352 | umm = "cool" | ||
| 353 | } | ||
| 354 | if _base_0.__index == nil then | ||
| 355 | _base_0.__index = _base_0 | ||
| 356 | end | ||
| 357 | _class_0 = setmetatable({ | ||
| 358 | __init = function() end, | ||
| 359 | __base = _base_0, | ||
| 360 | __name = "Something" | ||
| 361 | }, { | ||
| 362 | __index = _base_0, | ||
| 363 | __call = function(cls, ...) | ||
| 364 | local _self_0 = setmetatable({ }, _base_0) | ||
| 365 | cls.__init(_self_0, ...) | ||
| 366 | return _self_0 | ||
| 367 | end | ||
| 368 | }) | ||
| 369 | _base_0.__class = _class_0 | ||
| 370 | Something = _class_0 | ||
| 371 | _module_0["Something"] = Something | ||
| 372 | return _module_0 | ||
| 373 | local _module_0 = { } | ||
| 374 | local loadstring, tolua | ||
| 375 | do | ||
| 376 | local _obj_0 = yue | ||
| 377 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 378 | end | ||
| 379 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 380 | local fieldA = tb.itemA.fieldA | ||
| 381 | if fieldA == nil then | ||
| 382 | fieldA = 'default' | ||
| 383 | end | ||
| 384 | _module_0["fieldA"] = fieldA | ||
| 385 | return _module_0 | ||
| 386 | local _module_0 = setmetatable({ }, { }) | ||
| 387 | _module_0.itemA = tb | ||
| 388 | getmetatable(_module_0).__index = items | ||
| 389 | _module_0["a-b-c"] = 123 | ||
| 390 | return _module_0 | ||
| 391 | local _module_0 = { } | ||
| 392 | local d, e, f = 3, 2, 1 | ||
| 393 | _module_0[#_module_0 + 1] = d | ||
| 394 | _module_0[#_module_0 + 1] = e | ||
| 395 | _module_0[#_module_0 + 1] = f | ||
| 396 | if this then | ||
| 397 | _module_0[#_module_0 + 1] = 123 | ||
| 398 | else | ||
| 399 | _module_0[#_module_0 + 1] = 456 | ||
| 400 | end | ||
| 401 | local _with_0 = tmp | ||
| 402 | local j = 2000 | ||
| 403 | _module_0[#_module_0 + 1] = _with_0 | ||
| 404 | return _module_0 | ||
| 405 | local _module_0 = nil | ||
| 406 | _module_0 = function() | ||
| 407 | print("hello") | ||
| 408 | return 123 | ||
| 409 | end | ||
| 410 | return _module_0 | ||
| 411 | xpcall(function() | 173 | xpcall(function() |
| 412 | return func(1, 2, 3) | 174 | return func(1, 2, 3) |
| 413 | end, function(err) | 175 | end, function(err) |
| @@ -2395,6 +2157,12 @@ local file | |||
| 2395 | local _with_0 = File("favorite_foods.txt") | 2157 | local _with_0 = File("favorite_foods.txt") |
| 2396 | _with_0:set_encoding("utf8") | 2158 | _with_0:set_encoding("utf8") |
| 2397 | file = _with_0 | 2159 | file = _with_0 |
| 2160 | local result | ||
| 2161 | local _with_0 = obj | ||
| 2162 | repeat | ||
| 2163 | result = _with_0.value | ||
| 2164 | break | ||
| 2165 | until true | ||
| 2398 | local create_person | 2166 | local create_person |
| 2399 | create_person = function(name, relatives) | 2167 | create_person = function(name, relatives) |
| 2400 | local _with_0 = Person() | 2168 | local _with_0 = Person() |
| @@ -2435,6 +2203,12 @@ local file | |||
| 2435 | local _with_0 = File("favorite_foods.txt") | 2203 | local _with_0 = File("favorite_foods.txt") |
| 2436 | _with_0:set_encoding("utf8") | 2204 | _with_0:set_encoding("utf8") |
| 2437 | file = _with_0 | 2205 | file = _with_0 |
| 2206 | local result | ||
| 2207 | local _with_0 = obj | ||
| 2208 | repeat | ||
| 2209 | result = _with_0.value | ||
| 2210 | break | ||
| 2211 | until true | ||
| 2438 | local create_person | 2212 | local create_person |
| 2439 | create_person = function(name, relatives) | 2213 | create_person = function(name, relatives) |
| 2440 | local _with_0 = Person() | 2214 | local _with_0 = Person() |
| @@ -3268,6 +3042,13 @@ for _index_0 = 1, #_list_0 do | |||
| 3268 | break | 3042 | break |
| 3269 | end | 3043 | end |
| 3270 | end | 3044 | end |
| 3045 | local key, score | ||
| 3046 | for k, v in pairs(data) do | ||
| 3047 | if k == "target" then | ||
| 3048 | key, score = k, v * 10 | ||
| 3049 | break | ||
| 3050 | end | ||
| 3051 | end | ||
| 3271 | local func_a | 3052 | local func_a |
| 3272 | func_a = function() | 3053 | func_a = function() |
| 3273 | for i = 1, 10 do | 3054 | for i = 1, 10 do |
| @@ -3330,6 +3111,13 @@ for _index_0 = 1, #_list_0 do | |||
| 3330 | break | 3111 | break |
| 3331 | end | 3112 | end |
| 3332 | end | 3113 | end |
| 3114 | local key, score | ||
| 3115 | for k, v in pairs(data) do | ||
| 3116 | if k == "target" then | ||
| 3117 | key, score = k, v * 10 | ||
| 3118 | break | ||
| 3119 | end | ||
| 3120 | end | ||
| 3333 | local func_a | 3121 | local func_a |
| 3334 | func_a = function() | 3122 | func_a = function() |
| 3335 | for i = 1, 10 do | 3123 | for i = 1, 10 do |
| @@ -4008,11 +3796,32 @@ end | |||
| 4008 | while not (running == false) do | 3796 | while not (running == false) do |
| 4009 | my_function() | 3797 | my_function() |
| 4010 | end | 3798 | end |
| 3799 | local value, doubled | ||
| 3800 | local _val_0, _val_1 | ||
| 3801 | while true do | ||
| 3802 | local n = get_next() | ||
| 3803 | if n > 10 then | ||
| 3804 | _val_0, _val_1 = n, n * 2 | ||
| 3805 | break | ||
| 3806 | end | ||
| 3807 | end | ||
| 3808 | value, doubled = _val_0, _val_1 | ||
| 4011 | local i = 10 | 3809 | local i = 10 |
| 4012 | repeat | 3810 | repeat |
| 4013 | print(i) | 3811 | print(i) |
| 4014 | i = i - 1 | 3812 | i = i - 1 |
| 4015 | until i == 0 | 3813 | until i == 0 |
| 3814 | local i = 1 | ||
| 3815 | local value, scaled | ||
| 3816 | local _val_0, _val_1 | ||
| 3817 | repeat | ||
| 3818 | if i > 3 then | ||
| 3819 | _val_0, _val_1 = i, i * 100 | ||
| 3820 | break | ||
| 3821 | end | ||
| 3822 | i = i + 1 | ||
| 3823 | until false | ||
| 3824 | value, scaled = _val_0, _val_1 | ||
| 4016 | local i = 10 | 3825 | local i = 10 |
| 4017 | while i > 0 do | 3826 | while i > 0 do |
| 4018 | print(i) | 3827 | print(i) |
| @@ -4029,11 +3838,32 @@ end | |||
| 4029 | while not (running == false) do | 3838 | while not (running == false) do |
| 4030 | my_function() | 3839 | my_function() |
| 4031 | end | 3840 | end |
| 3841 | local value, doubled | ||
| 3842 | local _val_0, _val_1 | ||
| 3843 | while true do | ||
| 3844 | local n = get_next() | ||
| 3845 | if n > 10 then | ||
| 3846 | _val_0, _val_1 = n, n * 2 | ||
| 3847 | break | ||
| 3848 | end | ||
| 3849 | end | ||
| 3850 | value, doubled = _val_0, _val_1 | ||
| 4032 | local i = 10 | 3851 | local i = 10 |
| 4033 | repeat | 3852 | repeat |
| 4034 | print(i) | 3853 | print(i) |
| 4035 | i = i - 1 | 3854 | i = i - 1 |
| 4036 | until i == 0 | 3855 | until i == 0 |
| 3856 | local i = 1 | ||
| 3857 | local value, scaled | ||
| 3858 | local _val_0, _val_1 | ||
| 3859 | repeat | ||
| 3860 | if i > 3 then | ||
| 3861 | _val_0, _val_1 = i, i * 100 | ||
| 3862 | break | ||
| 3863 | end | ||
| 3864 | i = i + 1 | ||
| 3865 | until false | ||
| 3866 | value, scaled = _val_0, _val_1 | ||
| 4037 | local my_object = { | 3867 | local my_object = { |
| 4038 | value = 1000, | 3868 | value = 1000, |
| 4039 | write = function(self) | 3869 | write = function(self) |
| @@ -5136,3 +4966,265 @@ fn = function() | |||
| 5136 | return str | 4966 | return str |
| 5137 | end | 4967 | end |
| 5138 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'Ele disse: \"" .. tostring(Hello) .. "!\"'" | 4968 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'Ele disse: \"" .. tostring(Hello) .. "!\"'" |
| 4969 | do | ||
| 4970 | local insert, concat = table.insert, table.concat | ||
| 4971 | local C, Ct, Cmt | ||
| 4972 | do | ||
| 4973 | local _obj_0 = require("lpeg") | ||
| 4974 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 4975 | end | ||
| 4976 | local x, y, z | ||
| 4977 | do | ||
| 4978 | local _obj_0 = require('mymodule') | ||
| 4979 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 4980 | end | ||
| 4981 | local a, b, c | ||
| 4982 | local _obj_0 = require('module') | ||
| 4983 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 4984 | end | ||
| 4985 | do | ||
| 4986 | local module = require('module') | ||
| 4987 | local module_x = require('module_x') | ||
| 4988 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 4989 | local part = require("module.part") | ||
| 4990 | end | ||
| 4991 | do | ||
| 4992 | local PlayerModule = require("player") | ||
| 4993 | local C, Ct, Cmt | ||
| 4994 | do | ||
| 4995 | local _obj_0 = require("lpeg") | ||
| 4996 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 4997 | end | ||
| 4998 | local one, two, ch | ||
| 4999 | local _obj_0 = require("export") | ||
| 5000 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 5001 | end | ||
| 5002 | do | ||
| 5003 | local tostring <const> = tostring | ||
| 5004 | local concat <const> = table.concat | ||
| 5005 | print(concat({ | ||
| 5006 | "a", | ||
| 5007 | tostring(1) | ||
| 5008 | })) | ||
| 5009 | end | ||
| 5010 | do | ||
| 5011 | local print <const> = print | ||
| 5012 | local math <const> = math | ||
| 5013 | print("hello") | ||
| 5014 | math.random(3) | ||
| 5015 | end | ||
| 5016 | do | ||
| 5017 | local print <const> = print | ||
| 5018 | print(FLAG) | ||
| 5019 | FLAG = 123 | ||
| 5020 | end | ||
| 5021 | local _module_0 = { } | ||
| 5022 | local a, b, c = 1, 2, 3 | ||
| 5023 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 5024 | local cool = "cat" | ||
| 5025 | _module_0["cool"] = cool | ||
| 5026 | local What | ||
| 5027 | if this then | ||
| 5028 | What = "abc" | ||
| 5029 | else | ||
| 5030 | What = "def" | ||
| 5031 | end | ||
| 5032 | _module_0["What"] = What | ||
| 5033 | local y | ||
| 5034 | y = function() | ||
| 5035 | local hallo = 3434 | ||
| 5036 | end | ||
| 5037 | _module_0["y"] = y | ||
| 5038 | local Something | ||
| 5039 | local _class_0 | ||
| 5040 | local _base_0 = { | ||
| 5041 | umm = "cool" | ||
| 5042 | } | ||
| 5043 | if _base_0.__index == nil then | ||
| 5044 | _base_0.__index = _base_0 | ||
| 5045 | end | ||
| 5046 | _class_0 = setmetatable({ | ||
| 5047 | __init = function() end, | ||
| 5048 | __base = _base_0, | ||
| 5049 | __name = "Something" | ||
| 5050 | }, { | ||
| 5051 | __index = _base_0, | ||
| 5052 | __call = function(cls, ...) | ||
| 5053 | local _self_0 = setmetatable({ }, _base_0) | ||
| 5054 | cls.__init(_self_0, ...) | ||
| 5055 | return _self_0 | ||
| 5056 | end | ||
| 5057 | }) | ||
| 5058 | _base_0.__class = _class_0 | ||
| 5059 | Something = _class_0 | ||
| 5060 | _module_0["Something"] = Something | ||
| 5061 | return _module_0 | ||
| 5062 | local _module_0 = { } | ||
| 5063 | local loadstring, tolua | ||
| 5064 | do | ||
| 5065 | local _obj_0 = yue | ||
| 5066 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 5067 | end | ||
| 5068 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 5069 | local fieldA = tb.itemA.fieldA | ||
| 5070 | if fieldA == nil then | ||
| 5071 | fieldA = 'default' | ||
| 5072 | end | ||
| 5073 | _module_0["fieldA"] = fieldA | ||
| 5074 | return _module_0 | ||
| 5075 | local _module_0 = setmetatable({ }, { }) | ||
| 5076 | _module_0.itemA = tb | ||
| 5077 | getmetatable(_module_0).__index = items | ||
| 5078 | _module_0["a-b-c"] = 123 | ||
| 5079 | return _module_0 | ||
| 5080 | local _module_0 = { } | ||
| 5081 | local d, e, f = 3, 2, 1 | ||
| 5082 | _module_0[#_module_0 + 1] = d | ||
| 5083 | _module_0[#_module_0 + 1] = e | ||
| 5084 | _module_0[#_module_0 + 1] = f | ||
| 5085 | if this then | ||
| 5086 | _module_0[#_module_0 + 1] = 123 | ||
| 5087 | else | ||
| 5088 | _module_0[#_module_0 + 1] = 456 | ||
| 5089 | end | ||
| 5090 | local _with_0 = tmp | ||
| 5091 | local j = 2000 | ||
| 5092 | _module_0[#_module_0 + 1] = _with_0 | ||
| 5093 | return _module_0 | ||
| 5094 | local _module_0 = nil | ||
| 5095 | _module_0 = function() | ||
| 5096 | print("hello") | ||
| 5097 | return 123 | ||
| 5098 | end | ||
| 5099 | return _module_0 | ||
| 5100 | do | ||
| 5101 | local insert, concat = table.insert, table.concat | ||
| 5102 | local C, Ct, Cmt | ||
| 5103 | do | ||
| 5104 | local _obj_0 = require("lpeg") | ||
| 5105 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 5106 | end | ||
| 5107 | local x, y, z | ||
| 5108 | do | ||
| 5109 | local _obj_0 = require('mymodule') | ||
| 5110 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 5111 | end | ||
| 5112 | local a, b, c | ||
| 5113 | local _obj_0 = require('module') | ||
| 5114 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 5115 | end | ||
| 5116 | do | ||
| 5117 | local module = require('module') | ||
| 5118 | local module_x = require('module_x') | ||
| 5119 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 5120 | local part = require("module.part") | ||
| 5121 | end | ||
| 5122 | do | ||
| 5123 | local PlayerModule = require("player") | ||
| 5124 | local C, Ct, Cmt | ||
| 5125 | do | ||
| 5126 | local _obj_0 = require("lpeg") | ||
| 5127 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 5128 | end | ||
| 5129 | local one, two, ch | ||
| 5130 | local _obj_0 = require("export") | ||
| 5131 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 5132 | end | ||
| 5133 | do | ||
| 5134 | local tostring <const> = tostring | ||
| 5135 | local concat <const> = table.concat | ||
| 5136 | print(concat({ | ||
| 5137 | "a", | ||
| 5138 | tostring(1) | ||
| 5139 | })) | ||
| 5140 | end | ||
| 5141 | do | ||
| 5142 | local print <const> = print | ||
| 5143 | local math <const> = math | ||
| 5144 | print("hello") | ||
| 5145 | math.random(3) | ||
| 5146 | end | ||
| 5147 | do | ||
| 5148 | local print <const> = print | ||
| 5149 | print(FLAG) | ||
| 5150 | FLAG = 123 | ||
| 5151 | end | ||
| 5152 | local _module_0 = { } | ||
| 5153 | local a, b, c = 1, 2, 3 | ||
| 5154 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 5155 | local cool = "cat" | ||
| 5156 | _module_0["cool"] = cool | ||
| 5157 | local What | ||
| 5158 | if this then | ||
| 5159 | What = "abc" | ||
| 5160 | else | ||
| 5161 | What = "def" | ||
| 5162 | end | ||
| 5163 | _module_0["What"] = What | ||
| 5164 | local y | ||
| 5165 | y = function() | ||
| 5166 | local hallo = 3434 | ||
| 5167 | end | ||
| 5168 | _module_0["y"] = y | ||
| 5169 | local Something | ||
| 5170 | local _class_0 | ||
| 5171 | local _base_0 = { | ||
| 5172 | umm = "cool" | ||
| 5173 | } | ||
| 5174 | if _base_0.__index == nil then | ||
| 5175 | _base_0.__index = _base_0 | ||
| 5176 | end | ||
| 5177 | _class_0 = setmetatable({ | ||
| 5178 | __init = function() end, | ||
| 5179 | __base = _base_0, | ||
| 5180 | __name = "Something" | ||
| 5181 | }, { | ||
| 5182 | __index = _base_0, | ||
| 5183 | __call = function(cls, ...) | ||
| 5184 | local _self_0 = setmetatable({ }, _base_0) | ||
| 5185 | cls.__init(_self_0, ...) | ||
| 5186 | return _self_0 | ||
| 5187 | end | ||
| 5188 | }) | ||
| 5189 | _base_0.__class = _class_0 | ||
| 5190 | Something = _class_0 | ||
| 5191 | _module_0["Something"] = Something | ||
| 5192 | return _module_0 | ||
| 5193 | local _module_0 = { } | ||
| 5194 | local loadstring, tolua | ||
| 5195 | do | ||
| 5196 | local _obj_0 = yue | ||
| 5197 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 5198 | end | ||
| 5199 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 5200 | local fieldA = tb.itemA.fieldA | ||
| 5201 | if fieldA == nil then | ||
| 5202 | fieldA = 'default' | ||
| 5203 | end | ||
| 5204 | _module_0["fieldA"] = fieldA | ||
| 5205 | return _module_0 | ||
| 5206 | local _module_0 = setmetatable({ }, { }) | ||
| 5207 | _module_0.itemA = tb | ||
| 5208 | getmetatable(_module_0).__index = items | ||
| 5209 | _module_0["a-b-c"] = 123 | ||
| 5210 | return _module_0 | ||
| 5211 | local _module_0 = { } | ||
| 5212 | local d, e, f = 3, 2, 1 | ||
| 5213 | _module_0[#_module_0 + 1] = d | ||
| 5214 | _module_0[#_module_0 + 1] = e | ||
| 5215 | _module_0[#_module_0 + 1] = f | ||
| 5216 | if this then | ||
| 5217 | _module_0[#_module_0 + 1] = 123 | ||
| 5218 | else | ||
| 5219 | _module_0[#_module_0 + 1] = 456 | ||
| 5220 | end | ||
| 5221 | local _with_0 = tmp | ||
| 5222 | local j = 2000 | ||
| 5223 | _module_0[#_module_0 + 1] = _with_0 | ||
| 5224 | return _module_0 | ||
| 5225 | local _module_0 = nil | ||
| 5226 | _module_0 = function() | ||
| 5227 | print("hello") | ||
| 5228 | return 123 | ||
| 5229 | end | ||
| 5230 | return _module_0 | ||
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua index 087782e..4ff3866 100644 --- a/spec/outputs/codes_from_doc_zh.lua +++ b/spec/outputs/codes_from_doc_zh.lua | |||
| @@ -3,6 +3,18 @@ do | |||
| 3 | print(var) | 3 | print(var) |
| 4 | end | 4 | end |
| 5 | print(var) | 5 | print(var) |
| 6 | local status, value | ||
| 7 | do | ||
| 8 | repeat | ||
| 9 | local n = 12 | ||
| 10 | if n > 10 then | ||
| 11 | status, value = "large", n | ||
| 12 | break | ||
| 13 | end | ||
| 14 | status, value = "small", n | ||
| 15 | break | ||
| 16 | until true | ||
| 17 | end | ||
| 6 | local counter | 18 | local counter |
| 7 | do | 19 | do |
| 8 | local i = 0 | 20 | local i = 0 |
| @@ -24,6 +36,18 @@ do | |||
| 24 | print(var) | 36 | print(var) |
| 25 | end | 37 | end |
| 26 | print(var) | 38 | print(var) |
| 39 | local status, value | ||
| 40 | do | ||
| 41 | repeat | ||
| 42 | local n = 12 | ||
| 43 | if n > 10 then | ||
| 44 | status, value = "large", n | ||
| 45 | break | ||
| 46 | end | ||
| 47 | status, value = "small", n | ||
| 48 | break | ||
| 49 | until true | ||
| 50 | end | ||
| 27 | local counter | 51 | local counter |
| 28 | do | 52 | do |
| 29 | local i = 0 | 53 | local i = 0 |
| @@ -146,268 +170,6 @@ end | |||
| 146 | do | 170 | do |
| 147 | print(123, "hello") | 171 | print(123, "hello") |
| 148 | end | 172 | end |
| 149 | do | ||
| 150 | local insert, concat = table.insert, table.concat | ||
| 151 | local C, Ct, Cmt | ||
| 152 | do | ||
| 153 | local _obj_0 = require("lpeg") | ||
| 154 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 155 | end | ||
| 156 | local x, y, z | ||
| 157 | do | ||
| 158 | local _obj_0 = require('mymodule') | ||
| 159 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 160 | end | ||
| 161 | local a, b, c | ||
| 162 | local _obj_0 = require('module') | ||
| 163 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 164 | end | ||
| 165 | do | ||
| 166 | local module = require('module') | ||
| 167 | local module_x = require('module_x') | ||
| 168 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 169 | local part = require("module.part") | ||
| 170 | end | ||
| 171 | do | ||
| 172 | local PlayerModule = require("player") | ||
| 173 | local C, Ct, Cmt | ||
| 174 | do | ||
| 175 | local _obj_0 = require("lpeg") | ||
| 176 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 177 | end | ||
| 178 | local one, two, ch | ||
| 179 | local _obj_0 = require("export") | ||
| 180 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 181 | end | ||
| 182 | do | ||
| 183 | local tostring <const> = tostring | ||
| 184 | local concat <const> = table.concat | ||
| 185 | print(concat({ | ||
| 186 | "a", | ||
| 187 | tostring(1) | ||
| 188 | })) | ||
| 189 | end | ||
| 190 | do | ||
| 191 | local print <const> = print | ||
| 192 | local math <const> = math | ||
| 193 | print("hello") | ||
| 194 | math.random(3) | ||
| 195 | end | ||
| 196 | do | ||
| 197 | local print <const> = print | ||
| 198 | print(FLAG) | ||
| 199 | FLAG = 123 | ||
| 200 | end | ||
| 201 | local _module_0 = { } | ||
| 202 | local a, b, c = 1, 2, 3 | ||
| 203 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 204 | local cool = "cat" | ||
| 205 | _module_0["cool"] = cool | ||
| 206 | local What | ||
| 207 | if this then | ||
| 208 | What = "abc" | ||
| 209 | else | ||
| 210 | What = "def" | ||
| 211 | end | ||
| 212 | _module_0["What"] = What | ||
| 213 | local y | ||
| 214 | y = function() | ||
| 215 | local hallo = 3434 | ||
| 216 | end | ||
| 217 | _module_0["y"] = y | ||
| 218 | local Something | ||
| 219 | local _class_0 | ||
| 220 | local _base_0 = { | ||
| 221 | umm = "cool" | ||
| 222 | } | ||
| 223 | if _base_0.__index == nil then | ||
| 224 | _base_0.__index = _base_0 | ||
| 225 | end | ||
| 226 | _class_0 = setmetatable({ | ||
| 227 | __init = function() end, | ||
| 228 | __base = _base_0, | ||
| 229 | __name = "Something" | ||
| 230 | }, { | ||
| 231 | __index = _base_0, | ||
| 232 | __call = function(cls, ...) | ||
| 233 | local _self_0 = setmetatable({ }, _base_0) | ||
| 234 | cls.__init(_self_0, ...) | ||
| 235 | return _self_0 | ||
| 236 | end | ||
| 237 | }) | ||
| 238 | _base_0.__class = _class_0 | ||
| 239 | Something = _class_0 | ||
| 240 | _module_0["Something"] = Something | ||
| 241 | return _module_0 | ||
| 242 | local _module_0 = { } | ||
| 243 | local loadstring, tolua | ||
| 244 | do | ||
| 245 | local _obj_0 = yue | ||
| 246 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 247 | end | ||
| 248 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 249 | local fieldA = tb.itemA.fieldA | ||
| 250 | if fieldA == nil then | ||
| 251 | fieldA = '默认值' | ||
| 252 | end | ||
| 253 | _module_0["fieldA"] = fieldA | ||
| 254 | return _module_0 | ||
| 255 | local _module_0 = setmetatable({ }, { }) | ||
| 256 | _module_0.itemA = tb | ||
| 257 | getmetatable(_module_0).__index = items | ||
| 258 | _module_0["a-b-c"] = 123 | ||
| 259 | return _module_0 | ||
| 260 | local _module_0 = { } | ||
| 261 | local d, e, f = 3, 2, 1 | ||
| 262 | _module_0[#_module_0 + 1] = d | ||
| 263 | _module_0[#_module_0 + 1] = e | ||
| 264 | _module_0[#_module_0 + 1] = f | ||
| 265 | if this then | ||
| 266 | _module_0[#_module_0 + 1] = 123 | ||
| 267 | else | ||
| 268 | _module_0[#_module_0 + 1] = 456 | ||
| 269 | end | ||
| 270 | local _with_0 = tmp | ||
| 271 | local j = 2000 | ||
| 272 | _module_0[#_module_0 + 1] = _with_0 | ||
| 273 | return _module_0 | ||
| 274 | local _module_0 = nil | ||
| 275 | _module_0 = function() | ||
| 276 | print("你好") | ||
| 277 | return 123 | ||
| 278 | end | ||
| 279 | return _module_0 | ||
| 280 | do | ||
| 281 | local insert, concat = table.insert, table.concat | ||
| 282 | local C, Ct, Cmt | ||
| 283 | do | ||
| 284 | local _obj_0 = require("lpeg") | ||
| 285 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 286 | end | ||
| 287 | local x, y, z | ||
| 288 | do | ||
| 289 | local _obj_0 = require('mymodule') | ||
| 290 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 291 | end | ||
| 292 | local a, b, c | ||
| 293 | local _obj_0 = require('module') | ||
| 294 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 295 | end | ||
| 296 | do | ||
| 297 | local module = require('module') | ||
| 298 | local module_x = require('module_x') | ||
| 299 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 300 | local part = require("module.part") | ||
| 301 | end | ||
| 302 | do | ||
| 303 | local PlayerModule = require("player") | ||
| 304 | local C, Ct, Cmt | ||
| 305 | do | ||
| 306 | local _obj_0 = require("lpeg") | ||
| 307 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 308 | end | ||
| 309 | local one, two, ch | ||
| 310 | local _obj_0 = require("export") | ||
| 311 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 312 | end | ||
| 313 | do | ||
| 314 | local tostring <const> = tostring | ||
| 315 | local concat <const> = table.concat | ||
| 316 | print(concat({ | ||
| 317 | "a", | ||
| 318 | tostring(1) | ||
| 319 | })) | ||
| 320 | end | ||
| 321 | do | ||
| 322 | local print <const> = print | ||
| 323 | local math <const> = math | ||
| 324 | print("hello") | ||
| 325 | math.random(3) | ||
| 326 | end | ||
| 327 | do | ||
| 328 | local print <const> = print | ||
| 329 | print(FLAG) | ||
| 330 | FLAG = 123 | ||
| 331 | end | ||
| 332 | local _module_0 = { } | ||
| 333 | local a, b, c = 1, 2, 3 | ||
| 334 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 335 | local cool = "cat" | ||
| 336 | _module_0["cool"] = cool | ||
| 337 | local What | ||
| 338 | if this then | ||
| 339 | What = "abc" | ||
| 340 | else | ||
| 341 | What = "def" | ||
| 342 | end | ||
| 343 | _module_0["What"] = What | ||
| 344 | local y | ||
| 345 | y = function() | ||
| 346 | local hallo = 3434 | ||
| 347 | end | ||
| 348 | _module_0["y"] = y | ||
| 349 | local Something | ||
| 350 | local _class_0 | ||
| 351 | local _base_0 = { | ||
| 352 | umm = "cool" | ||
| 353 | } | ||
| 354 | if _base_0.__index == nil then | ||
| 355 | _base_0.__index = _base_0 | ||
| 356 | end | ||
| 357 | _class_0 = setmetatable({ | ||
| 358 | __init = function() end, | ||
| 359 | __base = _base_0, | ||
| 360 | __name = "Something" | ||
| 361 | }, { | ||
| 362 | __index = _base_0, | ||
| 363 | __call = function(cls, ...) | ||
| 364 | local _self_0 = setmetatable({ }, _base_0) | ||
| 365 | cls.__init(_self_0, ...) | ||
| 366 | return _self_0 | ||
| 367 | end | ||
| 368 | }) | ||
| 369 | _base_0.__class = _class_0 | ||
| 370 | Something = _class_0 | ||
| 371 | _module_0["Something"] = Something | ||
| 372 | return _module_0 | ||
| 373 | local _module_0 = { } | ||
| 374 | local loadstring, tolua | ||
| 375 | do | ||
| 376 | local _obj_0 = yue | ||
| 377 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 378 | end | ||
| 379 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 380 | local fieldA = tb.itemA.fieldA | ||
| 381 | if fieldA == nil then | ||
| 382 | fieldA = '默认值' | ||
| 383 | end | ||
| 384 | _module_0["fieldA"] = fieldA | ||
| 385 | return _module_0 | ||
| 386 | local _module_0 = setmetatable({ }, { }) | ||
| 387 | _module_0.itemA = tb | ||
| 388 | getmetatable(_module_0).__index = items | ||
| 389 | _module_0["a-b-c"] = 123 | ||
| 390 | return _module_0 | ||
| 391 | local _module_0 = { } | ||
| 392 | local d, e, f = 3, 2, 1 | ||
| 393 | _module_0[#_module_0 + 1] = d | ||
| 394 | _module_0[#_module_0 + 1] = e | ||
| 395 | _module_0[#_module_0 + 1] = f | ||
| 396 | if this then | ||
| 397 | _module_0[#_module_0 + 1] = 123 | ||
| 398 | else | ||
| 399 | _module_0[#_module_0 + 1] = 456 | ||
| 400 | end | ||
| 401 | local _with_0 = tmp | ||
| 402 | local j = 2000 | ||
| 403 | _module_0[#_module_0 + 1] = _with_0 | ||
| 404 | return _module_0 | ||
| 405 | local _module_0 = nil | ||
| 406 | _module_0 = function() | ||
| 407 | print("你好") | ||
| 408 | return 123 | ||
| 409 | end | ||
| 410 | return _module_0 | ||
| 411 | xpcall(function() | 173 | xpcall(function() |
| 412 | return func(1, 2, 3) | 174 | return func(1, 2, 3) |
| 413 | end, function(err) | 175 | end, function(err) |
| @@ -2395,6 +2157,12 @@ local file | |||
| 2395 | local _with_0 = File("favorite_foods.txt") | 2157 | local _with_0 = File("favorite_foods.txt") |
| 2396 | _with_0:set_encoding("utf8") | 2158 | _with_0:set_encoding("utf8") |
| 2397 | file = _with_0 | 2159 | file = _with_0 |
| 2160 | local result | ||
| 2161 | local _with_0 = obj | ||
| 2162 | repeat | ||
| 2163 | result = _with_0.value | ||
| 2164 | break | ||
| 2165 | until true | ||
| 2398 | local create_person | 2166 | local create_person |
| 2399 | create_person = function(name, relatives) | 2167 | create_person = function(name, relatives) |
| 2400 | local _with_0 = Person() | 2168 | local _with_0 = Person() |
| @@ -2435,6 +2203,12 @@ local file | |||
| 2435 | local _with_0 = File("favorite_foods.txt") | 2203 | local _with_0 = File("favorite_foods.txt") |
| 2436 | _with_0:set_encoding("utf8") | 2204 | _with_0:set_encoding("utf8") |
| 2437 | file = _with_0 | 2205 | file = _with_0 |
| 2206 | local result | ||
| 2207 | local _with_0 = obj | ||
| 2208 | repeat | ||
| 2209 | result = _with_0.value | ||
| 2210 | break | ||
| 2211 | until true | ||
| 2438 | local create_person | 2212 | local create_person |
| 2439 | create_person = function(name, relatives) | 2213 | create_person = function(name, relatives) |
| 2440 | local _with_0 = Person() | 2214 | local _with_0 = Person() |
| @@ -3268,6 +3042,13 @@ for _index_0 = 1, #_list_0 do | |||
| 3268 | break | 3042 | break |
| 3269 | end | 3043 | end |
| 3270 | end | 3044 | end |
| 3045 | local key, score | ||
| 3046 | for k, v in pairs(data) do | ||
| 3047 | if k == "target" then | ||
| 3048 | key, score = k, v * 10 | ||
| 3049 | break | ||
| 3050 | end | ||
| 3051 | end | ||
| 3271 | local func_a | 3052 | local func_a |
| 3272 | func_a = function() | 3053 | func_a = function() |
| 3273 | for i = 1, 10 do | 3054 | for i = 1, 10 do |
| @@ -3330,6 +3111,13 @@ for _index_0 = 1, #_list_0 do | |||
| 3330 | break | 3111 | break |
| 3331 | end | 3112 | end |
| 3332 | end | 3113 | end |
| 3114 | local key, score | ||
| 3115 | for k, v in pairs(data) do | ||
| 3116 | if k == "target" then | ||
| 3117 | key, score = k, v * 10 | ||
| 3118 | break | ||
| 3119 | end | ||
| 3120 | end | ||
| 3333 | local func_a | 3121 | local func_a |
| 3334 | func_a = function() | 3122 | func_a = function() |
| 3335 | for i = 1, 10 do | 3123 | for i = 1, 10 do |
| @@ -4008,11 +3796,32 @@ end | |||
| 4008 | while not (running == false) do | 3796 | while not (running == false) do |
| 4009 | my_function() | 3797 | my_function() |
| 4010 | end | 3798 | end |
| 3799 | local value, doubled | ||
| 3800 | local _val_0, _val_1 | ||
| 3801 | while true do | ||
| 3802 | local n = get_next() | ||
| 3803 | if n > 10 then | ||
| 3804 | _val_0, _val_1 = n, n * 2 | ||
| 3805 | break | ||
| 3806 | end | ||
| 3807 | end | ||
| 3808 | value, doubled = _val_0, _val_1 | ||
| 4011 | local i = 10 | 3809 | local i = 10 |
| 4012 | repeat | 3810 | repeat |
| 4013 | print(i) | 3811 | print(i) |
| 4014 | i = i - 1 | 3812 | i = i - 1 |
| 4015 | until i == 0 | 3813 | until i == 0 |
| 3814 | local i = 1 | ||
| 3815 | local value, scaled | ||
| 3816 | local _val_0, _val_1 | ||
| 3817 | repeat | ||
| 3818 | if i > 3 then | ||
| 3819 | _val_0, _val_1 = i, i * 100 | ||
| 3820 | break | ||
| 3821 | end | ||
| 3822 | i = i + 1 | ||
| 3823 | until false | ||
| 3824 | value, scaled = _val_0, _val_1 | ||
| 4016 | local i = 10 | 3825 | local i = 10 |
| 4017 | while i > 0 do | 3826 | while i > 0 do |
| 4018 | print(i) | 3827 | print(i) |
| @@ -4029,11 +3838,32 @@ end | |||
| 4029 | while not (running == false) do | 3838 | while not (running == false) do |
| 4030 | my_function() | 3839 | my_function() |
| 4031 | end | 3840 | end |
| 3841 | local value, doubled | ||
| 3842 | local _val_0, _val_1 | ||
| 3843 | while true do | ||
| 3844 | local n = get_next() | ||
| 3845 | if n > 10 then | ||
| 3846 | _val_0, _val_1 = n, n * 2 | ||
| 3847 | break | ||
| 3848 | end | ||
| 3849 | end | ||
| 3850 | value, doubled = _val_0, _val_1 | ||
| 4032 | local i = 10 | 3851 | local i = 10 |
| 4033 | repeat | 3852 | repeat |
| 4034 | print(i) | 3853 | print(i) |
| 4035 | i = i - 1 | 3854 | i = i - 1 |
| 4036 | until i == 0 | 3855 | until i == 0 |
| 3856 | local i = 1 | ||
| 3857 | local value, scaled | ||
| 3858 | local _val_0, _val_1 | ||
| 3859 | repeat | ||
| 3860 | if i > 3 then | ||
| 3861 | _val_0, _val_1 = i, i * 100 | ||
| 3862 | break | ||
| 3863 | end | ||
| 3864 | i = i + 1 | ||
| 3865 | until false | ||
| 3866 | value, scaled = _val_0, _val_1 | ||
| 4037 | local my_object = { | 3867 | local my_object = { |
| 4038 | value = 1000, | 3868 | value = 1000, |
| 4039 | write = function(self) | 3869 | write = function(self) |
| @@ -5136,3 +4966,265 @@ fn = function() | |||
| 5136 | return str | 4966 | return str |
| 5137 | end | 4967 | end |
| 5138 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" | 4968 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" |
| 4969 | do | ||
| 4970 | local insert, concat = table.insert, table.concat | ||
| 4971 | local C, Ct, Cmt | ||
| 4972 | do | ||
| 4973 | local _obj_0 = require("lpeg") | ||
| 4974 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 4975 | end | ||
| 4976 | local x, y, z | ||
| 4977 | do | ||
| 4978 | local _obj_0 = require('mymodule') | ||
| 4979 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 4980 | end | ||
| 4981 | local a, b, c | ||
| 4982 | local _obj_0 = require('module') | ||
| 4983 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 4984 | end | ||
| 4985 | do | ||
| 4986 | local module = require('module') | ||
| 4987 | local module_x = require('module_x') | ||
| 4988 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 4989 | local part = require("module.part") | ||
| 4990 | end | ||
| 4991 | do | ||
| 4992 | local PlayerModule = require("player") | ||
| 4993 | local C, Ct, Cmt | ||
| 4994 | do | ||
| 4995 | local _obj_0 = require("lpeg") | ||
| 4996 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 4997 | end | ||
| 4998 | local one, two, ch | ||
| 4999 | local _obj_0 = require("export") | ||
| 5000 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 5001 | end | ||
| 5002 | do | ||
| 5003 | local tostring <const> = tostring | ||
| 5004 | local concat <const> = table.concat | ||
| 5005 | print(concat({ | ||
| 5006 | "a", | ||
| 5007 | tostring(1) | ||
| 5008 | })) | ||
| 5009 | end | ||
| 5010 | do | ||
| 5011 | local print <const> = print | ||
| 5012 | local math <const> = math | ||
| 5013 | print("hello") | ||
| 5014 | math.random(3) | ||
| 5015 | end | ||
| 5016 | do | ||
| 5017 | local print <const> = print | ||
| 5018 | print(FLAG) | ||
| 5019 | FLAG = 123 | ||
| 5020 | end | ||
| 5021 | local _module_0 = { } | ||
| 5022 | local a, b, c = 1, 2, 3 | ||
| 5023 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 5024 | local cool = "cat" | ||
| 5025 | _module_0["cool"] = cool | ||
| 5026 | local What | ||
| 5027 | if this then | ||
| 5028 | What = "abc" | ||
| 5029 | else | ||
| 5030 | What = "def" | ||
| 5031 | end | ||
| 5032 | _module_0["What"] = What | ||
| 5033 | local y | ||
| 5034 | y = function() | ||
| 5035 | local hallo = 3434 | ||
| 5036 | end | ||
| 5037 | _module_0["y"] = y | ||
| 5038 | local Something | ||
| 5039 | local _class_0 | ||
| 5040 | local _base_0 = { | ||
| 5041 | umm = "cool" | ||
| 5042 | } | ||
| 5043 | if _base_0.__index == nil then | ||
| 5044 | _base_0.__index = _base_0 | ||
| 5045 | end | ||
| 5046 | _class_0 = setmetatable({ | ||
| 5047 | __init = function() end, | ||
| 5048 | __base = _base_0, | ||
| 5049 | __name = "Something" | ||
| 5050 | }, { | ||
| 5051 | __index = _base_0, | ||
| 5052 | __call = function(cls, ...) | ||
| 5053 | local _self_0 = setmetatable({ }, _base_0) | ||
| 5054 | cls.__init(_self_0, ...) | ||
| 5055 | return _self_0 | ||
| 5056 | end | ||
| 5057 | }) | ||
| 5058 | _base_0.__class = _class_0 | ||
| 5059 | Something = _class_0 | ||
| 5060 | _module_0["Something"] = Something | ||
| 5061 | return _module_0 | ||
| 5062 | local _module_0 = { } | ||
| 5063 | local loadstring, tolua | ||
| 5064 | do | ||
| 5065 | local _obj_0 = yue | ||
| 5066 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 5067 | end | ||
| 5068 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 5069 | local fieldA = tb.itemA.fieldA | ||
| 5070 | if fieldA == nil then | ||
| 5071 | fieldA = '默认值' | ||
| 5072 | end | ||
| 5073 | _module_0["fieldA"] = fieldA | ||
| 5074 | return _module_0 | ||
| 5075 | local _module_0 = setmetatable({ }, { }) | ||
| 5076 | _module_0.itemA = tb | ||
| 5077 | getmetatable(_module_0).__index = items | ||
| 5078 | _module_0["a-b-c"] = 123 | ||
| 5079 | return _module_0 | ||
| 5080 | local _module_0 = { } | ||
| 5081 | local d, e, f = 3, 2, 1 | ||
| 5082 | _module_0[#_module_0 + 1] = d | ||
| 5083 | _module_0[#_module_0 + 1] = e | ||
| 5084 | _module_0[#_module_0 + 1] = f | ||
| 5085 | if this then | ||
| 5086 | _module_0[#_module_0 + 1] = 123 | ||
| 5087 | else | ||
| 5088 | _module_0[#_module_0 + 1] = 456 | ||
| 5089 | end | ||
| 5090 | local _with_0 = tmp | ||
| 5091 | local j = 2000 | ||
| 5092 | _module_0[#_module_0 + 1] = _with_0 | ||
| 5093 | return _module_0 | ||
| 5094 | local _module_0 = nil | ||
| 5095 | _module_0 = function() | ||
| 5096 | print("你好") | ||
| 5097 | return 123 | ||
| 5098 | end | ||
| 5099 | return _module_0 | ||
| 5100 | do | ||
| 5101 | local insert, concat = table.insert, table.concat | ||
| 5102 | local C, Ct, Cmt | ||
| 5103 | do | ||
| 5104 | local _obj_0 = require("lpeg") | ||
| 5105 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 5106 | end | ||
| 5107 | local x, y, z | ||
| 5108 | do | ||
| 5109 | local _obj_0 = require('mymodule') | ||
| 5110 | x, y, z = _obj_0.x, _obj_0.y, _obj_0.z | ||
| 5111 | end | ||
| 5112 | local a, b, c | ||
| 5113 | local _obj_0 = require('module') | ||
| 5114 | a, b, c = _obj_0.a, _obj_0.b, _obj_0.c | ||
| 5115 | end | ||
| 5116 | do | ||
| 5117 | local module = require('module') | ||
| 5118 | local module_x = require('module_x') | ||
| 5119 | local d_a_s_h_e_s = require("d-a-s-h-e-s") | ||
| 5120 | local part = require("module.part") | ||
| 5121 | end | ||
| 5122 | do | ||
| 5123 | local PlayerModule = require("player") | ||
| 5124 | local C, Ct, Cmt | ||
| 5125 | do | ||
| 5126 | local _obj_0 = require("lpeg") | ||
| 5127 | C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt | ||
| 5128 | end | ||
| 5129 | local one, two, ch | ||
| 5130 | local _obj_0 = require("export") | ||
| 5131 | one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1] | ||
| 5132 | end | ||
| 5133 | do | ||
| 5134 | local tostring <const> = tostring | ||
| 5135 | local concat <const> = table.concat | ||
| 5136 | print(concat({ | ||
| 5137 | "a", | ||
| 5138 | tostring(1) | ||
| 5139 | })) | ||
| 5140 | end | ||
| 5141 | do | ||
| 5142 | local print <const> = print | ||
| 5143 | local math <const> = math | ||
| 5144 | print("hello") | ||
| 5145 | math.random(3) | ||
| 5146 | end | ||
| 5147 | do | ||
| 5148 | local print <const> = print | ||
| 5149 | print(FLAG) | ||
| 5150 | FLAG = 123 | ||
| 5151 | end | ||
| 5152 | local _module_0 = { } | ||
| 5153 | local a, b, c = 1, 2, 3 | ||
| 5154 | _module_0["a"], _module_0["b"], _module_0["c"] = a, b, c | ||
| 5155 | local cool = "cat" | ||
| 5156 | _module_0["cool"] = cool | ||
| 5157 | local What | ||
| 5158 | if this then | ||
| 5159 | What = "abc" | ||
| 5160 | else | ||
| 5161 | What = "def" | ||
| 5162 | end | ||
| 5163 | _module_0["What"] = What | ||
| 5164 | local y | ||
| 5165 | y = function() | ||
| 5166 | local hallo = 3434 | ||
| 5167 | end | ||
| 5168 | _module_0["y"] = y | ||
| 5169 | local Something | ||
| 5170 | local _class_0 | ||
| 5171 | local _base_0 = { | ||
| 5172 | umm = "cool" | ||
| 5173 | } | ||
| 5174 | if _base_0.__index == nil then | ||
| 5175 | _base_0.__index = _base_0 | ||
| 5176 | end | ||
| 5177 | _class_0 = setmetatable({ | ||
| 5178 | __init = function() end, | ||
| 5179 | __base = _base_0, | ||
| 5180 | __name = "Something" | ||
| 5181 | }, { | ||
| 5182 | __index = _base_0, | ||
| 5183 | __call = function(cls, ...) | ||
| 5184 | local _self_0 = setmetatable({ }, _base_0) | ||
| 5185 | cls.__init(_self_0, ...) | ||
| 5186 | return _self_0 | ||
| 5187 | end | ||
| 5188 | }) | ||
| 5189 | _base_0.__class = _class_0 | ||
| 5190 | Something = _class_0 | ||
| 5191 | _module_0["Something"] = Something | ||
| 5192 | return _module_0 | ||
| 5193 | local _module_0 = { } | ||
| 5194 | local loadstring, tolua | ||
| 5195 | do | ||
| 5196 | local _obj_0 = yue | ||
| 5197 | loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua | ||
| 5198 | end | ||
| 5199 | _module_0["loadstring"], _module_0["tolua"] = loadstring, tolua | ||
| 5200 | local fieldA = tb.itemA.fieldA | ||
| 5201 | if fieldA == nil then | ||
| 5202 | fieldA = '默认值' | ||
| 5203 | end | ||
| 5204 | _module_0["fieldA"] = fieldA | ||
| 5205 | return _module_0 | ||
| 5206 | local _module_0 = setmetatable({ }, { }) | ||
| 5207 | _module_0.itemA = tb | ||
| 5208 | getmetatable(_module_0).__index = items | ||
| 5209 | _module_0["a-b-c"] = 123 | ||
| 5210 | return _module_0 | ||
| 5211 | local _module_0 = { } | ||
| 5212 | local d, e, f = 3, 2, 1 | ||
| 5213 | _module_0[#_module_0 + 1] = d | ||
| 5214 | _module_0[#_module_0 + 1] = e | ||
| 5215 | _module_0[#_module_0 + 1] = f | ||
| 5216 | if this then | ||
| 5217 | _module_0[#_module_0 + 1] = 123 | ||
| 5218 | else | ||
| 5219 | _module_0[#_module_0 + 1] = 456 | ||
| 5220 | end | ||
| 5221 | local _with_0 = tmp | ||
| 5222 | local j = 2000 | ||
| 5223 | _module_0[#_module_0 + 1] = _with_0 | ||
| 5224 | return _module_0 | ||
| 5225 | local _module_0 = nil | ||
| 5226 | _module_0 = function() | ||
| 5227 | print("你好") | ||
| 5228 | return 123 | ||
| 5229 | end | ||
| 5230 | return _module_0 | ||
diff --git a/spec/outputs/compile_doc.lua b/spec/outputs/compile_doc.lua index 6a5efd5..8d5c11a 100644 --- a/spec/outputs/compile_doc.lua +++ b/spec/outputs/compile_doc.lua | |||
| @@ -11,7 +11,6 @@ getFiles = function(locale) | |||
| 11 | "doc/docs/" .. tostring(locale) .. "doc/advanced/do.md", | 11 | "doc/docs/" .. tostring(locale) .. "doc/advanced/do.md", |
| 12 | "doc/docs/" .. tostring(locale) .. "doc/advanced/line-decorators.md", | 12 | "doc/docs/" .. tostring(locale) .. "doc/advanced/line-decorators.md", |
| 13 | "doc/docs/" .. tostring(locale) .. "doc/advanced/macro.md", | 13 | "doc/docs/" .. tostring(locale) .. "doc/advanced/macro.md", |
| 14 | "doc/docs/" .. tostring(locale) .. "doc/advanced/module.md", | ||
| 15 | "doc/docs/" .. tostring(locale) .. "doc/advanced/try.md", | 14 | "doc/docs/" .. tostring(locale) .. "doc/advanced/try.md", |
| 16 | "doc/docs/" .. tostring(locale) .. "doc/data-structures/table-literals.md", | 15 | "doc/docs/" .. tostring(locale) .. "doc/data-structures/table-literals.md", |
| 17 | "doc/docs/" .. tostring(locale) .. "doc/data-structures/comprehensions.md", | 16 | "doc/docs/" .. tostring(locale) .. "doc/data-structures/comprehensions.md", |
| @@ -38,6 +37,7 @@ getFiles = function(locale) | |||
| 38 | "doc/docs/" .. tostring(locale) .. "doc/language-basics/attributes.md", | 37 | "doc/docs/" .. tostring(locale) .. "doc/language-basics/attributes.md", |
| 39 | "doc/docs/" .. tostring(locale) .. "doc/language-basics/operator.md", | 38 | "doc/docs/" .. tostring(locale) .. "doc/language-basics/operator.md", |
| 40 | "doc/docs/" .. tostring(locale) .. "doc/language-basics/literals.md", | 39 | "doc/docs/" .. tostring(locale) .. "doc/language-basics/literals.md", |
| 40 | "doc/docs/" .. tostring(locale) .. "doc/language-basics/module.md", | ||
| 41 | "doc/docs/" .. tostring(locale) .. "doc/reference/license-mit.md", | 41 | "doc/docs/" .. tostring(locale) .. "doc/reference/license-mit.md", |
| 42 | "doc/docs/" .. tostring(locale) .. "doc/reference/the-yuescript-library.md" | 42 | "doc/docs/" .. tostring(locale) .. "doc/reference/the-yuescript-library.md" |
| 43 | } | 43 | } |
