From 0b4129fb98b336d202a87b879768f7f4894101bf Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 13 Oct 2020 09:33:16 +0800 Subject: [PATCH] Raise precedence of ~ and %. --- doc/src/engine/custom-op.md | 3 ++- src/token.rs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/src/engine/custom-op.md b/doc/src/engine/custom-op.md index 79f70d7c..2e98ecc1 100644 --- a/doc/src/engine/custom-op.md +++ b/doc/src/engine/custom-op.md @@ -95,7 +95,8 @@ The following _precedence table_ show the built-in precedence of standard Rhai o | Comparisons | `>`, `>=`, `<`, `<=` | 110 | | | `in` | 130 | | Arithmetic | `+`, `-` | 150 | -| Arithmetic | `*`, `/`, `~`, `%` | 180 | +| Arithmetic | `*`, `/` | 180 | +| Arithmetic | `~`, `%` | 190 | | Bit-shifts | `<<`, `>>` | 210 | | Object | `.` _(binds to right)_ | 240 | | _Others_ | | 0 | diff --git a/src/token.rs b/src/token.rs index 181524cc..fde6a703 100644 --- a/src/token.rs +++ b/src/token.rs @@ -623,7 +623,9 @@ impl Token { Plus | Minus => 150, - Divide | Multiply | PowerOf | Modulo => 180, + Divide | Multiply => 180, + + PowerOf | Modulo => 190, LeftShift | RightShift => 210,