failed attempt to hotfix wrong post-processing bracket adding algorithm
This commit is contained in:
+14
-1
@@ -1120,6 +1120,8 @@ static int correct_operation_priorities(std::vector<Expression::Token>& 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<Expression::Token>& 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<Expression::Token>& tv, int
|
||||
relative_level++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rank_op(tok.v.o) < ip)
|
||||
{
|
||||
same_lvl_op_cnt = 0;
|
||||
}
|
||||
|
||||
last_op = tok.v.o;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user