diff --git a/src/parser.rs b/src/parser.rs index 7d05cec..7ffec69 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -106,7 +106,9 @@ 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); @@ -126,7 +128,7 @@ fn shunt(input: Vec) -> ASTPart { ASTPart::Operation(op) => { if *op.left != ASTPart::NOOP && *op.right != ASTPart::NOOP { output.push(part); - break; + continue; } while stack.len() > 0 { let top = &stack[stack.len()-1]; @@ -149,6 +151,7 @@ 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] { diff --git a/test.as b/test.as index cde513a..7cdb8df 100644 --- a/test.as +++ b/test.as @@ -1,4 +1,4 @@ gethelj a = 1 -gethelj b = a + 2 +gethelj b = (a + 2) * 3 ugass(a,b) gethelj c = piszv & nem piszv \ No newline at end of file