aboutsummaryrefslogtreecommitdiff
path: root/src/stack.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/stack.d')
-rw-r--r--src/stack.d17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/stack.d b/src/stack.d
index 756dafc..6805873 100644
--- a/src/stack.d
+++ b/src/stack.d
@@ -25,14 +25,19 @@ Token pop(ref Stack!Token stack) {
return token;
}
-void push(ref Stack!Token stack, int value) {
- if ( !src.definition.handle(value) ) {
- stack.insertFront(Token(value));
+void push(ref Stack!Token stack, Token token) {
+ if ( !token.visit!(
+ (int x ) => src.definition.handle(x),
+ (string word) => src.definition.handle(word)
+ ) ) {
+ stack.insertFront(token);
}
}
+void push(ref Stack!Token stack, int value) {
+ stack.push(Token(value));
+}
+
void push(ref Stack!Token stack, string word) {
- if ( !src.definition.handle(word) ) {
- stack.insertFront(Token(word));
- }
+ stack.push(Token(word));
}