aboutsummaryrefslogtreecommitdiff
path: root/source/primitives
diff options
context:
space:
mode:
authorAdrian Kummerlaender2017-04-15 14:02:50 +0200
committerAdrian Kummerlaender2017-04-15 14:02:50 +0200
commit47611c4938363346be414b1cf00a63b438e043c4 (patch)
treea08a727821c074d513a95e192ad3b43fcdfa4405 /source/primitives
parent5ca4d7acb5545050a731b0adc2e39b3ed65b7fc9 (diff)
downloadslang-47611c4938363346be414b1cf00a63b438e043c4.tar
slang-47611c4938363346be414b1cf00a63b438e043c4.tar.gz
slang-47611c4938363346be414b1cf00a63b438e043c4.tar.bz2
slang-47611c4938363346be414b1cf00a63b438e043c4.tar.lz
slang-47611c4938363346be414b1cf00a63b438e043c4.tar.xz
slang-47611c4938363346be414b1cf00a63b438e043c4.tar.zst
slang-47611c4938363346be414b1cf00a63b438e043c4.zip
Perform custom word definition at the same level as conditional primitives
Diffstat (limited to 'source/primitives')
-rw-r--r--source/primitives/conditional.d2
-rw-r--r--source/primitives/eval.d20
2 files changed, 14 insertions, 8 deletions
diff --git a/source/primitives/conditional.d b/source/primitives/conditional.d
index 08c0f52..e5ba591 100644
--- a/source/primitives/conditional.d
+++ b/source/primitives/conditional.d
@@ -16,7 +16,7 @@ void capture(Token token) {
}
}
-bool drop(Token token) {
+bool handle(Token token) {
if ( concluded && buffer.isNull ) {
return false;
}
diff --git a/source/primitives/eval.d b/source/primitives/eval.d
index 0ddd65a..0cb45b7 100644
--- a/source/primitives/eval.d
+++ b/source/primitives/eval.d
@@ -4,6 +4,8 @@ import std.variant;
import base.stack;
import primitives.core;
+
+import definition = base.definition;
import conditional = primitives.conditional;
bool evaluate_primitive(string word) {
@@ -33,15 +35,19 @@ bool evaluate_primitive(string word) {
}
bool evaluate(Token token) {
- if ( conditional.drop(token) ) {
+ if ( definition.handle(token) ) {
+ return true;
+ }
+
+ if ( conditional.handle(token) ) {
return true;
- } else {
- return token.visit!(
- (int value) => false,
- (bool value) => false,
- (string word ) => evaluate_primitive(word)
- );
}
+
+ return token.visit!(
+ (int value) => false,
+ (bool value) => false,
+ (string word ) => evaluate_primitive(word)
+ );
}
Stack!Token result() {