blob: 07ef9f7a57b82607277bbfc3a4f0349307c8e056 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include "std/io.toc", io;
plusone ::= fn(n : int) x := n {
defer x += 1;
}
same ::= fn(n : int) int {
x := n;
defer x += 1;
x
}
thing1 ::= fn() (int, int) {
x := 5;
y := 6;
defer x += 1;
x, y
}
thing2 ::= fn() x := 5, y := 6 {
defer x += 1;
}
main ::= fn() {
io.puti(plusone(3));
io.puti(same(3));
a, b := thing1();
c, d := thing2();
e, f ::= thing1();
g, h ::= thing2();
io.puti(a); io.puti(b); io.puti(c); io.puti(d);
io.puti(e); io.puti(f); io.puti(g); io.puti(h);
defer io.puts("deferred from main()");
for i := 1..10 {
defer io.puts("deferred from for");
io.puti(i);
if i == 2 {
defer io.puts("deferred from if1");
defer io.puts("deferred from if2");
defer io.puts("deferred from if3");
defer io.puts("deferred from if4");
defer io.puts("deferred from if5");
defer io.puts("deferred from if6");
defer io.puts("deferred from if7");
defer io.puts("deferred from if8");
continue;
}
if i == 8 {
break;
}
}
i := 0;
while true {
defer io.puts("deferred from while");
i += 1;
io.puti(i);
if i % 2 == 0 { continue; }
if i == 7 {
defer io.puts("deferred from if");
break;
}
}
io.puts("end of main()");
}
|