mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
LR0: Implemented unformatted ::dump
This commit is contained in:
parent
5f6a522ad8
commit
90ccdc872f
1 changed files with 21 additions and 10 deletions
31
src/LR0.cpp
31
src/LR0.cpp
|
@ -207,21 +207,32 @@ void LR0::debug (bool value)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// +-------+---------------+---------------+
|
||||||
|
// | state | actions... | goto... |
|
||||||
|
// | | terminals $ | non-terminals |
|
||||||
|
// +-------+--+--+--+--+---+----+-----+----+
|
||||||
|
// | | | | | | | | | |
|
||||||
|
// +-------+--+--+--+--+---+----+-----+----+
|
||||||
|
// | | | | | | | | | |
|
||||||
|
// +-------+--+--+--+--+---+----+-----+----+
|
||||||
std::string LR0::dump () const
|
std::string LR0::dump () const
|
||||||
{
|
{
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << "Parser Tables\n";
|
out << "Parser Tables\n";
|
||||||
|
|
||||||
// TODO Render _actions and _goto as a table.
|
for (unsigned int state = 0; state < _actions.size (); ++state)
|
||||||
//
|
{
|
||||||
// +-------+---------------+---------------+
|
out << " " << state;
|
||||||
// | state | actions... | goto... |
|
for (auto& terminal : _actions[state])
|
||||||
// | | terminals $ | non-terminals |
|
out << " " << terminal.first << ":" << terminal.second;
|
||||||
// +-------+--+--+--+--+---+----+-----+----+
|
|
||||||
// | | | | | | | | | |
|
out << " ";
|
||||||
// +-------+--+--+--+--+---+----+-----+----+
|
|
||||||
// | | | | | | | | | |
|
for (auto& rule : _goto[state])
|
||||||
// +-------+--+--+--+--+---+----+-----+----+
|
out << " " << rule.first << ":" << rule.second;
|
||||||
|
|
||||||
|
out << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue