fix binop precedence
This commit is contained in:
parent
3e772d74c1
commit
a039303d8c
1 changed files with 11 additions and 11 deletions
|
|
@ -215,38 +215,38 @@ where
|
|||
|
||||
// %
|
||||
atom.pratt((
|
||||
infix(none(10), just(Token::BinOp("=")), |l, _, r, _| {
|
||||
infix(none(1), just(Token::BinOp("=")), |l, _, r, _| {
|
||||
Ast::BinOp(Box::new(l), BinOp::Eq, Box::new(r))
|
||||
}),
|
||||
infix(none(10), just(Token::BinOp("<")), |l, _, r, _| {
|
||||
infix(none(1), just(Token::BinOp("<")), |l, _, r, _| {
|
||||
Ast::BinOp(Box::new(l), BinOp::Lt, Box::new(r))
|
||||
}),
|
||||
infix(none(10), just(Token::BinOp("<=")), |l, _, r, _| {
|
||||
infix(none(1), just(Token::BinOp("<=")), |l, _, r, _| {
|
||||
Ast::BinOp(Box::new(l), BinOp::Le, Box::new(r))
|
||||
}),
|
||||
// note that these two are flipped
|
||||
infix(none(10), just(Token::BinOp(">")), |l, _, r, _| {
|
||||
infix(none(1), just(Token::BinOp(">")), |l, _, r, _| {
|
||||
Ast::BinOp(Box::new(r), BinOp::Lt, Box::new(l))
|
||||
}),
|
||||
infix(none(10), just(Token::BinOp(">=")), |l, _, r, _| {
|
||||
infix(none(1), just(Token::BinOp(">=")), |l, _, r, _| {
|
||||
Ast::BinOp(Box::new(r), BinOp::Le, Box::new(l))
|
||||
}),
|
||||
infix(right(3), just(Token::BinOp("%")), |l, _, r, _| {
|
||||
infix(right(2), just(Token::BinOp("%")), |l, _, r, _| {
|
||||
Ast::BinOp(Box::new(l), BinOp::Mod, Box::new(r))
|
||||
}),
|
||||
infix(right(3), just(Token::BinOp("**")), |l, _, r, _| {
|
||||
infix(right(5), just(Token::BinOp("**")), |l, _, r, _| {
|
||||
Ast::BinOp(Box::new(l), BinOp::Pow, Box::new(r))
|
||||
}),
|
||||
infix(left(2), just(Token::BinOp("*")), |l, _, r, _| {
|
||||
infix(left(4), just(Token::BinOp("*")), |l, _, r, _| {
|
||||
Ast::BinOp(Box::new(l), BinOp::Mul, Box::new(r))
|
||||
}),
|
||||
infix(right(2), just(Token::BinOp("/")), |l, _, r, _| {
|
||||
infix(right(4), just(Token::BinOp("/")), |l, _, r, _| {
|
||||
Ast::BinOp(Box::new(l), BinOp::Div, Box::new(r))
|
||||
}),
|
||||
infix(left(1), just(Token::BinOp("+")), |l, _, r, _| {
|
||||
infix(left(3), just(Token::BinOp("+")), |l, _, r, _| {
|
||||
Ast::BinOp(Box::new(l), BinOp::Add, Box::new(r))
|
||||
}),
|
||||
infix(left(1), just(Token::BinOp("-")), |l, _, r, _| {
|
||||
infix(left(3), just(Token::BinOp("-")), |l, _, r, _| {
|
||||
Ast::BinOp(Box::new(l), BinOp::Sub, Box::new(r))
|
||||
}),
|
||||
))
|
||||
|
|
|
|||
Loading…
Reference in a new issue