From 963ace2e5ba0337130e5f343d7ab97a30b4547ae Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 14 Apr 2017 18:05:15 +0200 Subject: Simplify token handling in the context of word definitions --- src/definition.d | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/definition.d b/src/definition.d index 7429f4b..9c3606e 100644 --- a/src/definition.d +++ b/src/definition.d @@ -35,40 +35,24 @@ void end() { definition.nullify; } -template handle(T) -if ( is(T == int) || is(T == bool) ) { - bool handle(T value) { - if ( definition.isNull ) { - return false; - } else { - definition.insertBack(Token(value)); - return true; - } - } -} - -bool handle(string word) { +bool handle(Token token) { if ( definition.isNull ) { return false; } else { - if ( word == ";" ) { - end(); + if ( token.type == typeid(string) ) { + if ( *token.peek!string == ";" ) { + end; + } else { + definition.insertBack(token); + } } else { - definition.insertBack(Token(word)); + definition.insertBack(token); } return true; } } -bool handle(Token token) { - return token.visit!( - (int value) => handle(value), - (bool value) => handle(value), - (string word ) => handle(word) - ); -} - Stack!Token get(string word) { if ( word in words ) { return words[word].dup; -- cgit v1.2.3