|
|
|
@@ -5,9 +5,12 @@
|
|
|
|
|
#include <queue>
|
|
|
|
|
#include <stack>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
|
|
namespace Syntax {
|
|
|
|
|
|
|
|
|
|
static int add_bracket_to(std::vector<Expression::Token>& tv, const int location, const int direction);
|
|
|
|
|
|
|
|
|
|
static void highlight_issue(const std::vector<Expression::Token>& tv, const int location)
|
|
|
|
|
{
|
|
|
|
|
int start = location - 7 < 0 ? 0 : location - 7;
|
|
|
|
@@ -30,7 +33,62 @@ static void highlight_issue(const std::vector<Expression::Token>& tv, const int
|
|
|
|
|
std::cout << "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int check_syntax(std::vector<Expression::Token>& tv)
|
|
|
|
|
void pre_process(std::vector<Expression::Token>& tv)
|
|
|
|
|
{
|
|
|
|
|
pr_debug("Pre-process: remove empty brackets");
|
|
|
|
|
for (int i = 0; i < tv.size() - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
if (tv[i].t == Expression::Token::OPERATOR
|
|
|
|
|
&& tv[i].v.o == Expression::Token::OPA
|
|
|
|
|
&& tv[i+1].t == Expression::Token::OPERATOR
|
|
|
|
|
&& tv[i+1].v.o == Expression::Token::CPA)
|
|
|
|
|
{
|
|
|
|
|
std::vector<int> highlight;
|
|
|
|
|
highlight.emplace_back(i);
|
|
|
|
|
highlight.emplace_back(i+1);
|
|
|
|
|
Parser::print_math_vector(tv, highlight);
|
|
|
|
|
|
|
|
|
|
tv.erase(tv.begin() + i, tv.begin() + i + 2);
|
|
|
|
|
i--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pr_debug("Pre-process: unary minus");
|
|
|
|
|
int change = 1;
|
|
|
|
|
while (change)
|
|
|
|
|
{
|
|
|
|
|
change = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < tv.size() - 2; i++)
|
|
|
|
|
{
|
|
|
|
|
if (tv[i].t == Expression::Token::OPERATOR
|
|
|
|
|
&& tv[i].v.o != Expression::Token::CPA
|
|
|
|
|
&& tv[i+1].t == Expression::Token::OPERATOR
|
|
|
|
|
&& tv[i+1].v.o == Expression::Token::SUB
|
|
|
|
|
&& (tv[i+2].t == Expression::Token::CONST
|
|
|
|
|
|| tv[i+2].t == Expression::Token::VAR
|
|
|
|
|
|| (tv[i+2].t == Expression::Token::OPERATOR
|
|
|
|
|
&& tv[i+2].v.o == Expression::Token::OPA)))
|
|
|
|
|
{
|
|
|
|
|
std::vector<int> highlight;
|
|
|
|
|
|
|
|
|
|
tv.insert(tv.begin() + i + 1, Expression::Token(0.0));
|
|
|
|
|
tv.insert(tv.begin() + i + 1, Expression::Token(Expression::Token::OPA));
|
|
|
|
|
highlight.emplace_back(add_bracket_to(tv, i + 3, 1));
|
|
|
|
|
|
|
|
|
|
highlight.emplace(highlight.begin(), i+2);
|
|
|
|
|
highlight.emplace(highlight.begin(), i+1);
|
|
|
|
|
Parser::print_math_vector(tv, highlight);
|
|
|
|
|
|
|
|
|
|
i += 4;
|
|
|
|
|
|
|
|
|
|
change++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int check_syntax(const std::vector<Expression::Token>& tv)
|
|
|
|
|
{
|
|
|
|
|
int problem_cnt = 0;
|
|
|
|
|
|
|
|
|
@@ -382,7 +440,7 @@ static int get_max_index(const std::vector<int>& v)
|
|
|
|
|
|
|
|
|
|
static void write_operation(
|
|
|
|
|
std::vector<Expression::Operation>& ov,
|
|
|
|
|
const std::vector<Expression::Token>& tv,
|
|
|
|
|
std::vector<Expression::Token>& cv,
|
|
|
|
|
std::vector<Expression::Token>& mv,
|
|
|
|
|
std::vector<int>& mp,
|
|
|
|
|
int position)
|
|
|
|
@@ -391,36 +449,83 @@ static void write_operation(
|
|
|
|
|
int left_location = get_left_location(mv, location);
|
|
|
|
|
int right_location = get_right_location(mv, location);
|
|
|
|
|
|
|
|
|
|
std::vector<int> hl;
|
|
|
|
|
hl.emplace_back(left_location);
|
|
|
|
|
hl.emplace_back(location);
|
|
|
|
|
hl.emplace_back(right_location);
|
|
|
|
|
Parser::print_math_vector(mv, hl);
|
|
|
|
|
|
|
|
|
|
Expression::Token &o = mv[location],
|
|
|
|
|
&l = mv[left_location],
|
|
|
|
|
&r = mv[right_location];
|
|
|
|
|
|
|
|
|
|
int this_op_weight = get_operator_weight(mv, location) + 1;
|
|
|
|
|
#if LAB2_EXCLUDE_COMPTIME_OP_WRITES == 1
|
|
|
|
|
if (l.t == Expression::Token::CONST && r.t == Expression::Token::CONST)
|
|
|
|
|
{
|
|
|
|
|
pr_debug("CONST folding");
|
|
|
|
|
|
|
|
|
|
int il = l.t == Expression::Token::CV ? l.v.cv.i : left_location;
|
|
|
|
|
int ir = r.t == Expression::Token::CV ? r.v.cv.i : right_location;
|
|
|
|
|
switch (o.v.o)
|
|
|
|
|
{
|
|
|
|
|
case Expression::Token::ADD:
|
|
|
|
|
o.v.d = l.v.d + r.v.d;
|
|
|
|
|
break;
|
|
|
|
|
case Expression::Token::SUB:
|
|
|
|
|
o.v.d = l.v.d - r.v.d;
|
|
|
|
|
break;
|
|
|
|
|
case Expression::Token::MUL:
|
|
|
|
|
o.v.d = l.v.d * r.v.d;
|
|
|
|
|
break;
|
|
|
|
|
case Expression::Token::DIV:
|
|
|
|
|
o.v.d = l.v.d / r.v.d;
|
|
|
|
|
break;
|
|
|
|
|
case Expression::Token::POW:
|
|
|
|
|
o.v.d = std::pow(l.v.d, r.v.d);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
pr_warn("Impossible operator, this is a bug!");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// write new operation
|
|
|
|
|
int this_ov_index = ov.size();
|
|
|
|
|
ov.emplace_back(o.v.o,
|
|
|
|
|
l.t == Expression::Token::CV ? Expression::Operation::DERIVED : Expression::Operation::NORMAL,
|
|
|
|
|
il,
|
|
|
|
|
r.t == Expression::Token::CV ? Expression::Operation::DERIVED : Expression::Operation::NORMAL,
|
|
|
|
|
ir,
|
|
|
|
|
this_op_weight);
|
|
|
|
|
l.t = Expression::Token::NAT;
|
|
|
|
|
r.t = Expression::Token::NAT;
|
|
|
|
|
o.t = Expression::Token::CONST;
|
|
|
|
|
|
|
|
|
|
// update mv
|
|
|
|
|
l.t = Expression::Token::NAT;
|
|
|
|
|
r.t = Expression::Token::NAT;
|
|
|
|
|
o.t = Expression::Token::CV;
|
|
|
|
|
o.v.cv.w = this_op_weight;
|
|
|
|
|
o.v.cv.i = this_ov_index;
|
|
|
|
|
// sync &cv operator
|
|
|
|
|
cv[location].t = Expression::Token::CONST;
|
|
|
|
|
cv[location].v.d = o.v.d;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
int this_op_weight = get_operator_weight(mv, location) + 1;
|
|
|
|
|
|
|
|
|
|
int il = l.t == Expression::Token::CV ? l.v.cv.i : left_location;
|
|
|
|
|
int ir = r.t == Expression::Token::CV ? r.v.cv.i : right_location;
|
|
|
|
|
|
|
|
|
|
// write new operation
|
|
|
|
|
int this_ov_index = ov.size();
|
|
|
|
|
ov.emplace_back(o.v.o,
|
|
|
|
|
l.t == Expression::Token::CV ? Expression::Operation::DERIVED : Expression::Operation::NORMAL,
|
|
|
|
|
il,
|
|
|
|
|
r.t == Expression::Token::CV ? Expression::Operation::DERIVED : Expression::Operation::NORMAL,
|
|
|
|
|
ir,
|
|
|
|
|
this_op_weight);
|
|
|
|
|
|
|
|
|
|
// update mv
|
|
|
|
|
l.t = Expression::Token::NAT;
|
|
|
|
|
r.t = Expression::Token::NAT;
|
|
|
|
|
o.t = Expression::Token::CV;
|
|
|
|
|
o.v.cv.w = this_op_weight;
|
|
|
|
|
o.v.cv.i = this_ov_index;
|
|
|
|
|
#if LAB2_EXCLUDE_COMPTIME_OP_WRITES == 1
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// update mp
|
|
|
|
|
mp.erase(mp.begin() + position, mp.begin() + position + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void add_bracket_to(std::vector<Expression::Token>& tv, const int location, const int direction)
|
|
|
|
|
static int add_bracket_to(std::vector<Expression::Token>& tv, const int location, const int direction)
|
|
|
|
|
{
|
|
|
|
|
int i = location + direction, l = tv.size(), lv = 0;
|
|
|
|
|
|
|
|
|
@@ -430,26 +535,26 @@ static void add_bracket_to(std::vector<Expression::Token>& tv, const int locatio
|
|
|
|
|
{
|
|
|
|
|
if (tv[i].t == Expression::Token::OPERATOR)
|
|
|
|
|
{
|
|
|
|
|
switch (tv[i].v.o)
|
|
|
|
|
if (tv[i].v.o == Expression::Token::CPA)
|
|
|
|
|
{
|
|
|
|
|
case Expression::Token::OPA:
|
|
|
|
|
lv--;
|
|
|
|
|
break;
|
|
|
|
|
case Expression::Token::CPA:
|
|
|
|
|
lv++;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (!lv)
|
|
|
|
|
{
|
|
|
|
|
tv.insert(tv.begin() + i + 1, Expression::Token(Expression::Token::OPA));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!lv)
|
|
|
|
|
{
|
|
|
|
|
tv.insert(tv.begin() + i + 1, Expression::Token(Expression::Token::OPA));
|
|
|
|
|
return i + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tv[i].v.o == Expression::Token::OPA)
|
|
|
|
|
{
|
|
|
|
|
lv--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tv.insert(tv.begin(), Expression::Token(Expression::Token::OPA));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if (direction == 1)
|
|
|
|
|
{
|
|
|
|
@@ -457,26 +562,31 @@ static void add_bracket_to(std::vector<Expression::Token>& tv, const int locatio
|
|
|
|
|
{
|
|
|
|
|
if (tv[i].t == Expression::Token::OPERATOR)
|
|
|
|
|
{
|
|
|
|
|
switch (tv[i].v.o)
|
|
|
|
|
if (tv[i].v.o == Expression::Token::OPA)
|
|
|
|
|
{
|
|
|
|
|
case Expression::Token::OPA:
|
|
|
|
|
lv++;
|
|
|
|
|
break;
|
|
|
|
|
case Expression::Token::CPA:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!lv)
|
|
|
|
|
{
|
|
|
|
|
tv.insert(tv.begin() + i, Expression::Token(Expression::Token::CPA));
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tv[i].v.o == Expression::Token::CPA)
|
|
|
|
|
{
|
|
|
|
|
lv--;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (!lv)
|
|
|
|
|
{
|
|
|
|
|
tv.insert(tv.begin() + i, Expression::Token(Expression::Token::CPA));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tv.emplace_back(Expression::Token::CPA);
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pr_warn("Invalid direction given, this is a big bug!");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -634,9 +744,9 @@ static void weight_operators(std::vector<int>& operator_weights, const std::vect
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void apply_corrections(std::vector<Expression::Token>& tv)
|
|
|
|
|
void post_process(std::vector<Expression::Token>& tv)
|
|
|
|
|
{
|
|
|
|
|
pr_debug("Starting with vector:");
|
|
|
|
|
pr_debug("Post processing:");
|
|
|
|
|
Parser::print_math_vector(tv);
|
|
|
|
|
|
|
|
|
|
// global prio evaluation
|
|
|
|
@@ -650,68 +760,69 @@ void apply_corrections(std::vector<Expression::Token>& tv)
|
|
|
|
|
|
|
|
|
|
for (int current_prio_level = mp[get_max_index(mp)]; current_prio_level >= 0; current_prio_level--)
|
|
|
|
|
{
|
|
|
|
|
// calculate how many ranges need to be processed at this level
|
|
|
|
|
std::vector<Range> rv;
|
|
|
|
|
find_select_prio_op_ranges(mp, rv, current_prio_level);
|
|
|
|
|
int corrections = 1;
|
|
|
|
|
int relative_level = -current_prio_level;
|
|
|
|
|
|
|
|
|
|
for (int current_range = rv.size() - 1; current_range >= 0; current_range--)
|
|
|
|
|
while (corrections)
|
|
|
|
|
{
|
|
|
|
|
Range &outer_range = rv[current_range];
|
|
|
|
|
corrections = 0;
|
|
|
|
|
|
|
|
|
|
std::vector<int> inner_prios;
|
|
|
|
|
rank_inner_ops_raw(inner_prios, tv, outer_range.start, outer_range.finish);
|
|
|
|
|
|
|
|
|
|
for (int inner_prio = inner_prios[get_max_index(inner_prios)]; inner_prio >= 0; inner_prio--)
|
|
|
|
|
int same_op_cnt = -1;
|
|
|
|
|
for (int i = 0; i < tv.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
std::vector<Range> inner_ranges;
|
|
|
|
|
find_select_prio_op_ranges(inner_prios, inner_ranges, inner_prio);
|
|
|
|
|
Expression::Token& tok = tv[i];
|
|
|
|
|
|
|
|
|
|
for (int inner_range = inner_ranges.size() - 1; inner_range >= 0; inner_range--)
|
|
|
|
|
if (tok.t == Expression::Token::OPERATOR)
|
|
|
|
|
{
|
|
|
|
|
int corrections = 1;
|
|
|
|
|
|
|
|
|
|
Range &range = inner_ranges[inner_range];
|
|
|
|
|
while (corrections)
|
|
|
|
|
if (tok.v.o == Expression::Token::OPA)
|
|
|
|
|
{
|
|
|
|
|
corrections = 0;
|
|
|
|
|
relative_level++;
|
|
|
|
|
}
|
|
|
|
|
else if (tok.v.o == Expression::Token::CPA)
|
|
|
|
|
{
|
|
|
|
|
relative_level--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int same_op_cnt = -1;
|
|
|
|
|
for (int i = outer_range.start + range.start; i < outer_range.start + range.finish + 1; i++)
|
|
|
|
|
if (relative_level < 0)
|
|
|
|
|
{
|
|
|
|
|
same_op_cnt = -1;
|
|
|
|
|
}
|
|
|
|
|
else if ((tok.v.o == Expression::Token::SUB || tok.v.o == Expression::Token::DIV) && !relative_level)
|
|
|
|
|
{
|
|
|
|
|
same_op_cnt++;
|
|
|
|
|
|
|
|
|
|
if (same_op_cnt == 2)
|
|
|
|
|
{
|
|
|
|
|
int loc = get_mop_location(tv, i);
|
|
|
|
|
Expression::Token& tok = tv[loc];
|
|
|
|
|
same_op_cnt = 0;
|
|
|
|
|
|
|
|
|
|
if (tok.v.o == Expression::Token::SUB || tok.v.o == Expression::Token::DIV)
|
|
|
|
|
corrections++;
|
|
|
|
|
|
|
|
|
|
switch (tok.v.o)
|
|
|
|
|
{
|
|
|
|
|
same_op_cnt++;
|
|
|
|
|
|
|
|
|
|
if (same_op_cnt == 2)
|
|
|
|
|
{
|
|
|
|
|
same_op_cnt = 0;
|
|
|
|
|
|
|
|
|
|
corrections++;
|
|
|
|
|
|
|
|
|
|
switch (tok.v.o)
|
|
|
|
|
{
|
|
|
|
|
case Expression::Token::SUB:
|
|
|
|
|
tok.v.o = Expression::Token::ADD;
|
|
|
|
|
break;
|
|
|
|
|
case Expression::Token::DIV:
|
|
|
|
|
tok.v.o = Expression::Token::MUL;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
pr_warn("Impossible operator in this branch, this is a bug!");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// inverse order to keep location valid between calls
|
|
|
|
|
add_bracket_to(tv, loc, 1);
|
|
|
|
|
add_bracket_to(tv, loc, -1);
|
|
|
|
|
|
|
|
|
|
pr_debug("Updated vector:");
|
|
|
|
|
Parser::print_math_vector(tv);
|
|
|
|
|
}
|
|
|
|
|
case Expression::Token::SUB:
|
|
|
|
|
tok.v.o = Expression::Token::ADD;
|
|
|
|
|
break;
|
|
|
|
|
case Expression::Token::DIV:
|
|
|
|
|
tok.v.o = Expression::Token::MUL;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
pr_warn("Impossible operator in this branch, this is a bug!");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// inverse order to keep location valid between calls
|
|
|
|
|
std::vector<int> highlight_locations;
|
|
|
|
|
highlight_locations.emplace_back(i+1);
|
|
|
|
|
highlight_locations.emplace_back(add_bracket_to(tv, i, 1) + 1);
|
|
|
|
|
highlight_locations.emplace(highlight_locations.begin(), add_bracket_to(tv, i, -1));
|
|
|
|
|
|
|
|
|
|
// advance one step to compensate for inserted left bracket
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
// elevate one level to compensate for new brackets
|
|
|
|
|
relative_level++;
|
|
|
|
|
|
|
|
|
|
Parser::print_math_vector(tv, highlight_locations);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -726,15 +837,14 @@ std::vector<Expression::Operation> build_op_vector(const std::vector<Expression:
|
|
|
|
|
std::vector<int> g_prios;
|
|
|
|
|
create_prios_vector(tv, g_prios);
|
|
|
|
|
|
|
|
|
|
for (int i = 0, l = g_prios.size(); i < l; i++)
|
|
|
|
|
{
|
|
|
|
|
pr_debug("prio=" << g_prios[i]);
|
|
|
|
|
}
|
|
|
|
|
pr_debug("Building operation vector");
|
|
|
|
|
|
|
|
|
|
std::vector<Expression::Token> cv = tv; // Constant sync Vector
|
|
|
|
|
|
|
|
|
|
// build operation vector
|
|
|
|
|
std::vector<Expression::Operation> ov;
|
|
|
|
|
{
|
|
|
|
|
std::vector<Expression::Token> mv = tv;
|
|
|
|
|
std::vector<Expression::Token> mv = tv; // Modifiable Vector
|
|
|
|
|
std::vector<int> mp = g_prios;
|
|
|
|
|
|
|
|
|
|
while (mp.size())
|
|
|
|
@@ -751,15 +861,20 @@ std::vector<Expression::Operation> build_op_vector(const std::vector<Expression:
|
|
|
|
|
std::vector<int> operator_weights;
|
|
|
|
|
weight_operators(operator_weights, mv, inner_top_ops, start);
|
|
|
|
|
|
|
|
|
|
write_operation(ov, tv, mv, mp, start + inner_top_ops[get_min_index(operator_weights)]);
|
|
|
|
|
write_operation(ov, cv, mv, mp, start + inner_top_ops[get_min_index(operator_weights)]);
|
|
|
|
|
finish--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// process final operation w/out running selection algorithm
|
|
|
|
|
write_operation(ov, tv, mv, mp, start);
|
|
|
|
|
write_operation(ov, cv, mv, mp, start);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pr_debug("Final value:");
|
|
|
|
|
Parser::print_math_vector(mv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pr_debug("Resulting operation vector:");
|
|
|
|
|
|
|
|
|
|
for (int i = 0, l = ov.size(); i < l; i++)
|
|
|
|
|
{
|
|
|
|
|
const Expression::Operation &o = ov[i];
|
|
|
|
@@ -768,16 +883,8 @@ std::vector<Expression::Operation> build_op_vector(const std::vector<Expression:
|
|
|
|
|
|
|
|
|
|
if (o.tl == Expression::Operation::NORMAL)
|
|
|
|
|
{
|
|
|
|
|
const Expression::Token &real_value = tv[o.il];
|
|
|
|
|
|
|
|
|
|
if (real_value.t == Expression::Token::VAR)
|
|
|
|
|
{
|
|
|
|
|
pri_debug(*real_value.v.s);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pri_debug(real_value.v.d);
|
|
|
|
|
}
|
|
|
|
|
const Expression::Token &real_value = cv[o.il];
|
|
|
|
|
pri_debug(*real_value.to_math_str());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@@ -788,16 +895,8 @@ std::vector<Expression::Operation> build_op_vector(const std::vector<Expression:
|
|
|
|
|
|
|
|
|
|
if (o.tr == Expression::Operation::NORMAL)
|
|
|
|
|
{
|
|
|
|
|
const Expression::Token &real_value = tv[o.ir];
|
|
|
|
|
|
|
|
|
|
if (real_value.t == Expression::Token::VAR)
|
|
|
|
|
{
|
|
|
|
|
pri_debug(*real_value.v.s);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pri_debug(real_value.v.d);
|
|
|
|
|
}
|
|
|
|
|
const Expression::Token &real_value = cv[o.ir];
|
|
|
|
|
pri_debug(*real_value.to_math_str());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@@ -854,13 +953,6 @@ Expression::TreeNode ov_to_tree(const std::vector<Expression::Token> tv, const s
|
|
|
|
|
return root;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
static int get_tree_depth(const Expression::TreeNode& root)
|
|
|
|
|
{
|
|
|
|
|
retur
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void print_op_tree(const Expression::TreeNode& root)
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::pair<Expression::TreeNode *, int>> items_to_display;
|
|
|
|
|