summaryrefslogtreecommitdiff
path: root/tests/control_flow.toc
blob: f54a8bc3b072dc90227042b43d0fad520674f4fe (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
#include "std/io.toc", io;

f ::= fn() int {
	total := 0;
	for i := 1..10 {
		if i % 2 == 0 { continue; }
		total += i;
		if i == 7 { break; }
	}
	i := 0;
	while true {
		i += 1;
		total += i;
		if i == 10 {
			break;
		}
	}
	while i < 100 {
		i += 1;
		if i == 100 {
			return total;
		}
	}
	0
}

main ::= fn() {
	x ::= f();
	io.puti(x);
	io.puti(f());
}