aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/docs/.vitepress/config.mts9
-rw-r--r--doc/docs/de/doc/control-flow/conditionals.md58
-rw-r--r--doc/docs/de/doc/control-flow/goto.md106
-rw-r--r--doc/docs/doc/control-flow/conditionals.md58
-rw-r--r--doc/docs/doc/control-flow/goto.md106
-rw-r--r--doc/docs/id-id/doc/control-flow/conditionals.md58
-rw-r--r--doc/docs/id-id/doc/control-flow/goto.md106
-rw-r--r--doc/docs/pt-br/doc/control-flow/conditionals.md58
-rw-r--r--doc/docs/pt-br/doc/control-flow/goto.md106
-rw-r--r--doc/docs/zh/doc/control-flow/conditionals.md58
-rw-r--r--doc/docs/zh/doc/control-flow/goto.md106
-rw-r--r--doc/yue-de.md58
-rw-r--r--doc/yue-en.md58
-rw-r--r--doc/yue-id-id.md58
-rw-r--r--doc/yue-pt-br.md58
-rw-r--r--doc/yue-zh.md58
-rw-r--r--makefile37
-rw-r--r--spec/outputs/codes_from_doc_de.lua118
-rw-r--r--spec/outputs/codes_from_doc_en.lua118
-rw-r--r--spec/outputs/codes_from_doc_id-id.lua118
-rw-r--r--spec/outputs/codes_from_doc_pt-br.lua118
-rw-r--r--spec/outputs/codes_from_doc_zh.lua118
-rw-r--r--src/yue.cpp2
23 files changed, 1735 insertions, 13 deletions
diff --git a/doc/docs/.vitepress/config.mts b/doc/docs/.vitepress/config.mts
index 635d087..872791c 100644
--- a/doc/docs/.vitepress/config.mts
+++ b/doc/docs/.vitepress/config.mts
@@ -55,6 +55,7 @@ const sidebarText = {
55 whileLoop: "While-Schleife", 55 whileLoop: "While-Schleife",
56 continueStatement: "Continue-Anweisung", 56 continueStatement: "Continue-Anweisung",
57 conditionals: "Bedingungen", 57 conditionals: "Bedingungen",
58 gotoStatement: "Goto und Labels",
58 lineDecorators: "Zeilen-Dekoratoren", 59 lineDecorators: "Zeilen-Dekoratoren",
59 switch: "Switch", 60 switch: "Switch",
60 objectOrientedProgramming: "Objektorientierte Programmierung", 61 objectOrientedProgramming: "Objektorientierte Programmierung",
@@ -89,6 +90,7 @@ const sidebarText = {
89 whileLoop: "While Loop", 90 whileLoop: "While Loop",
90 continueStatement: "Continue Statement", 91 continueStatement: "Continue Statement",
91 conditionals: "Conditionals", 92 conditionals: "Conditionals",
93 gotoStatement: "Goto and Labels",
92 lineDecorators: "Line Decorators", 94 lineDecorators: "Line Decorators",
93 switch: "Switch", 95 switch: "Switch",
94 objectOrientedProgramming: "Object Oriented Programming", 96 objectOrientedProgramming: "Object Oriented Programming",
@@ -123,6 +125,7 @@ const sidebarText = {
123 whileLoop: "Perulangan While", 125 whileLoop: "Perulangan While",
124 continueStatement: "Pernyataan Lanjutkan", 126 continueStatement: "Pernyataan Lanjutkan",
125 conditionals: "Percabangan", 127 conditionals: "Percabangan",
128 gotoStatement: "Goto dan Label",
126 lineDecorators: "Dekorator Baris", 129 lineDecorators: "Dekorator Baris",
127 switch: "Switch", 130 switch: "Switch",
128 objectOrientedProgramming: "Pemrograman Berorientasi Objek", 131 objectOrientedProgramming: "Pemrograman Berorientasi Objek",
@@ -157,6 +160,7 @@ const sidebarText = {
157 whileLoop: "Laço while", 160 whileLoop: "Laço while",
158 continueStatement: "Instrução continue", 161 continueStatement: "Instrução continue",
159 conditionals: "Condicionais", 162 conditionals: "Condicionais",
163 gotoStatement: "Goto e Rótulos",
160 lineDecorators: "Decoradores de linha", 164 lineDecorators: "Decoradores de linha",
161 switch: "Switch", 165 switch: "Switch",
162 objectOrientedProgramming: "Programação orientada a objetos", 166 objectOrientedProgramming: "Programação orientada a objetos",
@@ -191,6 +195,7 @@ const sidebarText = {
191 whileLoop: "while 循环", 195 whileLoop: "while 循环",
192 continueStatement: "continue 语句", 196 continueStatement: "continue 语句",
193 conditionals: "条件语句", 197 conditionals: "条件语句",
198 gotoStatement: "goto 语句与标签",
194 lineDecorators: "代码行修饰符", 199 lineDecorators: "代码行修饰符",
195 switch: "switch 语句", 200 switch: "switch 语句",
196 objectOrientedProgramming: "面向对象编程", 201 objectOrientedProgramming: "面向对象编程",
@@ -363,6 +368,10 @@ function createSidebar(basePath: string, locale: SidebarLocale) {
363 text: text.continueStatement, 368 text: text.continueStatement,
364 link: `${basePath}/control-flow/continue`, 369 link: `${basePath}/control-flow/continue`,
365 }, 370 },
371 {
372 text: text.gotoStatement,
373 link: `${basePath}/control-flow/goto`,
374 },
366 { text: text.switch, link: `${basePath}/control-flow/switch` }, 375 { text: text.switch, link: `${basePath}/control-flow/switch` },
367 ], 376 ],
368 }, 377 },
diff --git a/doc/docs/de/doc/control-flow/conditionals.md b/doc/docs/de/doc/control-flow/conditionals.md
index 56663d1..0d2574d 100644
--- a/doc/docs/de/doc/control-flow/conditionals.md
+++ b/doc/docs/de/doc/control-flow/conditionals.md
@@ -143,3 +143,61 @@ if a in list
143``` 143```
144 144
145</YueDisplay> 145</YueDisplay>
146
147Der `in`-Operator kann auch mit Tabellen verwendet werden und unterstützt die Variante `not in` für Verneinungen:
148
149```yuescript
150has = "foo" in {"bar", "foo"}
151
152if a in {1, 2, 3}
153 print "a ist in der Tabelle"
154
155not_exist = item not in list
156
157check = -> value not in table
158```
159
160<YueDisplay>
161
162```yue
163has = "foo" in {"bar", "foo"}
164
165if a in {1, 2, 3}
166 print "a ist in der Tabelle"
167
168not_exist = item not in list
169
170check = -> value not in table
171```
172
173</YueDisplay>
174
175Eine Ein-Element-Liste oder Tabelle prüft auf Gleichheit mit diesem Element:
176
177```yuescript
178-- [1,] prüft, ob wert == 1
179c = a in [1,]
180
181-- {1} prüft auch, ob wert == 1
182c = a in {1}
183
184-- Ohne Komma ist [1] ein Indexzugriff (tb[1])
185with tb
186 c = a in [1]
187```
188
189<YueDisplay>
190
191```yue
192-- [1,] prüft, ob wert == 1
193c = a in [1,]
194
195-- {1} prüft auch, ob wert == 1
196c = a in {1}
197
198-- Ohne Komma ist [1] ein Indexzugriff (tb[1])
199with tb
200 c = a in [1]
201```
202
203</YueDisplay>
diff --git a/doc/docs/de/doc/control-flow/goto.md b/doc/docs/de/doc/control-flow/goto.md
new file mode 100644
index 0000000..0e2a415
--- /dev/null
+++ b/doc/docs/de/doc/control-flow/goto.md
@@ -0,0 +1,106 @@
1# Goto
2
3YueScript unterstützt die goto-Anweisung und die Label-Syntax zur Steuerung des Programmflusses, wobei die gleichen Regeln wie bei Luas goto-Anweisung gelten. **Hinweis:** Die goto-Anweisung erfordert Lua 5.2 oder höher. Beim Kompilieren zu Lua 5.1 führt die Verwendung der goto-Syntax zu einem Kompilierfehler.
4
5Ein Label wird mit doppelten Doppelpunkten definiert:
6
7```yuescript
8::start::
9::done::
10::mein_label::
11```
12
13<YueDisplay>
14
15```yue
16::start::
17::done::
18::mein_label::
19```
20
21</YueDisplay>
22
23Die goto-Anweisung springt zu einem angegebenen Label:
24
25```yuescript
26a = 0
27::start::
28a += 1
29goto done if a == 5
30goto start
31::done::
32print "a ist jetzt 5"
33```
34
35<YueDisplay>
36
37```yue
38a = 0
39::start::
40a += 1
41goto done if a == 5
42goto start
43::done::
44print "a ist jetzt 5"
45```
46
47</YueDisplay>
48
49Die goto-Anweisung ist nützlich, um aus tief verschachtelten Schleifen zu springen:
50
51```yuescript
52for z = 1, 10
53 for y = 1, 10 do for x = 1, 10
54 if x^2 + y^2 == z^2
55 print 'Pythagoreisches Tripel gefunden:', x, y, z
56 goto ok
57::ok::
58```
59
60<YueDisplay>
61
62```yue
63for z = 1, 10
64 for y = 1, 10 do for x = 1, 10
65 if x^2 + y^2 == z^2
66 print 'Pythagoreisches Tripel gefunden:', x, y, z
67 goto ok
68::ok::
69```
70
71</YueDisplay>
72
73Sie können auch Labels verwenden, um zu einer bestimmten Schleifenebene zu springen:
74
75```yuescript
76for z = 1, 10
77 for y = 1, 10
78 for x = 1, 10
79 if x^2 + y^2 == z^2
80 print 'Pythagoreisches Tripel gefunden:', x, y, z
81 print 'versuche nächstes z...'
82 goto zcontinue
83 ::zcontinue::
84```
85
86<YueDisplay>
87
88```yue
89for z = 1, 10
90 for y = 1, 10
91 for x = 1, 10
92 if x^2 + y^2 == z^2
93 print 'Pythagoreisches Tripel gefunden:', x, y, z
94 print 'versuche nächstes z...'
95 goto zcontinue
96 ::zcontinue::
97```
98
99</YueDisplay>
100
101## Hinweise
102
103- Labels müssen innerhalb ihres Geltungsbereichs eindeutig sein
104- goto kann zu Labels auf derselben oder äußeren Geltungsbereichsebenen springen
105- goto kann nicht in innere Geltungsbereiche springen (wie in Blöcke oder Schleifen)
106- Verwenden Sie goto sparsam, da es den Code schwieriger zu lesen und zu warten machen kann
diff --git a/doc/docs/doc/control-flow/conditionals.md b/doc/docs/doc/control-flow/conditionals.md
index 1bcc838..ca29fda 100644
--- a/doc/docs/doc/control-flow/conditionals.md
+++ b/doc/docs/doc/control-flow/conditionals.md
@@ -143,3 +143,61 @@ if a in list
143``` 143```
144 144
145</YueDisplay> 145</YueDisplay>
146
147The `in` operator can also be used with tables and supports the `not in` variant for negation:
148
149```yuescript
150has = "foo" in {"bar", "foo"}
151
152if a in {1, 2, 3}
153 print "a is in the table"
154
155not_exist = item not in list
156
157check = -> value not in table
158```
159
160<YueDisplay>
161
162```yue
163has = "foo" in {"bar", "foo"}
164
165if a in {1, 2, 3}
166 print "a is in the table"
167
168not_exist = item not in list
169
170check = -> value not in table
171```
172
173</YueDisplay>
174
175A single-element list or table checks for equality with that element:
176
177```yuescript
178-- [1,] checks if value == 1
179c = a in [1,]
180
181-- {1} also checks if value == 1
182c = a in {1}
183
184-- Without comma, [1] is indexing (tb[1])
185with tb
186 c = a in [1]
187```
188
189<YueDisplay>
190
191```yue
192-- [1,] checks if value == 1
193c = a in [1,]
194
195-- {1} also checks if value == 1
196c = a in {1}
197
198-- Without comma, [1] is indexing (tb[1])
199with tb
200 c = a in [1]
201```
202
203</YueDisplay>
diff --git a/doc/docs/doc/control-flow/goto.md b/doc/docs/doc/control-flow/goto.md
new file mode 100644
index 0000000..00227ba
--- /dev/null
+++ b/doc/docs/doc/control-flow/goto.md
@@ -0,0 +1,106 @@
1# Goto
2
3YueScript supports goto statement and label syntax for controlling program flow, following the same rules as Lua's goto statement. **Note:** The goto statement requires Lua 5.2 or higher. When compiling to Lua 5.1, using goto syntax will result in a compilation error.
4
5A label is defined using double colons:
6
7```yuescript
8::start::
9::done::
10::my_label::
11```
12
13<YueDisplay>
14
15```yue
16::start::
17::done::
18::my_label::
19```
20
21</YueDisplay>
22
23The goto statement jumps to a specified label:
24
25```yuescript
26a = 0
27::start::
28a += 1
29goto done if a == 5
30goto start
31::done::
32print "a is now 5"
33```
34
35<YueDisplay>
36
37```yue
38a = 0
39::start::
40a += 1
41goto done if a == 5
42goto start
43::done::
44print "a is now 5"
45```
46
47</YueDisplay>
48
49The goto statement is useful for breaking out of deeply nested loops:
50
51```yuescript
52for z = 1, 10
53 for y = 1, 10 do for x = 1, 10
54 if x^2 + y^2 == z^2
55 print 'found a Pythagorean triple:', x, y, z
56 goto ok
57::ok::
58```
59
60<YueDisplay>
61
62```yue
63for z = 1, 10
64 for y = 1, 10 do for x = 1, 10
65 if x^2 + y^2 == z^2
66 print 'found a Pythagorean triple:', x, y, z
67 goto ok
68::ok::
69```
70
71</YueDisplay>
72
73You can also use labels to jump to a specific loop level:
74
75```yuescript
76for z = 1, 10
77 for y = 1, 10
78 for x = 1, 10
79 if x^2 + y^2 == z^2
80 print 'found a Pythagorean triple:', x, y, z
81 print 'now trying next z...'
82 goto zcontinue
83 ::zcontinue::
84```
85
86<YueDisplay>
87
88```yue
89for z = 1, 10
90 for y = 1, 10
91 for x = 1, 10
92 if x^2 + y^2 == z^2
93 print 'found a Pythagorean triple:', x, y, z
94 print 'now trying next z...'
95 goto zcontinue
96 ::zcontinue::
97```
98
99</YueDisplay>
100
101## Notes
102
103- Labels must be unique within their scope
104- goto can jump to labels at the same or outer scope levels
105- goto cannot jump into inner scopes (like inside blocks or loops)
106- Use goto sparingly, as it can make code harder to read and maintain
diff --git a/doc/docs/id-id/doc/control-flow/conditionals.md b/doc/docs/id-id/doc/control-flow/conditionals.md
index 861eae6..db67a79 100644
--- a/doc/docs/id-id/doc/control-flow/conditionals.md
+++ b/doc/docs/id-id/doc/control-flow/conditionals.md
@@ -143,3 +143,61 @@ if a in list
143``` 143```
144 144
145</YueDisplay> 145</YueDisplay>
146
147Operator `in` juga dapat digunakan dengan tabel dan mendukung varian `not in` untuk negasi:
148
149```yuescript
150has = "foo" in {"bar", "foo"}
151
152if a in {1, 2, 3}
153 print "a ada di dalam tabel"
154
155not_exist = item not in list
156
157check = -> value not in table
158```
159
160<YueDisplay>
161
162```yue
163has = "foo" in {"bar", "foo"}
164
165if a in {1, 2, 3}
166 print "a ada di dalam tabel"
167
168not_exist = item not in list
169
170check = -> value not in table
171```
172
173</YueDisplay>
174
175Daftar atau tabel dengan satu elemen memeriksa kesamaan dengan elemen tersebut:
176
177```yuescript
178-- [1,] memeriksa apakah nilai == 1
179c = a in [1,]
180
181-- {1} juga memeriksa apakah nilai == 1
182c = a in {1}
183
184-- Tanpa koma, [1] adalah akses indeks (tb[1])
185with tb
186 c = a in [1]
187```
188
189<YueDisplay>
190
191```yue
192-- [1,] memeriksa apakah nilai == 1
193c = a in [1,]
194
195-- {1} juga memeriksa apakah nilai == 1
196c = a in {1}
197
198-- Tanpa koma, [1] adalah akses indeks (tb[1])
199with tb
200 c = a in [1]
201```
202
203</YueDisplay>
diff --git a/doc/docs/id-id/doc/control-flow/goto.md b/doc/docs/id-id/doc/control-flow/goto.md
new file mode 100644
index 0000000..f387f0d
--- /dev/null
+++ b/doc/docs/id-id/doc/control-flow/goto.md
@@ -0,0 +1,106 @@
1# Goto
2
3YueScript mendukung pernyataan goto dan sintaks label untuk mengontrol alur program, mengikuti aturan yang sama dengan pernyataan goto Lua. **Catatan:** Pernyataan goto memerlukan Lua 5.2 atau lebih tinggi. Saat mengompilasi ke Lua 5.1, penggunaan sintaks goto akan menyebabkan galat kompilasi.
4
5Label didefinisikan menggunakan dua titik dua:
6
7```yuescript
8::mulai::
9::selesai::
10::label_saya::
11```
12
13<YueDisplay>
14
15```yue
16::mulai::
17::selesai::
18::label_saya::
19```
20
21</YueDisplay>
22
23Pernyataan goto melompat ke label yang ditentukan:
24
25```yuescript
26a = 0
27::mulai::
28a += 1
29goto selesai if a == 5
30goto mulai
31::selesai::
32print "a sekarang 5"
33```
34
35<YueDisplay>
36
37```yue
38a = 0
39::mulai::
40a += 1
41goto selesai if a == 5
42goto mulai
43::selesai::
44print "a sekarang 5"
45```
46
47</YueDisplay>
48
49Pernyataan goto berguna untuk keluar dari loop yang bersarang dalam:
50
51```yuescript
52for z = 1, 10
53 for y = 1, 10 do for x = 1, 10
54 if x^2 + y^2 == z^2
55 print 'tripel Pythagorean ditemukan:', x, y, z
56 goto ok
57::ok::
58```
59
60<YueDisplay>
61
62```yue
63for z = 1, 10
64 for y = 1, 10 do for x = 1, 10
65 if x^2 + y^2 == z^2
66 print 'tripel Pythagorean ditemukan:', x, y, z
67 goto ok
68::ok::
69```
70
71</YueDisplay>
72
73Anda juga dapat menggunakan label untuk melompat ke tingkat loop tertentu:
74
75```yuescript
76for z = 1, 10
77 for y = 1, 10
78 for x = 1, 10
79 if x^2 + y^2 == z^2
80 print 'tripel Pythagorean ditemukan:', x, y, z
81 print 'mencoba z berikutnya...'
82 goto zcontinue
83 ::zcontinue::
84```
85
86<YueDisplay>
87
88```yue
89for z = 1, 10
90 for y = 1, 10
91 for x = 1, 10
92 if x^2 + y^2 == z^2
93 print 'tripel Pythagorean ditemukan:', x, y, z
94 print 'mencoba z berikutnya...'
95 goto zcontinue
96 ::zcontinue::
97```
98
99</YueDisplay>
100
101## Catatan
102
103- Label harus unik dalam cakupannya
104- goto dapat melompat ke label pada tingkat cakupan yang sama atau luar
105- goto tidak dapat melompat ke cakupan dalam (seperti di dalam blok atau loop)
106- Gunakan goto dengan hemat, karena dapat membuat kode lebih sulit dibaca dan dipelihara
diff --git a/doc/docs/pt-br/doc/control-flow/conditionals.md b/doc/docs/pt-br/doc/control-flow/conditionals.md
index bc12d4e..ce32d89 100644
--- a/doc/docs/pt-br/doc/control-flow/conditionals.md
+++ b/doc/docs/pt-br/doc/control-flow/conditionals.md
@@ -143,3 +143,61 @@ if a in list
143``` 143```
144 144
145</YueDisplay> 145</YueDisplay>
146
147O operador `in` também pode ser usado com tabelas e suporta a variante `not in` para negação:
148
149```yuescript
150has = "foo" in {"bar", "foo"}
151
152if a in {1, 2, 3}
153 print "a está na tabela"
154
155not_exist = item not in list
156
157check = -> value not in table
158```
159
160<YueDisplay>
161
162```yue
163has = "foo" in {"bar", "foo"}
164
165if a in {1, 2, 3}
166 print "a está na tabela"
167
168not_exist = item not in list
169
170check = -> value not in table
171```
172
173</YueDisplay>
174
175Uma lista ou tabela de único elemento verifica igualdade com esse elemento:
176
177```yuescript
178-- [1,] verifica se valor == 1
179c = a in [1,]
180
181-- {1} também verifica se valor == 1
182c = a in {1}
183
184-- Sem vírgula, [1] é acesso por índice (tb[1])
185with tb
186 c = a in [1]
187```
188
189<YueDisplay>
190
191```yue
192-- [1,] verifica se valor == 1
193c = a in [1,]
194
195-- {1} também verifica se valor == 1
196c = a in {1}
197
198-- Sem vírgula, [1] é acesso por índice (tb[1])
199with tb
200 c = a in [1]
201```
202
203</YueDisplay>
diff --git a/doc/docs/pt-br/doc/control-flow/goto.md b/doc/docs/pt-br/doc/control-flow/goto.md
new file mode 100644
index 0000000..f4c85f4
--- /dev/null
+++ b/doc/docs/pt-br/doc/control-flow/goto.md
@@ -0,0 +1,106 @@
1# Goto
2
3YueScript suporta a instrução goto e a sintaxe de rótulos para controlar o fluxo do programa, seguindo as mesmas regras da instrução goto do Lua. **Nota:** A instrução goto requer Lua 5.2 ou superior. Ao compilar para Lua 5.1, o uso da sintaxe goto resultará em um erro de compilação.
4
5Um rótulo é definido usando dois pontos duplos:
6
7```yuescript
8::inicio::
9::fim::
10::meu_rotulo::
11```
12
13<YueDisplay>
14
15```yue
16::inicio::
17::fim::
18::meu_rotulo::
19```
20
21</YueDisplay>
22
23A instrução goto salta para um rótulo especificado:
24
25```yuescript
26a = 0
27::inicio::
28a += 1
29goto fim if a == 5
30goto inicio
31::fim::
32print "a agora é 5"
33```
34
35<YueDisplay>
36
37```yue
38a = 0
39::inicio::
40a += 1
41goto fim if a == 5
42goto inicio
43::fim::
44print "a agora é 5"
45```
46
47</YueDisplay>
48
49A instrução goto é útil para sair de laços profundamente aninhados:
50
51```yuescript
52for z = 1, 10
53 for y = 1, 10 do for x = 1, 10
54 if x^2 + y^2 == z^2
55 print 'triplo pitagórico encontrado:', x, y, z
56 goto ok
57::ok::
58```
59
60<YueDisplay>
61
62```yue
63for z = 1, 10
64 for y = 1, 10 do for x = 1, 10
65 if x^2 + y^2 == z^2
66 print 'triplo pitagórico encontrado:', x, y, z
67 goto ok
68::ok::
69```
70
71</YueDisplay>
72
73Você também pode usar rótulos para pular para um nível específico de laço:
74
75```yuescript
76for z = 1, 10
77 for y = 1, 10
78 for x = 1, 10
79 if x^2 + y^2 == z^2
80 print 'triplo pitagórico encontrado:', x, y, z
81 print 'tentando próximo z...'
82 goto zcontinue
83 ::zcontinue::
84```
85
86<YueDisplay>
87
88```yue
89for z = 1, 10
90 for y = 1, 10
91 for x = 1, 10
92 if x^2 + y^2 == z^2
93 print 'triplo pitagórico encontrado:', x, y, z
94 print 'tentando próximo z...'
95 goto zcontinue
96 ::zcontinue::
97```
98
99</YueDisplay>
100
101## Notas
102
103- Rótulos devem ser únicos dentro de seu escopo
104- goto pode pular para rótulos nos mesmos níveis de escopo ou externos
105- goto não pode pular para escopos internos (como dentro de blocos ou laços)
106- Use goto com moderação, pois pode tornar o código mais difícil de ler e manter
diff --git a/doc/docs/zh/doc/control-flow/conditionals.md b/doc/docs/zh/doc/control-flow/conditionals.md
index 3a4d5d1..f8d2851 100644
--- a/doc/docs/zh/doc/control-flow/conditionals.md
+++ b/doc/docs/zh/doc/control-flow/conditionals.md
@@ -143,3 +143,61 @@ if a in list
143``` 143```
144 144
145</YueDisplay> 145</YueDisplay>
146
147`in` 运算符也可以用于表,并支持 `not in` 变体来进行否定检查:
148
149```yuescript
150has = "foo" in {"bar", "foo"}
151
152if a in {1, 2, 3}
153 print "a 在表中"
154
155not_exist = item not in list
156
157check = -> value not in table
158```
159
160<YueDisplay>
161
162```yue
163has = "foo" in {"bar", "foo"}
164
165if a in {1, 2, 3}
166 print "a 在表中"
167
168not_exist = item not in list
169
170check = -> value not in table
171```
172
173</YueDisplay>
174
175单元素列表或表会检查与该元素的相等性:
176
177```yuescript
178-- [1,] 检查 value == 1
179c = a in [1,]
180
181-- {1} 也是检查 value == 1
182c = a in {1}
183
184-- 没有逗号,[1] 是索引访问(tb[1])
185with tb
186 c = a in [1]
187```
188
189<YueDisplay>
190
191```yue
192-- [1,] 检查 value == 1
193c = a in [1,]
194
195-- {1} 也是检查 value == 1
196c = a in {1}
197
198-- 没有逗号,[1] 是索引访问(tb[1])
199with tb
200 c = a in [1]
201```
202
203</YueDisplay>
diff --git a/doc/docs/zh/doc/control-flow/goto.md b/doc/docs/zh/doc/control-flow/goto.md
new file mode 100644
index 0000000..6d1cc89
--- /dev/null
+++ b/doc/docs/zh/doc/control-flow/goto.md
@@ -0,0 +1,106 @@
1# Goto
2
3YueScript 支持 goto 语句和标签语法来控制程序流程,该语法遵循与 Lua 的 goto 语句相同的规则。**注意:** goto 语句需要 Lua 5.2 或更高版本。当编译目标是 Lua 5.1 时,使用 goto 语法将导致编译错误。
4
5标签使用双冒号定义:
6
7```yuescript
8::开始::
9::结束::
10::我的标签::
11```
12
13<YueDisplay>
14
15```yue
16::开始::
17::结束::
18::我的标签::
19```
20
21</YueDisplay>
22
23goto 语句可以跳转到指定的标签:
24
25```yuescript
26a = 0
27::开始::
28a += 1
29goto 结束 if a == 5
30goto 开始
31::结束::
32print "a 现在是 5"
33```
34
35<YueDisplay>
36
37```yue
38a = 0
39::开始::
40a += 1
41goto 结束 if a == 5
42goto 开始
43::结束::
44print "a 现在是 5"
45```
46
47</YueDisplay>
48
49goto 语句对于跳出深层嵌套循环非常有用:
50
51```yuescript
52for z = 1, 10
53 for y = 1, 10 do for x = 1, 10
54 if x^2 + y^2 == z^2
55 print '找到勾股数:', x, y, z
56 goto 完成
57::完成::
58```
59
60<YueDisplay>
61
62```yue
63for z = 1, 10
64 for y = 1, 10 do for x = 1, 10
65 if x^2 + y^2 == z^2
66 print '找到勾股数:', x, y, z
67 goto 完成
68::完成::
69```
70
71</YueDisplay>
72
73你也可以使用标签跳转到特定的循环层级:
74
75```yuescript
76for z = 1, 10
77 for y = 1, 10
78 for x = 1, 10
79 if x^2 + y^2 == z^2
80 print '找到勾股数:', x, y, z
81 print '尝试下一个 z...'
82 goto 继续z
83 ::继续z::
84```
85
86<YueDisplay>
87
88```yue
89for z = 1, 10
90 for y = 1, 10
91 for x = 1, 10
92 if x^2 + y^2 == z^2
93 print '找到勾股数:', x, y, z
94 print '尝试下一个 z...'
95 goto 继续z
96 ::继续z::
97```
98
99</YueDisplay>
100
101## 注意事项
102
103- 标签在其作用域内必须唯一
104- goto 可以跳转到相同或外层作用域级别的标签
105- goto 不能跳转到内层作用域(如代码块或循环内部)
106- 谨慎使用 goto,因为它会使代码更难阅读和维护
diff --git a/doc/yue-de.md b/doc/yue-de.md
index 9149231..1a13a47 100644
--- a/doc/yue-de.md
+++ b/doc/yue-de.md
@@ -2779,6 +2779,64 @@ if a in list
2779 2779
2780</YueDisplay> 2780</YueDisplay>
2781 2781
2782Der `in`-Operator kann auch mit Tabellen verwendet werden und unterstützt die Variante `not in` für Verneinungen:
2783
2784```yuescript
2785has = "foo" in {"bar", "foo"}
2786
2787if a in {1, 2, 3}
2788 print "a ist in der Tabelle"
2789
2790not_exist = item not in list
2791
2792check = -> value not in table
2793```
2794
2795<YueDisplay>
2796
2797```yue
2798has = "foo" in {"bar", "foo"}
2799
2800if a in {1, 2, 3}
2801 print "a ist in der Tabelle"
2802
2803not_exist = item not in list
2804
2805check = -> value not in table
2806```
2807
2808</YueDisplay>
2809
2810Eine Ein-Element-Liste oder Tabelle prüft auf Gleichheit mit diesem Element:
2811
2812```yuescript
2813-- [1,] prüft, ob wert == 1
2814c = a in [1,]
2815
2816-- {1} prüft auch, ob wert == 1
2817c = a in {1}
2818
2819-- Ohne Komma ist [1] ein Indexzugriff (tb[1])
2820with tb
2821 c = a in [1]
2822```
2823
2824<YueDisplay>
2825
2826```yue
2827-- [1,] prüft, ob wert == 1
2828c = a in [1,]
2829
2830-- {1} prüft auch, ob wert == 1
2831c = a in {1}
2832
2833-- Ohne Komma ist [1] ein Indexzugriff (tb[1])
2834with tb
2835 c = a in [1]
2836```
2837
2838</YueDisplay>
2839
2782# For-Schleife 2840# For-Schleife
2783 2841
2784Es gibt zwei Formen der `for`-Schleife, genau wie in Lua: eine numerische und eine generische. 2842Es gibt zwei Formen der `for`-Schleife, genau wie in Lua: eine numerische und eine generische.
diff --git a/doc/yue-en.md b/doc/yue-en.md
index a3d98d3..3f8546a 100644
--- a/doc/yue-en.md
+++ b/doc/yue-en.md
@@ -2780,6 +2780,64 @@ if a in list
2780 2780
2781</YueDisplay> 2781</YueDisplay>
2782 2782
2783The `in` operator can also be used with tables and supports the `not in` variant for negation:
2784
2785```yuescript
2786has = "foo" in {"bar", "foo"}
2787
2788if a in {1, 2, 3}
2789 print "a is in the table"
2790
2791not_exist = item not in list
2792
2793check = -> value not in table
2794```
2795
2796<YueDisplay>
2797
2798```yue
2799has = "foo" in {"bar", "foo"}
2800
2801if a in {1, 2, 3}
2802 print "a is in the table"
2803
2804not_exist = item not in list
2805
2806check = -> value not in table
2807```
2808
2809</YueDisplay>
2810
2811A single-element list or table checks for equality with that element:
2812
2813```yuescript
2814-- [1,] checks if value == 1
2815c = a in [1,]
2816
2817-- {1} also checks if value == 1
2818c = a in {1}
2819
2820-- Without comma, [1] is indexing (tb[1])
2821with tb
2822 c = a in [1]
2823```
2824
2825<YueDisplay>
2826
2827```yue
2828-- [1,] checks if value == 1
2829c = a in [1,]
2830
2831-- {1} also checks if value == 1
2832c = a in {1}
2833
2834-- Without comma, [1] is indexing (tb[1])
2835with tb
2836 c = a in [1]
2837```
2838
2839</YueDisplay>
2840
2783# For Loop 2841# For Loop
2784 2842
2785There are two for loop forms, just like in Lua. A numeric one and a generic one: 2843There are two for loop forms, just like in Lua. A numeric one and a generic one:
diff --git a/doc/yue-id-id.md b/doc/yue-id-id.md
index 365ee32..ca90d85 100644
--- a/doc/yue-id-id.md
+++ b/doc/yue-id-id.md
@@ -2778,6 +2778,64 @@ if a in list
2778 2778
2779</YueDisplay> 2779</YueDisplay>
2780 2780
2781Operator `in` juga dapat digunakan dengan tabel dan mendukung varian `not in` untuk negasi:
2782
2783```yuescript
2784has = "foo" in {"bar", "foo"}
2785
2786if a in {1, 2, 3}
2787 print "a ada di dalam tabel"
2788
2789not_exist = item not in list
2790
2791check = -> value not in table
2792```
2793
2794<YueDisplay>
2795
2796```yue
2797has = "foo" in {"bar", "foo"}
2798
2799if a in {1, 2, 3}
2800 print "a ada di dalam tabel"
2801
2802not_exist = item not in list
2803
2804check = -> value not in table
2805```
2806
2807</YueDisplay>
2808
2809Daftar atau tabel dengan satu elemen memeriksa kesamaan dengan elemen tersebut:
2810
2811```yuescript
2812-- [1,] memeriksa apakah nilai == 1
2813c = a in [1,]
2814
2815-- {1} juga memeriksa apakah nilai == 1
2816c = a in {1}
2817
2818-- Tanpa koma, [1] adalah akses indeks (tb[1])
2819with tb
2820 c = a in [1]
2821```
2822
2823<YueDisplay>
2824
2825```yue
2826-- [1,] memeriksa apakah nilai == 1
2827c = a in [1,]
2828
2829-- {1} juga memeriksa apakah nilai == 1
2830c = a in {1}
2831
2832-- Tanpa koma, [1] adalah akses indeks (tb[1])
2833with tb
2834 c = a in [1]
2835```
2836
2837</YueDisplay>
2838
2781# Perulangan For 2839# Perulangan For
2782 2840
2783Ada dua bentuk perulangan for, seperti di Lua. Satu numerik dan satu generik: 2841Ada dua bentuk perulangan for, seperti di Lua. Satu numerik dan satu generik:
diff --git a/doc/yue-pt-br.md b/doc/yue-pt-br.md
index ad0521a..7bab231 100644
--- a/doc/yue-pt-br.md
+++ b/doc/yue-pt-br.md
@@ -2777,6 +2777,64 @@ if a in list
2777 2777
2778</YueDisplay> 2778</YueDisplay>
2779 2779
2780O operador `in` também pode ser usado com tabelas e suporta a variante `not in` para negação:
2781
2782```yuescript
2783has = "foo" in {"bar", "foo"}
2784
2785if a in {1, 2, 3}
2786 print "a está na tabela"
2787
2788not_exist = item not in list
2789
2790check = -> value not in table
2791```
2792
2793<YueDisplay>
2794
2795```yue
2796has = "foo" in {"bar", "foo"}
2797
2798if a in {1, 2, 3}
2799 print "a está na tabela"
2800
2801not_exist = item not in list
2802
2803check = -> value not in table
2804```
2805
2806</YueDisplay>
2807
2808Uma lista ou tabela de único elemento verifica igualdade com esse elemento:
2809
2810```yuescript
2811-- [1,] verifica se valor == 1
2812c = a in [1,]
2813
2814-- {1} também verifica se valor == 1
2815c = a in {1}
2816
2817-- Sem vírgula, [1] é acesso por índice (tb[1])
2818with tb
2819 c = a in [1]
2820```
2821
2822<YueDisplay>
2823
2824```yue
2825-- [1,] verifica se valor == 1
2826c = a in [1,]
2827
2828-- {1} também verifica se valor == 1
2829c = a in {1}
2830
2831-- Sem vírgula, [1] é acesso por índice (tb[1])
2832with tb
2833 c = a in [1]
2834```
2835
2836</YueDisplay>
2837
2780# Loop For 2838# Loop For
2781 2839
2782Existem duas formas de loop for, assim como no Lua. Uma numérica e uma genérica: 2840Existem duas formas de loop for, assim como no Lua. Uma numérica e uma genérica:
diff --git a/doc/yue-zh.md b/doc/yue-zh.md
index d026fc2..93e21d8 100644
--- a/doc/yue-zh.md
+++ b/doc/yue-zh.md
@@ -2770,6 +2770,64 @@ if a in list
2770 2770
2771</YueDisplay> 2771</YueDisplay>
2772 2772
2773`in` 运算符也可以用于表,并支持 `not in` 变体来进行否定检查:
2774
2775```yuescript
2776has = "foo" in {"bar", "foo"}
2777
2778if a in {1, 2, 3}
2779 print "a 在表中"
2780
2781not_exist = item not in list
2782
2783check = -> value not in table
2784```
2785
2786<YueDisplay>
2787
2788```yue
2789has = "foo" in {"bar", "foo"}
2790
2791if a in {1, 2, 3}
2792 print "a 在表中"
2793
2794not_exist = item not in list
2795
2796check = -> value not in table
2797```
2798
2799</YueDisplay>
2800
2801单元素列表或表会检查与该元素的相等性:
2802
2803```yuescript
2804-- [1,] 检查 value == 1
2805c = a in [1,]
2806
2807-- {1} 也是检查 value == 1
2808c = a in {1}
2809
2810-- 没有逗号,[1] 是索引访问(tb[1])
2811with tb
2812 c = a in [1]
2813```
2814
2815<YueDisplay>
2816
2817```yue
2818-- [1,] 检查 value == 1
2819c = a in [1,]
2820
2821-- {1} 也是检查 value == 1
2822c = a in {1}
2823
2824-- 没有逗号,[1] 是索引访问(tb[1])
2825with tb
2826 c = a in [1]
2827```
2828
2829</YueDisplay>
2830
2773# for 循环 2831# for 循环
2774 2832
2775&emsp;&emsp;Lua 中有两种 for 循环形式,数字型和通用型: 2833&emsp;&emsp;Lua 中有两种 for 循环形式,数字型和通用型:
diff --git a/makefile b/makefile
index 8cf9854..47c574c 100644
--- a/makefile
+++ b/makefile
@@ -58,22 +58,29 @@ endif
58 LINK_FLAGS += -L $(SRC_PATH)/3rdParty/lua -llua -ldl 58 LINK_FLAGS += -L $(SRC_PATH)/3rdParty/lua -llua -ldl
59endif 59endif
60 60
61# Detect PRoot environment (e.g., PRoot-Distro)
62# PRoot can be detected by checking uname -v or /proc/version for "PRoot"
63IS_PROOT := $(shell uname -v 2>/dev/null | grep -q "PRoot" && echo yes || cat /proc/version 2>/dev/null | grep -q "PRoot" && echo yes)
64
61# Detect Android Termux environment 65# Detect Android Termux environment
62# Termux typically has ANDROID_ROOT environment variable set and PREFIX points to Termux directory 66# Termux typically has ANDROID_ROOT environment variable set and PREFIX points to Termux directory
67# Note: PRoot environments may have ANDROID_ROOT set but are not Termux
63IS_TERMUX := false 68IS_TERMUX := false
64ANDROID_ROOT_VAR := $(shell echo $$ANDROID_ROOT) 69ifeq ($(IS_PROOT),)
65PREFIX_VAR := $(shell echo $$PREFIX) 70 ANDROID_ROOT_VAR := $(shell echo $$ANDROID_ROOT)
66ifneq ($(ANDROID_ROOT_VAR),) 71 PREFIX_VAR := $(shell echo $$PREFIX)
67 # Check if PREFIX environment variable points to Termux directory 72 ifneq ($(ANDROID_ROOT_VAR),)
68 ifneq ($(PREFIX_VAR),) 73 # Check if PREFIX environment variable points to Termux directory
69 ifneq ($(findstring com.termux,$(PREFIX_VAR)),) 74 ifneq ($(PREFIX_VAR),)
70 IS_TERMUX := true 75 ifneq ($(findstring com.termux,$(PREFIX_VAR)),)
76 IS_TERMUX := true
77 endif
71 endif 78 endif
72 endif 79 # Alternative check: verify if Termux installation path exists
73 # Alternative check: verify if Termux installation path exists 80 ifeq ($(IS_TERMUX),false)
74 ifeq ($(IS_TERMUX),false) 81 ifneq ($(shell test -d /data/data/com.termux/files/usr && echo yes),)
75 ifneq ($(shell test -d /data/data/com.termux/files/usr && echo yes),) 82 IS_TERMUX := true
76 IS_TERMUX := true 83 endif
77 endif 84 endif
78 endif 85 endif
79endif 86endif
@@ -82,10 +89,14 @@ endif
82ifeq ($(IS_TERMUX),true) 89ifeq ($(IS_TERMUX),true)
83 ifeq ($(NO_WATCHER),) 90 ifeq ($(NO_WATCHER),)
84 NO_WATCHER := true 91 NO_WATCHER := true
85 $(info Detected Android Termux environment, automatically setting NO_WATCHER=true) 92 TERMUX_DETECTED := true
86 endif 93 endif
87endif 94endif
88 95
96ifdef TERMUX_DETECTED
97$(info Detected Android Termux environment, automatically setting NO_WATCHER=true)
98endif
99
89ifeq ($(NO_WATCHER),true) 100ifeq ($(NO_WATCHER),true)
90 COMPILE_FLAGS += -DYUE_NO_WATCHER 101 COMPILE_FLAGS += -DYUE_NO_WATCHER
91endif 102endif
diff --git a/spec/outputs/codes_from_doc_de.lua b/spec/outputs/codes_from_doc_de.lua
index 4c9ba1d..385dbae 100644
--- a/spec/outputs/codes_from_doc_de.lua
+++ b/spec/outputs/codes_from_doc_de.lua
@@ -2966,6 +2966,65 @@ if (function()
2966end)() then 2966end)() then
2967 print("Prüfen, ob `a` in einer Liste ist") 2967 print("Prüfen, ob `a` in einer Liste ist")
2968end 2968end
2969local has
2970do
2971 local _val_0 = "foo"
2972 has = "bar" == _val_0 or "foo" == _val_0
2973end
2974if (function()
2975 local _val_0 = a
2976 return 1 == _val_0 or 2 == _val_0 or 3 == _val_0
2977end)() then
2978 print("a ist in der Tabelle")
2979end
2980local not_exist
2981do
2982 local _check_0 = list
2983 local _val_0 = item
2984 local _find_0 = false
2985 for _index_0 = 1, #_check_0 do
2986 local _item_0 = _check_0[_index_0]
2987 if _item_0 == _val_0 then
2988 _find_0 = true
2989 break
2990 end
2991 end
2992 not_exist = not _find_0
2993end
2994local check
2995check = function()
2996 local _check_0 = table
2997 local _val_0 = value
2998 for _index_0 = 1, #_check_0 do
2999 if _check_0[_index_0] == _val_0 then
3000 return false
3001 end
3002 end
3003 return true
3004end
3005local c
3006do
3007 local _val_0 = a
3008 c = 1 == _val_0
3009end
3010do
3011 local _val_0 = a
3012 c = 1 == _val_0
3013end
3014local _with_0 = tb
3015do
3016 local _check_0 = _with_0[1]
3017 local _val_0 = a
3018 local _find_0 = false
3019 for _index_0 = 1, #_check_0 do
3020 local _item_0 = _check_0[_index_0]
3021 if _item_0 == _val_0 then
3022 _find_0 = true
3023 break
3024 end
3025 end
3026 c = _find_0
3027end
2969local have_coins = false 3028local have_coins = false
2970if have_coins then 3029if have_coins then
2971 print("Münzen erhalten") 3030 print("Münzen erhalten")
@@ -3022,6 +3081,65 @@ if (function()
3022end)() then 3081end)() then
3023 print("Prüfen, ob `a` in einer Liste ist") 3082 print("Prüfen, ob `a` in einer Liste ist")
3024end 3083end
3084local has
3085do
3086 local _val_0 = "foo"
3087 has = "bar" == _val_0 or "foo" == _val_0
3088end
3089if (function()
3090 local _val_0 = a
3091 return 1 == _val_0 or 2 == _val_0 or 3 == _val_0
3092end)() then
3093 print("a ist in der Tabelle")
3094end
3095local not_exist
3096do
3097 local _check_0 = list
3098 local _val_0 = item
3099 local _find_0 = false
3100 for _index_0 = 1, #_check_0 do
3101 local _item_0 = _check_0[_index_0]
3102 if _item_0 == _val_0 then
3103 _find_0 = true
3104 break
3105 end
3106 end
3107 not_exist = not _find_0
3108end
3109local check
3110check = function()
3111 local _check_0 = table
3112 local _val_0 = value
3113 for _index_0 = 1, #_check_0 do
3114 if _check_0[_index_0] == _val_0 then
3115 return false
3116 end
3117 end
3118 return true
3119end
3120local c
3121do
3122 local _val_0 = a
3123 c = 1 == _val_0
3124end
3125do
3126 local _val_0 = a
3127 c = 1 == _val_0
3128end
3129local _with_0 = tb
3130do
3131 local _check_0 = _with_0[1]
3132 local _val_0 = a
3133 local _find_0 = false
3134 for _index_0 = 1, #_check_0 do
3135 local _item_0 = _check_0[_index_0]
3136 if _item_0 == _val_0 then
3137 _find_0 = true
3138 break
3139 end
3140 end
3141 c = _find_0
3142end
3025for i = 10, 20 do 3143for i = 10, 20 do
3026 print(i) 3144 print(i)
3027end 3145end
diff --git a/spec/outputs/codes_from_doc_en.lua b/spec/outputs/codes_from_doc_en.lua
index 6d822e1..2d9c8cf 100644
--- a/spec/outputs/codes_from_doc_en.lua
+++ b/spec/outputs/codes_from_doc_en.lua
@@ -2966,6 +2966,65 @@ if (function()
2966end)() then 2966end)() then
2967 print("checking if `a` is in a list") 2967 print("checking if `a` is in a list")
2968end 2968end
2969local has
2970do
2971 local _val_0 = "foo"
2972 has = "bar" == _val_0 or "foo" == _val_0
2973end
2974if (function()
2975 local _val_0 = a
2976 return 1 == _val_0 or 2 == _val_0 or 3 == _val_0
2977end)() then
2978 print("a is in the table")
2979end
2980local not_exist
2981do
2982 local _check_0 = list
2983 local _val_0 = item
2984 local _find_0 = false
2985 for _index_0 = 1, #_check_0 do
2986 local _item_0 = _check_0[_index_0]
2987 if _item_0 == _val_0 then
2988 _find_0 = true
2989 break
2990 end
2991 end
2992 not_exist = not _find_0
2993end
2994local check
2995check = function()
2996 local _check_0 = table
2997 local _val_0 = value
2998 for _index_0 = 1, #_check_0 do
2999 if _check_0[_index_0] == _val_0 then
3000 return false
3001 end
3002 end
3003 return true
3004end
3005local c
3006do
3007 local _val_0 = a
3008 c = 1 == _val_0
3009end
3010do
3011 local _val_0 = a
3012 c = 1 == _val_0
3013end
3014local _with_0 = tb
3015do
3016 local _check_0 = _with_0[1]
3017 local _val_0 = a
3018 local _find_0 = false
3019 for _index_0 = 1, #_check_0 do
3020 local _item_0 = _check_0[_index_0]
3021 if _item_0 == _val_0 then
3022 _find_0 = true
3023 break
3024 end
3025 end
3026 c = _find_0
3027end
2969local have_coins = false 3028local have_coins = false
2970if have_coins then 3029if have_coins then
2971 print("Got coins") 3030 print("Got coins")
@@ -3022,6 +3081,65 @@ if (function()
3022end)() then 3081end)() then
3023 print("checking if `a` is in a list") 3082 print("checking if `a` is in a list")
3024end 3083end
3084local has
3085do
3086 local _val_0 = "foo"
3087 has = "bar" == _val_0 or "foo" == _val_0
3088end
3089if (function()
3090 local _val_0 = a
3091 return 1 == _val_0 or 2 == _val_0 or 3 == _val_0
3092end)() then
3093 print("a is in the table")
3094end
3095local not_exist
3096do
3097 local _check_0 = list
3098 local _val_0 = item
3099 local _find_0 = false
3100 for _index_0 = 1, #_check_0 do
3101 local _item_0 = _check_0[_index_0]
3102 if _item_0 == _val_0 then
3103 _find_0 = true
3104 break
3105 end
3106 end
3107 not_exist = not _find_0
3108end
3109local check
3110check = function()
3111 local _check_0 = table
3112 local _val_0 = value
3113 for _index_0 = 1, #_check_0 do
3114 if _check_0[_index_0] == _val_0 then
3115 return false
3116 end
3117 end
3118 return true
3119end
3120local c
3121do
3122 local _val_0 = a
3123 c = 1 == _val_0
3124end
3125do
3126 local _val_0 = a
3127 c = 1 == _val_0
3128end
3129local _with_0 = tb
3130do
3131 local _check_0 = _with_0[1]
3132 local _val_0 = a
3133 local _find_0 = false
3134 for _index_0 = 1, #_check_0 do
3135 local _item_0 = _check_0[_index_0]
3136 if _item_0 == _val_0 then
3137 _find_0 = true
3138 break
3139 end
3140 end
3141 c = _find_0
3142end
3025for i = 10, 20 do 3143for i = 10, 20 do
3026 print(i) 3144 print(i)
3027end 3145end
diff --git a/spec/outputs/codes_from_doc_id-id.lua b/spec/outputs/codes_from_doc_id-id.lua
index 4026240..7af01b7 100644
--- a/spec/outputs/codes_from_doc_id-id.lua
+++ b/spec/outputs/codes_from_doc_id-id.lua
@@ -2966,6 +2966,65 @@ if (function()
2966end)() then 2966end)() then
2967 print("memeriksa apakah `a` ada di dalam daftar") 2967 print("memeriksa apakah `a` ada di dalam daftar")
2968end 2968end
2969local has
2970do
2971 local _val_0 = "foo"
2972 has = "bar" == _val_0 or "foo" == _val_0
2973end
2974if (function()
2975 local _val_0 = a
2976 return 1 == _val_0 or 2 == _val_0 or 3 == _val_0
2977end)() then
2978 print("a ada di dalam tabel")
2979end
2980local not_exist
2981do
2982 local _check_0 = list
2983 local _val_0 = item
2984 local _find_0 = false
2985 for _index_0 = 1, #_check_0 do
2986 local _item_0 = _check_0[_index_0]
2987 if _item_0 == _val_0 then
2988 _find_0 = true
2989 break
2990 end
2991 end
2992 not_exist = not _find_0
2993end
2994local check
2995check = function()
2996 local _check_0 = table
2997 local _val_0 = value
2998 for _index_0 = 1, #_check_0 do
2999 if _check_0[_index_0] == _val_0 then
3000 return false
3001 end
3002 end
3003 return true
3004end
3005local c
3006do
3007 local _val_0 = a
3008 c = 1 == _val_0
3009end
3010do
3011 local _val_0 = a
3012 c = 1 == _val_0
3013end
3014local _with_0 = tb
3015do
3016 local _check_0 = _with_0[1]
3017 local _val_0 = a
3018 local _find_0 = false
3019 for _index_0 = 1, #_check_0 do
3020 local _item_0 = _check_0[_index_0]
3021 if _item_0 == _val_0 then
3022 _find_0 = true
3023 break
3024 end
3025 end
3026 c = _find_0
3027end
2969local have_coins = false 3028local have_coins = false
2970if have_coins then 3029if have_coins then
2971 print("Dapat koin") 3030 print("Dapat koin")
@@ -3022,6 +3081,65 @@ if (function()
3022end)() then 3081end)() then
3023 print("memeriksa apakah `a` ada di dalam daftar") 3082 print("memeriksa apakah `a` ada di dalam daftar")
3024end 3083end
3084local has
3085do
3086 local _val_0 = "foo"
3087 has = "bar" == _val_0 or "foo" == _val_0
3088end
3089if (function()
3090 local _val_0 = a
3091 return 1 == _val_0 or 2 == _val_0 or 3 == _val_0
3092end)() then
3093 print("a ada di dalam tabel")
3094end
3095local not_exist
3096do
3097 local _check_0 = list
3098 local _val_0 = item
3099 local _find_0 = false
3100 for _index_0 = 1, #_check_0 do
3101 local _item_0 = _check_0[_index_0]
3102 if _item_0 == _val_0 then
3103 _find_0 = true
3104 break
3105 end
3106 end
3107 not_exist = not _find_0
3108end
3109local check
3110check = function()
3111 local _check_0 = table
3112 local _val_0 = value
3113 for _index_0 = 1, #_check_0 do
3114 if _check_0[_index_0] == _val_0 then
3115 return false
3116 end
3117 end
3118 return true
3119end
3120local c
3121do
3122 local _val_0 = a
3123 c = 1 == _val_0
3124end
3125do
3126 local _val_0 = a
3127 c = 1 == _val_0
3128end
3129local _with_0 = tb
3130do
3131 local _check_0 = _with_0[1]
3132 local _val_0 = a
3133 local _find_0 = false
3134 for _index_0 = 1, #_check_0 do
3135 local _item_0 = _check_0[_index_0]
3136 if _item_0 == _val_0 then
3137 _find_0 = true
3138 break
3139 end
3140 end
3141 c = _find_0
3142end
3025for i = 10, 20 do 3143for i = 10, 20 do
3026 print(i) 3144 print(i)
3027end 3145end
diff --git a/spec/outputs/codes_from_doc_pt-br.lua b/spec/outputs/codes_from_doc_pt-br.lua
index 0d0c76f..dfe0108 100644
--- a/spec/outputs/codes_from_doc_pt-br.lua
+++ b/spec/outputs/codes_from_doc_pt-br.lua
@@ -2966,6 +2966,65 @@ if (function()
2966end)() then 2966end)() then
2967 print("verificando se `a` está na lista") 2967 print("verificando se `a` está na lista")
2968end 2968end
2969local has
2970do
2971 local _val_0 = "foo"
2972 has = "bar" == _val_0 or "foo" == _val_0
2973end
2974if (function()
2975 local _val_0 = a
2976 return 1 == _val_0 or 2 == _val_0 or 3 == _val_0
2977end)() then
2978 print("a está na tabela")
2979end
2980local not_exist
2981do
2982 local _check_0 = list
2983 local _val_0 = item
2984 local _find_0 = false
2985 for _index_0 = 1, #_check_0 do
2986 local _item_0 = _check_0[_index_0]
2987 if _item_0 == _val_0 then
2988 _find_0 = true
2989 break
2990 end
2991 end
2992 not_exist = not _find_0
2993end
2994local check
2995check = function()
2996 local _check_0 = table
2997 local _val_0 = value
2998 for _index_0 = 1, #_check_0 do
2999 if _check_0[_index_0] == _val_0 then
3000 return false
3001 end
3002 end
3003 return true
3004end
3005local c
3006do
3007 local _val_0 = a
3008 c = 1 == _val_0
3009end
3010do
3011 local _val_0 = a
3012 c = 1 == _val_0
3013end
3014local _with_0 = tb
3015do
3016 local _check_0 = _with_0[1]
3017 local _val_0 = a
3018 local _find_0 = false
3019 for _index_0 = 1, #_check_0 do
3020 local _item_0 = _check_0[_index_0]
3021 if _item_0 == _val_0 then
3022 _find_0 = true
3023 break
3024 end
3025 end
3026 c = _find_0
3027end
2969local have_coins = false 3028local have_coins = false
2970if have_coins then 3029if have_coins then
2971 print("Tem moedas") 3030 print("Tem moedas")
@@ -3022,6 +3081,65 @@ if (function()
3022end)() then 3081end)() then
3023 print("verificando se `a` está na lista") 3082 print("verificando se `a` está na lista")
3024end 3083end
3084local has
3085do
3086 local _val_0 = "foo"
3087 has = "bar" == _val_0 or "foo" == _val_0
3088end
3089if (function()
3090 local _val_0 = a
3091 return 1 == _val_0 or 2 == _val_0 or 3 == _val_0
3092end)() then
3093 print("a está na tabela")
3094end
3095local not_exist
3096do
3097 local _check_0 = list
3098 local _val_0 = item
3099 local _find_0 = false
3100 for _index_0 = 1, #_check_0 do
3101 local _item_0 = _check_0[_index_0]
3102 if _item_0 == _val_0 then
3103 _find_0 = true
3104 break
3105 end
3106 end
3107 not_exist = not _find_0
3108end
3109local check
3110check = function()
3111 local _check_0 = table
3112 local _val_0 = value
3113 for _index_0 = 1, #_check_0 do
3114 if _check_0[_index_0] == _val_0 then
3115 return false
3116 end
3117 end
3118 return true
3119end
3120local c
3121do
3122 local _val_0 = a
3123 c = 1 == _val_0
3124end
3125do
3126 local _val_0 = a
3127 c = 1 == _val_0
3128end
3129local _with_0 = tb
3130do
3131 local _check_0 = _with_0[1]
3132 local _val_0 = a
3133 local _find_0 = false
3134 for _index_0 = 1, #_check_0 do
3135 local _item_0 = _check_0[_index_0]
3136 if _item_0 == _val_0 then
3137 _find_0 = true
3138 break
3139 end
3140 end
3141 c = _find_0
3142end
3025for i = 10, 20 do 3143for i = 10, 20 do
3026 print(i) 3144 print(i)
3027end 3145end
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua
index c847841..6db4a43 100644
--- a/spec/outputs/codes_from_doc_zh.lua
+++ b/spec/outputs/codes_from_doc_zh.lua
@@ -2966,6 +2966,65 @@ if (function()
2966end)() then 2966end)() then
2967 print("检查`a`是否在列表中") 2967 print("检查`a`是否在列表中")
2968end 2968end
2969local has
2970do
2971 local _val_0 = "foo"
2972 has = "bar" == _val_0 or "foo" == _val_0
2973end
2974if (function()
2975 local _val_0 = a
2976 return 1 == _val_0 or 2 == _val_0 or 3 == _val_0
2977end)() then
2978 print("a 在表中")
2979end
2980local not_exist
2981do
2982 local _check_0 = list
2983 local _val_0 = item
2984 local _find_0 = false
2985 for _index_0 = 1, #_check_0 do
2986 local _item_0 = _check_0[_index_0]
2987 if _item_0 == _val_0 then
2988 _find_0 = true
2989 break
2990 end
2991 end
2992 not_exist = not _find_0
2993end
2994local check
2995check = function()
2996 local _check_0 = table
2997 local _val_0 = value
2998 for _index_0 = 1, #_check_0 do
2999 if _check_0[_index_0] == _val_0 then
3000 return false
3001 end
3002 end
3003 return true
3004end
3005local c
3006do
3007 local _val_0 = a
3008 c = 1 == _val_0
3009end
3010do
3011 local _val_0 = a
3012 c = 1 == _val_0
3013end
3014local _with_0 = tb
3015do
3016 local _check_0 = _with_0[1]
3017 local _val_0 = a
3018 local _find_0 = false
3019 for _index_0 = 1, #_check_0 do
3020 local _item_0 = _check_0[_index_0]
3021 if _item_0 == _val_0 then
3022 _find_0 = true
3023 break
3024 end
3025 end
3026 c = _find_0
3027end
2969local have_coins = false 3028local have_coins = false
2970if have_coins then 3029if have_coins then
2971 print("有硬币") 3030 print("有硬币")
@@ -3022,6 +3081,65 @@ if (function()
3022end)() then 3081end)() then
3023 print("检查`a`是否在列表中") 3082 print("检查`a`是否在列表中")
3024end 3083end
3084local has
3085do
3086 local _val_0 = "foo"
3087 has = "bar" == _val_0 or "foo" == _val_0
3088end
3089if (function()
3090 local _val_0 = a
3091 return 1 == _val_0 or 2 == _val_0 or 3 == _val_0
3092end)() then
3093 print("a 在表中")
3094end
3095local not_exist
3096do
3097 local _check_0 = list
3098 local _val_0 = item
3099 local _find_0 = false
3100 for _index_0 = 1, #_check_0 do
3101 local _item_0 = _check_0[_index_0]
3102 if _item_0 == _val_0 then
3103 _find_0 = true
3104 break
3105 end
3106 end
3107 not_exist = not _find_0
3108end
3109local check
3110check = function()
3111 local _check_0 = table
3112 local _val_0 = value
3113 for _index_0 = 1, #_check_0 do
3114 if _check_0[_index_0] == _val_0 then
3115 return false
3116 end
3117 end
3118 return true
3119end
3120local c
3121do
3122 local _val_0 = a
3123 c = 1 == _val_0
3124end
3125do
3126 local _val_0 = a
3127 c = 1 == _val_0
3128end
3129local _with_0 = tb
3130do
3131 local _check_0 = _with_0[1]
3132 local _val_0 = a
3133 local _find_0 = false
3134 for _index_0 = 1, #_check_0 do
3135 local _item_0 = _check_0[_index_0]
3136 if _item_0 == _val_0 then
3137 _find_0 = true
3138 break
3139 end
3140 end
3141 c = _find_0
3142end
3025for i = 10, 20 do 3143for i = 10, 20 do
3026 print(i) 3144 print(i)
3027end 3145end
diff --git a/src/yue.cpp b/src/yue.cpp
index a30075d..0493205 100644
--- a/src/yue.cpp
+++ b/src/yue.cpp
@@ -264,7 +264,9 @@ static std::string compileFile(const fs::path& file, yue::YueConfig conf, const
264 return "Failed to read file: "s + srcFile.string() + '\n'; 264 return "Failed to read file: "s + srcFile.string() + '\n';
265 } 265 }
266} 266}
267#endif // YUE_NO_WATCHER
267 268
269#ifndef YUE_NO_WATCHER
268class UpdateListener : public efsw::FileWatchListener { 270class UpdateListener : public efsw::FileWatchListener {
269public: 271public:
270 void handleFileAction(efsw::WatchID, const std::string& dir, const std::string& filename, efsw::Action action, std::string) override { 272 void handleFileAction(efsw::WatchID, const std::string& dir, const std::string& filename, efsw::Action action, std::string) override {