mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
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:
parent
27f71d810f
commit
586cce2114
2 changed files with 9 additions and 5 deletions
12
src/LR0.cpp
12
src/LR0.cpp
|
@ -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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue