From b56bb9a48c774d9c76b125b8936fb5015d8961c5 Mon Sep 17 00:00:00 2001 From: afonya2 Date: Fri, 23 May 2025 20:48:19 +0200 Subject: [PATCH] add new operators to the shunter --- src/parser.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 7ffec69..2c58140 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -96,9 +96,10 @@ fn read_call(variable: ASTPart, pos: &mut usize, input: &Vec) -> ASTPart fn operator_precedence(op: &str) -> i64 { match op { "|" | "&" => 1, - "+" | "-" => 2, - "*" | "/" | "%" => 3, - "^" => 4, + "==" | "!=" | "<=" | ">=" => 2, + "+" | "-" => 3, + "*" | "/" | "%" => 4, + "^" => 5, _ => 0 } } @@ -106,9 +107,7 @@ fn operator_precedence(op: &str) -> i64 { fn shunt(input: Vec) -> ASTPart { let mut output: Vec = vec![]; let mut stack: Vec = vec![]; - println!("Shunting input: {:?}", input); for part in input { - println!("Shunting part: {:?}", part); match &part { ASTPart::String(_) => { output.push(part); @@ -151,7 +150,6 @@ fn shunt(input: Vec) -> ASTPart { while stack.len() > 0 { output.push(stack.pop().unwrap()); } - println!("Shunting output: {:?}\n\n", output); let mut i = 0; while i < output.len() { match &output[i] {