aboutsummaryrefslogtreecommitdiff
path: root/src/primitives/eval.d
blob: 533f491d1e0786bb27b517720a73e2d4c4553b0d (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
module src.primitives.eval;

import src.primitives.impl;

bool evaluate(int value) {
	return drop_mode;
}

bool evaluate(string word) {
	if ( drop_mode ) {
		switch ( word ) {
			case "then":
				return conditional_then;
			case "else":
				return conditional_else;
			default:
				return true;
		}
	}

	switch ( word ) {
		case "§":
			return definition_start;
		case "$":
			return binary_op_variable_bind;
		case "@":
			return unary_op_variable_resolve;
		case "if":
			return conditional_if;
		case "then":
			return conditional_then;
		case "else":
			return conditional_else;
		case "+":
			return binary_op_add;
		case "*":
			return binary_op_multiply;
		case "/":
			return binary_op_divide;
		case "%":
			return binary_op_modulo;
		case ".":
			return unary_op_io_print;
		case "pop":
			return unary_op_stack_pop;
		case "dup":
			return unary_op_stack_dup;
		case "swp":
			return binary_op_stack_swp;
		case "<":
			return binary_cond_lt;
		case "=":
			return binary_cond_eq;
		default:
			return false;
	}
}