aboutsummaryrefslogtreecommitdiff
path: root/src/definition.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/definition.d')
-rw-r--r--src/definition.d15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/definition.d b/src/definition.d
index e6a7789..7429f4b 100644
--- a/src/definition.d
+++ b/src/definition.d
@@ -3,11 +3,12 @@ module src.definition;
import std.string;
import std.variant;
import std.typecons;
+
import std.container : DList;
-import src.stack : Token;
+import src.stack;
-alias Words = DList!Token[string];
+alias Words = Stack!Token[string];
Nullable!(DList!Token) definition;
Words words;
@@ -30,7 +31,7 @@ void end() {
}
definition.removeFront;
- words[wordToBeDefined] = definition;
+ words[wordToBeDefined] = Stack!Token(definition[]);
definition.nullify;
}
@@ -67,3 +68,11 @@ bool handle(Token token) {
(string word ) => handle(word)
);
}
+
+Stack!Token get(string word) {
+ if ( word in words ) {
+ return words[word].dup;
+ } else {
+ return Stack!Token(Token(word));
+ }
+}