-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.re
75 lines (64 loc) · 1.07 KB
/
main.re
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
73
74
75
gen fn bar() -> int {
yield if true {
yield 1;
3
} else {
yield 2;
4
};
}
let bar = bar();
print(bar.next());
print(bar.next());
print(bar.next());
// yield (1330 + {yield 42; 7})
// fn make_1337(x: ()) -> int { 1337 }
// yield make_1337(yield 42);
/*
gen fn range(mut start: int, end: int) -> int {
while start < end {
let foo: () = yield start;
start += 1;
}
}
CODE:
match expr {
Value::Int(i) => a(i),
Value::Float(f) => b(f),
_ => c(),
}
d();
GRAPH:
node_0:
expr()
-> node_1 [Value::Int(i)]
-> node_2 [Value::Float(f)]
-> node_3 [_]
node_1:
a(i);
-> node_4 [()]
node_2:
b(f);
-> node_4 [()]
node_3:
c();
-> node_4 [()]
node_4:
d();
GENERATED:
loop {
self.state = match self.state {
0 => match { expr() } {
Value::Int(i) => {
state.i = i;
1
},
Value::Float(f) => {
state.f = f;
},
_ => 3
}
}
}
let foo = struct Bar { a: int };
*/