From 679f094f16c3584253aa4ac9b3394a03ccd96d2a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 2 Jan 2016 14:16:11 -0500 Subject: [PATCH] LR0: Added ::getExpectations --- src/LR0.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/LR0.cpp b/src/LR0.cpp index 59c35017..7a8e7252 100644 --- a/src/LR0.cpp +++ b/src/LR0.cpp @@ -105,9 +105,14 @@ LR0::Closure LR0::getClosure (const Closure& items) } //////////////////////////////////////////////////////////////////////////////// +// Collect a unique set of expected symbols from the closure. std::vector LR0::getExpectations (const Closure& closure) { std::vector 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; }