From 4804893a6616a312ac8028e42d2aa990018ffbe6 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 12 Apr 2017 16:58:18 +0200 Subject: Modularize primitives implementation, add stack manipulators --- src/stack.d | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/stack.d') 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)); } -- cgit v1.2.3