Add comparison operators

Signed-off-by: CHatingPython <chatingpython@gmail.com>
This commit is contained in:
CHatingPython
2026-05-30 13:09:39 +02:00
committed by CHatingPython
parent f4efb53531
commit 737f637a38
6 changed files with 46 additions and 2 deletions
+7
View File
@@ -88,6 +88,13 @@ enum class binop_expression_node_t {
Mul,
Div,
Mod,
Equal,
NotEqual,
LessThan,
GreaterThan,
LessEqual,
GreaterEqual,
};
class binop_expression_node : public expression_node {
+19
View File
@@ -41,6 +41,13 @@ enum class token_t {
StarEq,
SlashEq,
PercentEq,
DEq,
NotEq,
LessThan,
GreaterThan,
LessEq,
GreaterEq,
};
static inline std::ostream& operator<<(std::ostream& os, token_t type) {
@@ -73,6 +80,12 @@ static inline std::ostream& operator<<(std::ostream& os, token_t type) {
case token_t::StarEq: return os << "*=";
case token_t::SlashEq: return os << "/=";
case token_t::PercentEq: return os << "%=";
case token_t::DEq: return os << "==";
case token_t::NotEq: return os << "!=";
case token_t::LessThan: return os << "<";
case token_t::GreaterThan: return os << ">";
case token_t::LessEq: return os << "<=";
case token_t::GreaterEq: return os << ">=";
}
return os;
}
@@ -107,6 +120,12 @@ static inline std::string operator+(const std::string& str, token_t type) {
case token_t::StarEq: return str + "*=";
case token_t::SlashEq: return str + "/=";
case token_t::PercentEq: return str + "%=";
case token_t::DEq: return str + "==";
case token_t::NotEq: return str + "!=";
case token_t::LessThan: return str + "<";
case token_t::GreaterThan: return str + ">";
case token_t::LessEq: return str + "<=";
case token_t::GreaterEq: return str + ">=";
}
return str;
}