aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2017-04-18 10:45:35 +0200
committerAdrian Kummerlaender2017-04-18 10:50:59 +0200
commit44a8573c4d4081552320c80bf9a2ed3eaba6c91c (patch)
tree5762e96fdd951d532546c5e65e435ef4a4603eb2
parent717da3529c617c5a8b58b99d45fcd86d8da65a7c (diff)
downloadslang-44a8573c4d4081552320c80bf9a2ed3eaba6c91c.tar
slang-44a8573c4d4081552320c80bf9a2ed3eaba6c91c.tar.gz
slang-44a8573c4d4081552320c80bf9a2ed3eaba6c91c.tar.bz2
slang-44a8573c4d4081552320c80bf9a2ed3eaba6c91c.tar.xz
slang-44a8573c4d4081552320c80bf9a2ed3eaba6c91c.zip
Rename boolean operators
-rw-r--r--README.md6
-rw-r--r--source/primitives/core.d34
2 files changed, 20 insertions, 20 deletions
diff --git a/README.md b/README.md
index b1d220d..2392094 100644
--- a/README.md
+++ b/README.md
@@ -31,9 +31,9 @@ Currently implemented primitives:
| `rot` | Rotate the top three stack elements |
| `true` | Write true boolean value to top-of-stack |
| `false` | Write false boolean value to top-of-stack |
-| `!` | Negate boolean value |
+| `not` | Negate boolean value |
+| `and` | Boolean and |
+| `or` | Boolean or |
| `<` | Compare size of two integers |
| `=` | Compare equality of two stack values |
-| `&` | Boolean and |
-| `or` | Boolean or |
| `#` | Debug word printing the whole stack to _stdout_ |
diff --git a/source/primitives/core.d b/source/primitives/core.d
index a3a24f0..e3c2eeb 100644
--- a/source/primitives/core.d
+++ b/source/primitives/core.d
@@ -29,11 +29,11 @@ bool handle(string word) {
case "rot" : ternary_op_stack_rot; break;
case "true" : nullary_op_value_bool(true); break;
case "false" : nullary_op_value_bool(false); break;
- case "!" : unary_op_negate; break;
+ case "not" : unary_op_negate; break;
+ case "and" : binary_cond_and; break;
+ case "or" : binary_cond_or; break;
case "<" : binary_cond_lt; break;
case "=" : binary_cond_eq; break;
- case "&" : binary_cond_and; break;
- case "or" : binary_cond_or; break;
case "#" : debug_print_stack; break;
default : return false;
}
@@ -126,20 +126,6 @@ void unary_op_negate() {
stack.push(Token(!a));
}
-void binary_cond_lt() {
- int b = stack.pop.get!int;
- int a = stack.pop.get!int;
-
- stack.push(a < b);
-}
-
-void binary_cond_eq() {
- auto b = stack.pop;
- auto a = stack.pop;
-
- stack.push(a == b);
-}
-
void binary_cond_and() {
bool b = stack.pop.get!bool;
bool a = stack.pop.get!bool;
@@ -154,6 +140,20 @@ void binary_cond_or() {
stack.push(Token(a || b));
}
+void binary_cond_lt() {
+ int b = stack.pop.get!int;
+ int a = stack.pop.get!int;
+
+ stack.push(a < b);
+}
+
+void binary_cond_eq() {
+ auto b = stack.pop;
+ auto a = stack.pop;
+
+ stack.push(a == b);
+}
+
void debug_print_stack() {
writeln(stack[]);
}