LR0: Changed ::expand to take a single symbol, not a closure

- Updated ::initialize to handle the expanѕion of the first rule.
This commit is contained in:
Paul Beckingham 2016-01-02 15:21:50 -05:00
parent 27f71d810f
commit 586cce2114
2 changed files with 9 additions and 5 deletions

View file

@ -74,11 +74,15 @@ void LR0::initialize (const Grammar& grammar)
Closure items;
items.push_back (item0);
auto closure = getClosure (items);
for (auto& expected : getExpected (items))
for (auto& item : expand (expected))
items.push_back (item);
States states;
states.push_back (closure);
states.push_back (items);
std::cout << states.dump () << "\n";
// TODO Now recursively fill in the rest.
}
////////////////////////////////////////////////////////////////////////////////
@ -127,11 +131,11 @@ std::set <std::string> LR0::getExpected (const Closure& closure) const
}
////////////////////////////////////////////////////////////////////////////////
LR0::Closure LR0::expand (const Closure& closure) const
LR0::Closure LR0::expand (const std::string& symbol) const
{
LR0::Closure result;
return closure;
return result;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -70,7 +70,7 @@ public:
private:
Closure getClosure (const Closure&) const;
std::set <std::string> getExpected (const Closure&) const;
Closure expand (const Closure&) const;
Closure expand (const std::string&) const;
private:
// Copy of the augmented grammar.