blob: fc5938ea4bb8b0e89da3e7f323e8716a737ac7a1 (
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
|
module primitives.eval;
import std.variant;
import base.stack;
import core = primitives.core;
import definition = base.definition;
import conditional = primitives.conditional;
bool evaluate(Token token) {
if ( definition.handle(token) ) {
return true;
}
if ( conditional.handle(token) ) {
return true;
}
return token.visit!(
(int value) => false,
(bool value) => false,
(string word ) => core.handle(word)
);
}
Stack!Token result() {
if ( conditional.dischargeable ) {
return conditional.discharge;
} else {
return Stack!Token();
}
}
|