fix range selection during bracket removal scanning
This commit is contained in:
+24
-2
@@ -539,6 +539,28 @@ static void find_top_prio_op_range(const std::vector<int>& mp, int& start, int&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// find operation ranges that are of selected priority (target_prio)
|
||||||
|
// accounting for future token convolution into compound values
|
||||||
|
static void find_select_prio_op_ranges_after_conv(const std::vector<int>& mp, std::vector<Range>& ranges, int target_prio)
|
||||||
|
{
|
||||||
|
for (int i = 0, l = mp.size(), recording_range = 0; i < l; i++)
|
||||||
|
{
|
||||||
|
if (mp[i] == target_prio && !recording_range)
|
||||||
|
{
|
||||||
|
recording_range = 1;
|
||||||
|
ranges.emplace_back(i, i);
|
||||||
|
}
|
||||||
|
else if (mp[i] == target_prio && recording_range)
|
||||||
|
{
|
||||||
|
ranges.back().finish = i;
|
||||||
|
}
|
||||||
|
else if (mp[i] < target_prio && recording_range)
|
||||||
|
{
|
||||||
|
recording_range = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void find_select_prio_op_ranges(const std::vector<int>& mp, std::vector<Range>& ranges, int target_prio)
|
static void find_select_prio_op_ranges(const std::vector<int>& mp, std::vector<Range>& ranges, int target_prio)
|
||||||
{
|
{
|
||||||
for (int i = 0, l = mp.size(), prio = 0, recording_range = 0; i < l; i++)
|
for (int i = 0, l = mp.size(), prio = 0, recording_range = 0; i < l; i++)
|
||||||
@@ -919,7 +941,7 @@ static void remove_extra_brackets(std::vector<Expression::Token>& tv)
|
|||||||
create_prios_vector(tv, mp);
|
create_prios_vector(tv, mp);
|
||||||
|
|
||||||
std::vector<Range> ranges;
|
std::vector<Range> ranges;
|
||||||
find_select_prio_op_ranges(mp, ranges, current_prio);
|
find_select_prio_op_ranges_after_conv(mp, ranges, current_prio);
|
||||||
|
|
||||||
for (int r_no = ranges.size() - 1; r_no >= 0; r_no--)
|
for (int r_no = ranges.size() - 1; r_no >= 0; r_no--)
|
||||||
{
|
{
|
||||||
@@ -927,7 +949,7 @@ static void remove_extra_brackets(std::vector<Expression::Token>& tv)
|
|||||||
create_prios_vector(tv, mp);
|
create_prios_vector(tv, mp);
|
||||||
|
|
||||||
ranges.clear();
|
ranges.clear();
|
||||||
find_select_prio_op_ranges(mp, ranges, current_prio);
|
find_select_prio_op_ranges_after_conv(mp, ranges, current_prio);
|
||||||
|
|
||||||
const Range &r = ranges[r_no];
|
const Range &r = ranges[r_no];
|
||||||
int max_child_rank = max_rank(tv, mp, r, current_prio);
|
int max_child_rank = max_rank(tv, mp, r, current_prio);
|
||||||
|
|||||||
Reference in New Issue
Block a user