diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-01-01 02:52:39 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-01-01 03:20:14 +0300 |
commit | b0f9a8bee0736990bdd58667be3d7deea66b399e (patch) | |
tree | 8771be0c9331383aab2c52c146d69cff4e00eec3 /server/parser/operator.hpp | |
parent | parser: support unary + (diff) | |
download | math-server-b0f9a8bee0736990bdd58667be3d7deea66b399e.tar.gz math-server-b0f9a8bee0736990bdd58667be3d7deea66b399e.zip |
parser: make ^ operator higher priority than unary -
Diffstat (limited to 'server/parser/operator.hpp')
-rw-r--r-- | server/parser/operator.hpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/server/parser/operator.hpp b/server/parser/operator.hpp index 86b9eb1..fd45aa2 100644 --- a/server/parser/operator.hpp +++ b/server/parser/operator.hpp @@ -42,8 +42,8 @@ public: static constexpr unsigned min_precedence() { return 0; } - unsigned get_precedence() const { - switch (m_type) { + static unsigned get_precedence(Type type) { + switch (type) { case Type::PLUS: case Type::MINUS: return min_precedence(); @@ -53,13 +53,15 @@ public: return min_precedence() + 1; case Type::CARET: - return min_precedence() + 2; + return min_precedence() + 3; default: throw ParserError{"internal: undefined operator precedence"}; } } + unsigned get_precedence() const { return get_precedence(m_type); } + bool is_right_associative() const { switch (m_type) { case Type::CARET: |