From b1fa3024fd2fae76e6e0345861f3fa17b4a082ef Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 15 Apr 2017 22:33:15 +0200 Subject: Hide module implementation details --- source/base/definition.d | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'source/base') 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)); - } } -- cgit v1.2.3