fix: fix some shunting-yard realisation issues
This commit is contained in:
+2
-2
@@ -20,14 +20,14 @@ pub fn to_rpn(tokens: Vec<Token>) -> Vec<Token> {
|
||||
Token::Number(_) => out_buf.push(t),
|
||||
Token::BracketOpen => act_buf.push(t),
|
||||
Token::BracketClose => {
|
||||
while matches!(act_buf.last().unwrap(), Token::BracketOpen) {
|
||||
while !matches!(act_buf.last().unwrap(), Token::BracketOpen) {
|
||||
out_buf.push(act_buf.pop().unwrap());
|
||||
}
|
||||
act_buf.pop();
|
||||
}
|
||||
_ => {
|
||||
if !act_buf.is_empty() {
|
||||
while priority.get(&t).unwrap() < priority.get(act_buf.last().unwrap()).unwrap() {
|
||||
while priority.get(&t).unwrap() <= priority.get(act_buf.last().unwrap()).unwrap() {
|
||||
out_buf.push(act_buf.pop().unwrap());
|
||||
if act_buf.is_empty() { break; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user