From b0f9a8bee0736990bdd58667be3d7deea66b399e Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 1 Jan 2020 02:52:39 +0300 Subject: parser: make ^ operator higher priority than unary - --- server/parser/operator.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'server/parser/operator.hpp') 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: -- cgit v1.2.3