diff --git a/src/syntaxer.cpp b/src/syntaxer.cpp index 61c93e3..66df65b 100644 --- a/src/syntaxer.cpp +++ b/src/syntaxer.cpp @@ -1120,6 +1120,8 @@ static int correct_operation_priorities(std::vector& tv, int { int corrections = 0; + Expression::Token::Operator last_op = Expression::Token::ADD; + for (int i = 0, same_lvl_op_cnt = -1, relative_level = -op; i < tv.size(); i++) { Expression::Token& tok = tv[i]; @@ -1164,8 +1166,9 @@ static int correct_operation_priorities(std::vector& tv, int break; } - if (same_op_ip) + if (same_op_ip && tok.v.o == last_op) { + last_op = tok.v.o; same_lvl_op_cnt++; if (same_lvl_op_cnt >= 1 && target_op) @@ -1198,6 +1201,16 @@ static int correct_operation_priorities(std::vector& tv, int relative_level++; } } + else + { + if (rank_op(tok.v.o) < ip) + { + same_lvl_op_cnt = 0; + } + + last_op = tok.v.o; + } + } } }