aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/goto.yue
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-02-17 11:22:07 +0800
committerLi Jin <dragon-fly@qq.com>2021-02-17 11:22:07 +0800
commit7066392d1c974065181d95d93274136dcd625d43 (patch)
treecf51eafc2c52cbc12246a306bca172d799193d30 /spec/inputs/goto.yue
parent90cd12ad9ef465f3e435e1bd034dcfbe4e19d016 (diff)
downloadyuescript-7066392d1c974065181d95d93274136dcd625d43.tar.gz
yuescript-7066392d1c974065181d95d93274136dcd625d43.tar.bz2
yuescript-7066392d1c974065181d95d93274136dcd625d43.zip
stop reusing variables, rename project.
Diffstat (limited to 'spec/inputs/goto.yue')
-rw-r--r--spec/inputs/goto.yue41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/inputs/goto.yue b/spec/inputs/goto.yue
new file mode 100644
index 0000000..1197251
--- /dev/null
+++ b/spec/inputs/goto.yue
@@ -0,0 +1,41 @@
1do
2 a = 0
3 ::start::
4 a += 1
5 goto done if a == 5
6 goto start
7 ::done::
8
9do
10 for z = 1, 10 do for y = 1, 10 do for x = 1, 10
11 if x^2 + y^2 == z^2
12 print 'found a Pythagorean triple:', x, y, z
13 goto done
14 ::done::
15
16do
17 for z = 1, 10
18 for y = 1, 10 do for x = 1, 10
19 if x^2 + y^2 == z^2
20 print 'found a Pythagorean triple:', x, y, z
21 print 'now trying next z...'
22 goto zcontinue
23 ::zcontinue::
24
25do
26 ::redo::
27 for x = 1, 10 do for y = 1, 10
28 if not f x, y then goto continue
29 if not g x, y then goto skip
30 if not h x, y then goto redo
31 ::continue::
32 ::skip::
33
34do
35 for x in *t
36 if x % 2 == 0
37 print 'list has even number'
38 goto has
39 print 'list lacks even number'
40 ::has::
41