summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-04-28 22:54:55 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-04-28 22:54:55 +0200
commitb6e97c70ae13fff134c0b26a21fef25e7f441ca8 (patch)
tree5725d427b995479772c7de3dd183c7fa64eea5c1
parent74ed467e20f75f9301c1008015fc8c8c8e8571f3 (diff)
downloadrebel-b6e97c70ae13fff134c0b26a21fef25e7f441ca8.tar
rebel-b6e97c70ae13fff134c0b26a21fef25e7f441ca8.zip
rebel-lang: add support str comparision
-rw-r--r--crates/rebel-lang/src/typing.rs4
-rw-r--r--crates/rebel-lang/src/value.rs4
2 files changed, 8 insertions, 0 deletions
diff --git a/crates/rebel-lang/src/typing.rs b/crates/rebel-lang/src/typing.rs
index 7472968..ebb3116 100644
--- a/crates/rebel-lang/src/typing.rs
+++ b/crates/rebel-lang/src/typing.rs
@@ -153,6 +153,10 @@ impl Type {
(Int, Le, Int) => Bool,
(Int, Ge, Int) => Bool,
(Int, Gt, Int) => Bool,
+ (Str, Lt, Str) => Bool,
+ (Str, Le, Str) => Bool,
+ (Str, Ge, Str) => Bool,
+ (Str, Gt, Str) => Bool,
_ => return Err(TypeError),
})
}
diff --git a/crates/rebel-lang/src/value.rs b/crates/rebel-lang/src/value.rs
index 1eafc97..112f689 100644
--- a/crates/rebel-lang/src/value.rs
+++ b/crates/rebel-lang/src/value.rs
@@ -116,6 +116,10 @@ impl Value {
(Int(i1), Le, Int(i2)) => Bool(i1 <= i2),
(Int(i1), Ge, Int(i2)) => Bool(i1 >= i2),
(Int(i1), Gt, Int(i2)) => Bool(i1 > i2),
+ (Str(i1), Lt, Str(i2)) => Bool(i1 < i2),
+ (Str(i1), Le, Str(i2)) => Bool(i1 <= i2),
+ (Str(i1), Ge, Str(i2)) => Bool(i1 >= i2),
+ (Str(i1), Gt, Str(i2)) => Bool(i1 > i2),
_ => return Err(EvalError),
})
}