From 034f81dcc63bcf85314604525f0978c2e9f82d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=B6=E5=A1=9A=E5=A4=AA=E6=99=BA?= Date: Fri, 26 Jul 2024 22:53:51 +0900 Subject: [PATCH] Enhance operator --- src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.rs b/src/main.rs index faa6c3a..008e5e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -157,10 +157,22 @@ fn parse_expr(source: String) -> Expr { expr.push(Expr::Operator(Operator::Mod)) } else if token == "==" { expr.push(Expr::Operator(Operator::Equal)) + } else if token == "!=" { + expr.push(Expr::Operator(Operator::NotEq)) } else if token == ">" { expr.push(Expr::Operator(Operator::Greater)) } else if token == "<" { expr.push(Expr::Operator(Operator::Less)) + } else if token == ">=" { + expr.push(Expr::Operator(Operator::GreaterEq)) + } else if token == "<=" { + expr.push(Expr::Operator(Operator::LessEq)) + } else if token == "&& " { + expr.push(Expr::Operator(Operator::And)) + } else if token == "||" { + expr.push(Expr::Operator(Operator::Or)) + } else if token == "!" { + expr.push(Expr::Operator(Operator::Not)) } else { expr.push(Expr::Literal(Type::Symbol(token))) }