More binary operators

This commit is contained in:
2026-04-14 05:07:45 +02:00
parent 7b8010abbb
commit b2fa1e24e1
4 changed files with 31 additions and 2 deletions
+7
View File
@@ -18,6 +18,13 @@ pub enum BinaryOp {
Minus,
Multiply,
Divide,
Modulo,
Equal,
NotEqual,
LessThan,
GreaterThan,
LessThanOrEqual,
GreaterThanOrEqual,
}
#[derive(Debug, Clone, Serialize)]
+1 -1
View File
@@ -105,7 +105,7 @@ field_px = { "." ~ identifier }
call_px = { "(" ~ (expr ~ ("," ~ expr)*)? ~ ")" }
index_px = { "[" ~ expr ~ "]" }
binary_px = { bin_op ~ expr }
bin_op = { "+" | "-" | "*" | "/" | "%" }
bin_op = { "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | ">" | "<=" | ">=" }
expr = {
primary ~ postfix*
+8
View File
@@ -341,6 +341,14 @@ impl Postfix {
"-" => BinaryOp::Minus,
"*" => BinaryOp::Multiply,
"/" => BinaryOp::Divide,
"%" => BinaryOp::Modulo,
"==" => BinaryOp::Equal,
"!=" => BinaryOp::NotEqual,
"<" => BinaryOp::LessThan,
">" => BinaryOp::GreaterThan,
"<=" => BinaryOp::LessThanOrEqual,
">=" => BinaryOp::GreaterThanOrEqual,
_ => {
unimplemented!("Binary operator not implemented yet: {}", op_pair.as_str())
}