From e837671d1590a7c750cace59874fd33c6a23911f Mon Sep 17 00:00:00 2001 From: hasslesstech Date: Wed, 14 Oct 2026 21:49:59 +0300 Subject: [PATCH] fix post-processing --- src/syntaxer.cpp | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/syntaxer.cpp b/src/syntaxer.cpp index 66df65b..632600e 100644 --- a/src/syntaxer.cpp +++ b/src/syntaxer.cpp @@ -1120,8 +1120,6 @@ 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]; @@ -1143,7 +1141,6 @@ static int correct_operation_priorities(std::vector& tv, int } else if (relative_level == 0) { - // same operation inner priority int target_op; switch (ip) { @@ -1155,26 +1152,13 @@ static int correct_operation_priorities(std::vector& tv, int break; } - int same_op_ip; - switch (ip) + if (rank_op(tok.v.o) == ip && target_op) { - case 0: - same_op_ip = tok.v.o == Expression::Token::ADD || tok.v.o == Expression::Token::SUB; - break; - case 1: - same_op_ip = tok.v.o == Expression::Token::MUL || tok.v.o == Expression::Token::DIV; - break; - } - - 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) + if (same_lvl_op_cnt >= 1) { same_lvl_op_cnt = 0; - corrections++; switch (ip) @@ -1201,14 +1185,9 @@ static int correct_operation_priorities(std::vector& tv, int relative_level++; } } - else + else if (rank_op(tok.v.o) < ip) { - if (rank_op(tok.v.o) < ip) - { - same_lvl_op_cnt = 0; - } - - last_op = tok.v.o; + same_lvl_op_cnt = -1; } }