mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
LR0: Capture state transitions during closure
This commit is contained in:
parent
67b497733f
commit
227c5ae8e5
1 changed files with 3 additions and 1 deletions
|
@ -135,6 +135,7 @@ void LR0::closeState (States& states, const int state) const
|
||||||
{
|
{
|
||||||
Item advanced (item);
|
Item advanced (item);
|
||||||
advanced.advance ();
|
advanced.advance ();
|
||||||
|
advanced.setTransition (state);
|
||||||
closure.push_back (advanced);
|
closure.push_back (advanced);
|
||||||
|
|
||||||
if (! advanced.done ())
|
if (! advanced.done ())
|
||||||
|
@ -148,6 +149,7 @@ void LR0::closeState (States& states, const int state) const
|
||||||
{
|
{
|
||||||
Item additional (_augmented[r]);
|
Item additional (_augmented[r]);
|
||||||
additional.setGrammarRuleIndex (r);
|
additional.setGrammarRuleIndex (r);
|
||||||
|
additional.setTransition (state);
|
||||||
closure.push_back (additional);
|
closure.push_back (additional);
|
||||||
seen.insert (nextSymbol);
|
seen.insert (nextSymbol);
|
||||||
}
|
}
|
||||||
|
@ -290,9 +292,9 @@ LR0::Item::Item (const std::vector <std::string>& rule)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool LR0::Item::operator== (const Item& other)
|
bool LR0::Item::operator== (const Item& other)
|
||||||
{
|
{
|
||||||
|
// Deliberately ignores _transitionsTo.
|
||||||
if (_cursor != other._cursor ||
|
if (_cursor != other._cursor ||
|
||||||
_grammarRule != other._grammarRule ||
|
_grammarRule != other._grammarRule ||
|
||||||
_transitionsTo != other._transitionsTo ||
|
|
||||||
_rule.size () != other._rule.size ())
|
_rule.size () != other._rule.size ())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue