diff options
author | Adrian Kummerlaender | 2017-04-14 17:40:49 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2017-04-14 17:40:49 +0200 |
commit | 526b06922e10fcfe1d1613a1e639694b0d892504 (patch) | |
tree | b4b5300ccede02694b284629ad572f19ebdca866 | |
parent | d2126fe52fd3c002631e66fa7d6e2d5cd8862bea (diff) | |
download | slang-526b06922e10fcfe1d1613a1e639694b0d892504.tar slang-526b06922e10fcfe1d1613a1e639694b0d892504.tar.gz slang-526b06922e10fcfe1d1613a1e639694b0d892504.tar.bz2 slang-526b06922e10fcfe1d1613a1e639694b0d892504.tar.lz slang-526b06922e10fcfe1d1613a1e639694b0d892504.tar.xz slang-526b06922e10fcfe1d1613a1e639694b0d892504.tar.zst slang-526b06922e10fcfe1d1613a1e639694b0d892504.zip |
Clean up core processing loop
-rw-r--r-- | repl.d | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -1,12 +1,13 @@ import std.stdio; import std.string; import std.variant; -import std.typecons; + +import std.container.util : make; import src.stack; -static import definition = src.definition; -static import primitives = src.primitives.eval; +import definition = src.definition; +import primitives = src.primitives.eval; Stack!Token resolve(Token token) { try { @@ -27,14 +28,9 @@ Stack!Token resolve(Token token) { } void process(string value) { - Stack!Token buffer; - Token token = toToken(value); - - if ( !definition.handle(token) ) { - buffer = resolve(token); - } + auto buffer = make!(Stack!Token)(toToken(value)); - while ( !buffer.empty ) { + do { Token current = buffer.pop; if ( !definition.handle(current) ) { @@ -49,6 +45,7 @@ void process(string value) { } } } + while ( !buffer.empty ); } void main() { |