fix dot crashing in multiple places
This commit is contained in:
+2
-1
@@ -302,11 +302,12 @@ public:
|
||||
// if value, left and right hands should be null
|
||||
|
||||
explicit TreeNode(void)
|
||||
: l(nullptr), r(nullptr), o()
|
||||
{
|
||||
}
|
||||
|
||||
explicit TreeNode(const Token t)
|
||||
: o(t)
|
||||
: l(nullptr), r(nullptr), o(t)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -377,7 +377,10 @@ void print_token_vector(const std::vector<Expression::Token>& tv)
|
||||
std::cout << "(" << *tv[i].to_str() << ") ";
|
||||
}
|
||||
|
||||
if (tv.size())
|
||||
{
|
||||
std::cout << "(" << *tv[i].to_str() << ")\n";
|
||||
}
|
||||
}
|
||||
|
||||
void print_math_vector(const std::vector<Expression::Token>& tv)
|
||||
@@ -388,7 +391,10 @@ void print_math_vector(const std::vector<Expression::Token>& tv)
|
||||
std::cout << *tv[i].to_math_str(); //<< " ";
|
||||
}
|
||||
|
||||
if (tv.size())
|
||||
{
|
||||
std::cout << *tv[i].to_math_str() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ int check_syntax(std::vector<Expression::Token>& tv)
|
||||
int problem_cnt = 0;
|
||||
|
||||
// check start and finish validity
|
||||
if (tv.size())
|
||||
{
|
||||
int pc = problem_cnt;
|
||||
|
||||
@@ -101,6 +102,7 @@ int check_syntax(std::vector<Expression::Token>& tv)
|
||||
}
|
||||
|
||||
// check token type sequence
|
||||
if (tv.size() > 1)
|
||||
{
|
||||
for (int i = 0, l = tv.size() - 1, pc; pc = problem_cnt, i < l; i++)
|
||||
{
|
||||
@@ -812,7 +814,11 @@ Expression::TreeNode ov_to_tree(const std::vector<Expression::Token> tv, const s
|
||||
{
|
||||
Expression::TreeNode root;
|
||||
std::queue<std::pair<Expression::TreeNode *, int>> queued_ops;
|
||||
|
||||
if (ov.size())
|
||||
{
|
||||
queued_ops.emplace(&root, ov.size() - 1);
|
||||
}
|
||||
|
||||
while (queued_ops.size())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user