diff options
author | Adrian Kummerlaender | 2017-04-14 18:05:15 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2017-04-14 18:05:15 +0200 |
commit | 963ace2e5ba0337130e5f343d7ab97a30b4547ae (patch) | |
tree | 6e7abfd2eea735e2d146560e1fc6fc8bff68004a /src | |
parent | 526b06922e10fcfe1d1613a1e639694b0d892504 (diff) | |
download | slang-963ace2e5ba0337130e5f343d7ab97a30b4547ae.tar slang-963ace2e5ba0337130e5f343d7ab97a30b4547ae.tar.gz slang-963ace2e5ba0337130e5f343d7ab97a30b4547ae.tar.bz2 slang-963ace2e5ba0337130e5f343d7ab97a30b4547ae.tar.lz slang-963ace2e5ba0337130e5f343d7ab97a30b4547ae.tar.xz slang-963ace2e5ba0337130e5f343d7ab97a30b4547ae.tar.zst slang-963ace2e5ba0337130e5f343d7ab97a30b4547ae.zip |
Simplify token handling in the context of word definitions
Diffstat (limited to 'src')
-rw-r--r-- | src/definition.d | 32 |
1 files changed, 8 insertions, 24 deletions
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; |