mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 13:44:15 +00:00
Fix associativity of addition and subtraction
This commit is contained in:
parent
7158fe81e1
commit
b4f3d02539
1 changed files with 6 additions and 6 deletions
|
@ -468,20 +468,20 @@ fn parse_suffix(mut iter: &mut Iter) -> Expr {
|
|||
}
|
||||
|
||||
fn parse_add(mut iter: &mut Iter) -> Expr {
|
||||
let left = parse_suffix(iter);
|
||||
match *iter.peek().unwrap() {
|
||||
let mut left = parse_suffix(iter);
|
||||
loop { match *iter.peek().unwrap() {
|
||||
Token::Plus => {
|
||||
iter.next();
|
||||
let right = parse_suffix(iter);
|
||||
Expr::Add(Box::new(left), Box::new(right))
|
||||
left = Expr::Add(Box::new(left), Box::new(right))
|
||||
},
|
||||
Token::Minus => {
|
||||
iter.next();
|
||||
let right = parse_suffix(iter);
|
||||
Expr::Sub(Box::new(left), Box::new(right))
|
||||
left = Expr::Sub(Box::new(left), Box::new(right))
|
||||
},
|
||||
_ => left
|
||||
}
|
||||
_ => return left
|
||||
}}
|
||||
}
|
||||
|
||||
fn parse_eq(mut iter: &mut Iter) -> Expr {
|
||||
|
|
Loading…
Reference in a new issue