aboutsummaryrefslogtreecommitdiff
path: root/doc/docs
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-02-15 05:49:13 +0000
committerLi Jin <dragon-fly@qq.com>2026-02-15 07:36:30 +0000
commitcf5b1b4a68d762e6e33cac8367611ecea15fa942 (patch)
tree25de1a4113d26882c0135e38b7ff166efbc39969 /doc/docs
parentecd8f3bfd07e91d04e0a2d72f4a50f9cc6c75433 (diff)
downloadyuescript-cf5b1b4a68d762e6e33cac8367611ecea15fa942.tar.gz
yuescript-cf5b1b4a68d762e6e33cac8367611ecea15fa942.tar.bz2
yuescript-cf5b1b4a68d762e6e33cac8367611ecea15fa942.zip
Add goto statement documentation and testsHEADmain
- Added goto.md documentation files in all languages (en, de, zh, pt-br, id-id) - Updated conditionals.md to include goto statement references - Updated VitePress config to include new goto documentation pages - Updated makefile for goto documentation compilation - Added test outputs for goto examples in all languages - Updated yue.cpp core implementation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'doc/docs')
-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
11 files changed, 829 insertions, 0 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,因为它会使代码更难阅读和维护