blob: a25220ce1e6bc7265d6b3cc7a74a5c29d0288c10 (
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
66
67
68
69
70
71
72
|
implement Switch;
include "sys.m";
include "draw.m";
sys: Sys;
print, FD: import sys;
Switch: module {
init: fn(nil: ref Draw->Context, nil: list of string);
};
init(nil: ref Draw->Context, nil: list of string) {
sys = load Sys Sys->PATH;
i := 10;
# The label labelling the enclosing construct
loop:
for(; i >= 0; i--)
case i {
0 or 2 or 4 or 6 or 8 or 10 =>
print("Even\n");
continue loop;
* =>
print("Odd\n");
break loop;
}
print("i's value: %d\n", i);
c := 'c';
case c {
'a' to 'f' =>
print("Valid hex\n");
'C' =>
print("The letter 'C'\n");
* =>
print("The default\n");
}
str := "ducks";
case str {
"ducks" =>
print("Quack!\n");
"" =>
print("Nil string\n");
}
n := 1;
case n {
0 or 1 =>
print("This is binary\n");
* =>
print("This is non-binary\n");
}
f := big 6;
case f {
big 4 => print("The number 4\n");
big 5 => print("The number 7\n");
* =>
print("Neither 4 nor 7\n");
}
exit;
}
|