fix: parenthesis
This commit is contained in:
parent
b074f18648
commit
b4886eff87
2 changed files with 5 additions and 2 deletions
|
@ -106,7 +106,9 @@ fn operator_precedence(op: &str) -> i64 {
|
|||
fn shunt(input: Vec<ASTPart>) -> ASTPart {
|
||||
let mut output: Vec<ASTPart> = vec![];
|
||||
let mut stack: Vec<ASTPart> = 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 {
|
|||
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>) -> 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] {
|
||||
|
|
2
test.as
2
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
|
Loading…
Add table
Add a link
Reference in a new issue