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,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 ();
} }