LR0: Implemented unformatted ::dump

This commit is contained in:
Paul Beckingham 2016-01-05 12:04:26 -05:00
parent 5f6a522ad8
commit 90ccdc872f

View file

@ -207,13 +207,6 @@ void LR0::debug (bool value)
}
////////////////////////////////////////////////////////////////////////////////
std::string LR0::dump () const
{
std::stringstream out;
out << "Parser Tables\n";
// TODO Render _actions and _goto as a table.
//
// +-------+---------------+---------------+
// | state | actions... | goto... |
// | | terminals $ | non-terminals |
@ -222,6 +215,24 @@ std::string LR0::dump () const
// +-------+--+--+--+--+---+----+-----+----+
// | | | | | | | | | |
// +-------+--+--+--+--+---+----+-----+----+
std::string LR0::dump () const
{
std::stringstream out;
out << "Parser Tables\n";
for (unsigned int state = 0; state < _actions.size (); ++state)
{
out << " " << state;
for (auto& terminal : _actions[state])
out << " " << terminal.first << ":" << terminal.second;
out << " ";
for (auto& rule : _goto[state])
out << " " << rule.first << ":" << rule.second;
out << "\n";
}
return out.str ();
}