mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
LR0: Converted ::getExpected from std::vector to std::set
This commit is contained in:
parent
1305c0cb55
commit
31b53e8c23
2 changed files with 6 additions and 6 deletions
|
@ -116,13 +116,12 @@ LR0::Closure LR0::getClosure (const Closure& items)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Collect a unique set of expected symbols from the closure.
|
// Collect a unique set of expected symbols from the closure.
|
||||||
std::vector <std::string> LR0::getExpected (const Closure& closure)
|
std::set <std::string> LR0::getExpected (const Closure& closure)
|
||||||
{
|
{
|
||||||
std::vector <std::string> expected;
|
std::set <std::string> expected;
|
||||||
for (auto& item : closure)
|
for (auto& item : closure)
|
||||||
if (! item.done () &&
|
if (! item.done ())
|
||||||
std::find (expected.begin (), expected.end (), item.next ()) == expected.end ())
|
expected.insert (item.next ());
|
||||||
expected.push_back (item.next ());
|
|
||||||
|
|
||||||
return expected;
|
return expected;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#define INCLUDED_LR0
|
#define INCLUDED_LR0
|
||||||
|
|
||||||
#include <Grammar.h>
|
#include <Grammar.h>
|
||||||
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Closure getClosure (const Closure&);
|
Closure getClosure (const Closure&);
|
||||||
std::vector <std::string> getExpected (const Closure&);
|
std::set <std::string> getExpected (const Closure&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Copy of the augmented grammar.
|
// Copy of the augmented grammar.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue