parse thse what sir

This commit is contained in:
LinlyBoi
2023-05-18 10:06:12 +03:00
parent 607df564b4
commit c31d5698fc

View File

@@ -91,7 +91,13 @@ impl CalcTree {
match operation { match operation {
Operation::Add => Num(a + b), Operation::Add => Num(a + b),
Operation::Sub => Num(a - b), Operation::Sub => Num(a - b),
Operation::Div => Num(a / b), Operation::Div => {
if b != 0 {
Num(a / b)
} else {
panic!("DIVISION BY 0");
}
}
Operation::Mult => Num(a * b), Operation::Mult => Num(a * b),
} }
} else { } else {
@@ -99,3 +105,6 @@ impl CalcTree {
} }
} }
} }
pub fn parse_string(expression: &str) -> Vec<Item> {
let first_split: Vec<&str> = expression.split_inclusive(['+', '-', '*', '/']).collect();
}