mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
LR0: ::createParseTable now find acceptance and reductions
This commit is contained in:
parent
b3eef3f959
commit
a2e45b9297
1 changed files with 10 additions and 7 deletions
17
src/LR0.cpp
17
src/LR0.cpp
|
@ -198,14 +198,17 @@ void LR0::createParseTable (States& states)
|
|||
_goto[state][rule] = "";
|
||||
}
|
||||
|
||||
// Look for states with items that are done, and mark them as reductions, but
|
||||
// a reduction of grammar rule 0 is marked "acc".
|
||||
for (unsigned int state = 0; state < states.size (); ++state)
|
||||
{
|
||||
/*
|
||||
if (states[state].size () == 1 &&
|
||||
states[state][0].done ())
|
||||
_actions[state][states[state][0]._rule[states[state]0]._cursor]] = format ("r{1}", states[state][0]._grammarRule);
|
||||
*/
|
||||
}
|
||||
for (unsigned int item = 0; item < states[state].size (); ++item)
|
||||
if (states[state][item].done ())
|
||||
if (states[state][item]._grammarRule == 0)
|
||||
_actions[state]["$"] = "acc";
|
||||
else
|
||||
for (auto& terminal : _terminals)
|
||||
_actions[state][terminal] = format ("r{1}", states[state][item]._grammarRule);
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue