Commit 53f9718b authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Add explicit error message when trying to build a feature from a postfix...

Add explicit error message when trying to build a feature from a postfix expression with an improper leaf

Stops the seg fault when this occurs
parent 50ea6832
......@@ -45,6 +45,10 @@ node_ptr str2node::postfix2node(const std::string postfix_expr, const std::vecto
std::string term = postfix_split[ff];
if(term.find_first_not_of("0123456789") == std::string::npos)
{
if(std::stoi(term) >= phi_0.size())
{
throw std::logic_error("Accessing feature outside of phi_0");
}
stack.push_back(phi_0[std::stoi(term)]);
++feat_ind;
}
......@@ -408,7 +412,9 @@ std::vector<node_ptr> str2node::phi_from_file(const std::string filename, const
{
node_ptr feat = postfix2node(line, phi_0, feat_ind);
if(feat->type() == NODE_TYPE::FEAT)
{
continue;
}
phi.push_back(feat);
phi.back()->set_selected(false);
++feat_ind;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment