fixed the "!" operation
This commit is contained in:
parent
0c60e98d9f
commit
e9d1f9bbd6
3 changed files with 34 additions and 18 deletions
|
@ -228,20 +228,35 @@ fn shunt(input: Vec<ASTPart>) -> ASTPart {
|
|||
i += 1;
|
||||
continue;
|
||||
}
|
||||
if i < 2 {
|
||||
panic!("Unexpected operation at {}", op.pos);
|
||||
if op.operator == "!" {
|
||||
println!("{:?}", output);
|
||||
if i < 1 {
|
||||
panic!("Unexpected operation at {}", op.pos);
|
||||
}
|
||||
let left = output[i-1].clone();
|
||||
output[i] = ASTPart::Operation(AstOperation {
|
||||
operator: op.operator.clone(),
|
||||
left: Box::new(left),
|
||||
right: Box::new(ASTPart::NOOP),
|
||||
pos: op.pos,
|
||||
});
|
||||
output.remove(i-1);
|
||||
} else {
|
||||
if i < 2 {
|
||||
panic!("Unexpected operation at {}", op.pos);
|
||||
}
|
||||
let left = output[i-2].clone();
|
||||
let right = output[i-1].clone();
|
||||
output[i] = ASTPart::Operation(AstOperation {
|
||||
operator: op.operator.clone(),
|
||||
left: Box::new(left),
|
||||
right: Box::new(right),
|
||||
pos: op.pos,
|
||||
});
|
||||
output.remove(i-2);
|
||||
output.remove(i-2);
|
||||
i -= 1;
|
||||
}
|
||||
let left = output[i-2].clone();
|
||||
let right = output[i-1].clone();
|
||||
output[i] = ASTPart::Operation(AstOperation {
|
||||
operator: op.operator.clone(),
|
||||
left: Box::new(left),
|
||||
right: Box::new(right),
|
||||
pos: op.pos,
|
||||
});
|
||||
output.remove(i-2);
|
||||
output.remove(i-2);
|
||||
i -= 1;
|
||||
}
|
||||
_ => {
|
||||
i += 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue