aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2020-03-24 10:19:30 +0800
committerLi Jin <dragon-fly@qq.com>2020-03-24 10:19:30 +0800
commit2447d158241aeaaf9c0b1ab21a08db7a40e5cef3 (patch)
treea8c17610aae77e61ee713b090546e3ae7d35f967 /spec
parent14d7e02285857226e26288c1ac83a14eb4fbd478 (diff)
downloadyuescript-2447d158241aeaaf9c0b1ab21a08db7a40e5cef3.tar.gz
yuescript-2447d158241aeaaf9c0b1ab21a08db7a40e5cef3.tar.bz2
yuescript-2447d158241aeaaf9c0b1ab21a08db7a40e5cef3.zip
add goto statement support.
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/goto.moon41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/inputs/goto.moon b/spec/inputs/goto.moon
new file mode 100644
index 0000000..3410ca3
--- /dev/null
+++ b/spec/inputs/goto.moon
@@ -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 for y = 1, 10 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 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 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