A3t
- Added ::clear method. - Handles ::captureFirst with an empty tree.
This commit is contained in:
15
src/A3t.cpp
15
src/A3t.cpp
@@ -76,6 +76,16 @@ void A3t::initialize (int argc, const char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void A3t::clear ()
|
||||
{
|
||||
delete _tree;
|
||||
|
||||
_tree = new Tree ("root");
|
||||
if (! _tree)
|
||||
throw std::string ("Failed to allocate memory for parse tree.");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Add an arg for every word from std::cin.
|
||||
//
|
||||
@@ -514,11 +524,12 @@ Tree* A3t::captureFirst (const std::string& arg)
|
||||
t->_trunk = _tree;
|
||||
|
||||
std::vector <Tree*>::iterator i = _tree->_branches.begin ();
|
||||
i++; // Walk past the binary.
|
||||
if (i != _tree->_branches.end ())
|
||||
i++; // Walk past the binary.
|
||||
|
||||
_tree->_branches.insert (i, t);
|
||||
findCommand ();
|
||||
|
||||
findCommand ();
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user