aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2017-04-15 14:21:20 +0200
committerAdrian Kummerlaender2017-04-15 14:21:20 +0200
commitbce4d934a47023096e74ac39ed4d3a2cd99bc8e4 (patch)
tree729162d54b77b2480293dff657cb59d5ddc7dd5a
parent47611c4938363346be414b1cf00a63b438e043c4 (diff)
downloadslang-bce4d934a47023096e74ac39ed4d3a2cd99bc8e4.tar
slang-bce4d934a47023096e74ac39ed4d3a2cd99bc8e4.tar.gz
slang-bce4d934a47023096e74ac39ed4d3a2cd99bc8e4.tar.bz2
slang-bce4d934a47023096e74ac39ed4d3a2cd99bc8e4.tar.lz
slang-bce4d934a47023096e74ac39ed4d3a2cd99bc8e4.tar.xz
slang-bce4d934a47023096e74ac39ed4d3a2cd99bc8e4.tar.zst
slang-bce4d934a47023096e74ac39ed4d3a2cd99bc8e4.zip
Abstract stack prepending
-rw-r--r--source/app.d2
-rw-r--r--source/base/stack.d12
2 files changed, 9 insertions, 5 deletions
diff --git a/source/app.d b/source/app.d
index 0f17afc..35b2d88 100644
--- a/source/app.d
+++ b/source/app.d
@@ -38,7 +38,7 @@ void process(string value) {
if ( result.front == current ) {
stack.push(current);
} else {
- buffer.insertFront(result[]);
+ buffer.push(result);
}
}
}
diff --git a/source/base/stack.d b/source/base/stack.d
index e42ff12..c6e1a59 100644
--- a/source/base/stack.d
+++ b/source/base/stack.d
@@ -32,13 +32,17 @@ Token pop(ref Stack!Token stack) {
return token;
}
-void push(ref Stack!Token stack, Token token) {
- stack.insertFront(token);
-}
-
template push(T)
if ( is(T == int) || is(T == bool) || is (T == string) ) {
void push(ref Stack!Token stack, T value) {
stack.push(Token(value));
}
}
+
+void push(ref Stack!Token stack, Token token) {
+ stack.insertFront(token);
+}
+
+void push(ref Stack!Token stack, Stack!Token prefix) {
+ stack.insertFront(prefix[]);
+}