From c91e935c62b8e254b9daadf37b915c983518bff4 Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Fri, 18 Apr 2025 16:25:35 +0000
Subject: [PATCH] add dynamic module load, more escape seq
---
src/Interpreter/BinaryExpressionNode.hpp | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/src/Interpreter/BinaryExpressionNode.hpp b/src/Interpreter/BinaryExpressionNode.hpp
index f741d3f..3281aab 100644
--- a/src/Interpreter/BinaryExpressionNode.hpp
+++ b/src/Interpreter/BinaryExpressionNode.hpp
@@ -23,6 +23,26 @@
"Unsupported types in binary expression: " + Symbols::Variables::TypeToString(leftVal.getType()) +
" and " + Symbols::Variables::TypeToString(rightVal.getType()) + " " + toString());
}
+ if (leftVal.getType() == Symbols::Variables::Type::BOOLEAN &&
+ rightVal.getType() == Symbols::Variables::Type::BOOLEAN) {
+ bool l = leftVal.get<bool>();
+ bool r = rightVal.get<bool>();
+
+ if (op_ == "&&") {
+ return Symbols::Value(l && r);
+ }
+ if (op_ == "||") {
+ return Symbols::Value(l || r);
+ }
+ if (op_ == "==") {
+ return Symbols::Value(l == r);
+ }
+ if (op_ == "!=") {
+ return Symbols::Value(l != r);
+ }
+
+ throw std::runtime_error("Unknown operator: " + op_);
+ }
if (leftVal.getType() == Symbols::Variables::Type::INTEGER &&
rightVal.getType() == Symbols::Variables::Type::INTEGER) {
@@ -41,6 +61,27 @@
if (op_ == "/") {
return Symbols::Value(l / r); // TODO: 0 div
}
+ if (op_ == "%") {
+ return Symbols::Value(l % r);
+ }
+ if (op_ == "==") {
+ return Symbols::Value(l == r);
+ }
+ if (op_ == "!=") {
+ return Symbols::Value(l != r);
+ }
+ if (op_ == "<") {
+ return Symbols::Value(l < r);
+ }
+ if (op_ == ">") {
+ return Symbols::Value(l > r);
+ }
+ if (op_ == "<=") {
+ return Symbols::Value(l <= r);
+ }
+ if (op_ == ">=") {
+ return Symbols::Value(l >= r);
+ }
throw std::runtime_error("Unknown operator: " + op_);
}
--
Gitblit v1.9.3