mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
LR0: Initialization in ::createParseTable
This commit is contained in:
parent
9d239f7a80
commit
5f6a522ad8
1 changed files with 16 additions and 1 deletions
17
src/LR0.cpp
17
src/LR0.cpp
|
@ -176,7 +176,22 @@ void LR0::closeState (States& states, const int state) const
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void LR0::createParseTable (States& states)
|
void LR0::createParseTable (States& states)
|
||||||
{
|
{
|
||||||
// TODO Convert States to the _actions and _goto tables.
|
// First size the tables:
|
||||||
|
// - Create a row for every state
|
||||||
|
// - Create a column for every terminal in the _actions table
|
||||||
|
// - Create a column for every rule in the _goto table
|
||||||
|
for (unsigned int state = 0; state < states.size (); ++state)
|
||||||
|
{
|
||||||
|
// Create a column for every terminal, plus "$".
|
||||||
|
_actions.push_back ({});
|
||||||
|
_actions[state]["$"] = "";
|
||||||
|
for (auto& terminal : _terminals)
|
||||||
|
_actions[state][terminal] = "";
|
||||||
|
|
||||||
|
_goto.push_back ({});
|
||||||
|
for (auto& rule : _rules)
|
||||||
|
_goto[state][rule] = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue