diff options
author | Adrian Kummerlaender | 2017-04-15 22:33:15 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2017-04-15 22:34:47 +0200 |
commit | b1fa3024fd2fae76e6e0345861f3fa17b4a082ef (patch) | |
tree | 876a34b82c291c9b3b10219198a3d7f26b2b6686 /source/base | |
parent | a654500cd3084cff93e4cf866a15e7977ff0cc94 (diff) | |
download | slang-b1fa3024fd2fae76e6e0345861f3fa17b4a082ef.tar slang-b1fa3024fd2fae76e6e0345861f3fa17b4a082ef.tar.gz slang-b1fa3024fd2fae76e6e0345861f3fa17b4a082ef.tar.bz2 slang-b1fa3024fd2fae76e6e0345861f3fa17b4a082ef.tar.lz slang-b1fa3024fd2fae76e6e0345861f3fa17b4a082ef.tar.xz slang-b1fa3024fd2fae76e6e0345861f3fa17b4a082ef.tar.zst slang-b1fa3024fd2fae76e6e0345861f3fa17b4a082ef.zip |
Hide module implementation details
Diffstat (limited to 'source/base')
-rw-r--r-- | source/base/definition.d | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/source/base/definition.d b/source/base/definition.d index 4c0f50c..d37ad20 100644 --- a/source/base/definition.d +++ b/source/base/definition.d @@ -10,8 +10,27 @@ import base.stack; alias Words = Stack!Token[string]; +Words words; + +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; + } else { + return Stack!Token(Token(word)); + } +} + +private { + Nullable!(DList!Token) definition; -Words words; void register(DList!Token definition) { string wordToBeDefined; @@ -62,18 +81,4 @@ bool handle(string word) { } } -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; - } else { - return Stack!Token(Token(word)); - } } |