Skip to content

Commit

Permalink
Swap precedence of negation and factorial (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
SandaruKasa authored Jun 16, 2023
1 parent a4c93a7 commit 5ce7b43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions derive/examples/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ fn main() {
.op(Op::infix(Rule::add, Left) | Op::infix(Rule::sub, Left))
.op(Op::infix(Rule::mul, Left) | Op::infix(Rule::div, Left))
.op(Op::infix(Rule::pow, Right))
.op(Op::postfix(Rule::fac))
.op(Op::prefix(Rule::neg));
.op(Op::prefix(Rule::neg))
.op(Op::postfix(Rule::fac));

let stdin = stdin();
let mut stdout = stdout();
Expand Down
4 changes: 2 additions & 2 deletions pest/src/pratt_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ impl<R: RuleType> BitOr for Op<R> {
/// .op(Op::infix(Rule::add, Assoc::Left) | Op::infix(Rule::sub, Assoc::Left))
/// .op(Op::infix(Rule::mul, Assoc::Left) | Op::infix(Rule::div, Assoc::Left))
/// .op(Op::infix(Rule::pow, Assoc::Right))
/// .op(Op::postfix(Rule::fac))
/// .op(Op::prefix(Rule::neg));
/// .op(Op::prefix(Rule::neg))
/// .op(Op::postfix(Rule::fac));
/// ```
///
/// To parse an expression, call the [`map_primary`], [`map_prefix`], [`map_postfix`],
Expand Down

0 comments on commit 5ce7b43

Please sign in to comment.