LR0: Added ::getExpectations

This commit is contained in:
Paul Beckingham 2016-01-02 14:16:11 -05:00
parent 9327ff7c8b
commit 679f094f16

View file

@ -105,9 +105,14 @@ LR0::Closure LR0::getClosure (const Closure& items)
}
////////////////////////////////////////////////////////////////////////////////
// Collect a unique set of expected symbols from the closure.
std::vector <std::string> LR0::getExpectations (const Closure& closure)
{
std::vector <std::string> expected;
for (auto& item : closure)
if (! item.done () &&
std::find (expected.begin (), expected.end (), item.next ()) == expected.end ())
expected.push_back (item.next ());
return expected;
}