aboutsummaryrefslogtreecommitdiff
path: root/source/primitives
diff options
context:
space:
mode:
Diffstat (limited to 'source/primitives')
-rw-r--r--source/primitives/conditional.d2
-rw-r--r--source/primitives/core.d20
-rw-r--r--source/primitives/eval.d10
3 files changed, 10 insertions, 22 deletions
diff --git a/source/primitives/conditional.d b/source/primitives/conditional.d
index 5dc0fa5..fd101bd 100644
--- a/source/primitives/conditional.d
+++ b/source/primitives/conditional.d
@@ -4,7 +4,7 @@ import std.variant;
import std.typecons;
import std.container : DList;
-import base.stack;
+import state.stack;
bool handle(string word) {
switch ( word ) {
diff --git a/source/primitives/core.d b/source/primitives/core.d
index cae577b..75783ed 100644
--- a/source/primitives/core.d
+++ b/source/primitives/core.d
@@ -2,12 +2,10 @@ module primitives.core;
import std.stdio;
-import base.stack;
+import state.stack;
bool handle(string word) {
switch ( word ) {
- case "$" : binary_op_variable_bind; break;
- case "@" : unary_op_variable_resolve; break;
case "+" : binary_op_add; break;
case "*" : binary_op_multiply; break;
case "/" : binary_op_divide; break;
@@ -28,22 +26,6 @@ bool handle(string word) {
private {
-Token[string] variables;
-
-void binary_op_variable_bind() {
- string name = stack.pop.get!string;
- Token value = stack.pop;
- variables[name] = value;
-}
-
-void unary_op_variable_resolve() {
- string name = stack.pop.get!string;
-
- if ( name in variables ) {
- stack.push(variables[name]);
- }
-}
-
void binary_op_add() {
int b = stack.pop.get!int;
int a = stack.pop.get!int;
diff --git a/source/primitives/eval.d b/source/primitives/eval.d
index fc5938e..a18e897 100644
--- a/source/primitives/eval.d
+++ b/source/primitives/eval.d
@@ -2,10 +2,12 @@ module primitives.eval;
import std.variant;
-import base.stack;
+import state.stack;
+
+import definition = state.definition;
+import variable = state.variable;
import core = primitives.core;
-import definition = base.definition;
import conditional = primitives.conditional;
bool evaluate(Token token) {
@@ -17,6 +19,10 @@ bool evaluate(Token token) {
return true;
}
+ if ( variable.handle(token) ) {
+ return true;
+ }
+
return token.visit!(
(int value) => false,
(bool value) => false,