fix post-processing
This commit is contained in:
+4
-25
@@ -1120,8 +1120,6 @@ 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];
|
||||
@@ -1143,7 +1141,6 @@ static int correct_operation_priorities(std::vector<Expression::Token>& 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<Expression::Token>& 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<Expression::Token>& 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user