aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2017-04-14 17:40:49 +0200
committerAdrian Kummerlaender2017-04-14 17:40:49 +0200
commit526b06922e10fcfe1d1613a1e639694b0d892504 (patch)
treeb4b5300ccede02694b284629ad572f19ebdca866
parentd2126fe52fd3c002631e66fa7d6e2d5cd8862bea (diff)
downloadslang-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.d17
1 files changed, 7 insertions, 10 deletions
diff --git a/repl.d b/repl.d
index df2905d..3f2aea4 100644
--- a/repl.d
+++ b/repl.d
@@ -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() {