LR0: Added ::createParseTables, ::dump

This commit is contained in:
Paul Beckingham 2015-12-22 23:26:06 -05:00
parent fa375615cd
commit bc22348822
2 changed files with 37 additions and 0 deletions

View file

@ -26,6 +26,7 @@
#include <cmake.h>
#include <LR0.h>
#include <sstream>
////////////////////////////////////////////////////////////////////////////////
LR0::LR0 ()
@ -33,3 +34,27 @@ LR0::LR0 ()
}
////////////////////////////////////////////////////////////////////////////////
void LR0::createParseTables (Grammar& grammar)
{
}
////////////////////////////////////////////////////////////////////////////////
std::string LR0::dump () const
{
std::stringstream out;
// TODO Render _actions and _goto as a table.
//
// +-------+---------------+---------------+
// | state | actions... | goto... |
// | | terminals $ | non-terminals |
// +-------+-----------+---+----+-----+----+
// | | | | | | |
// +-------+-----------+---+----+-----+----+
// | | | | | | |
// +-------+-----------+---+----+-----+----+
return out.str ();
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -27,10 +27,22 @@
#ifndef INCLUDED_LR0
#define INCLUDED_LR0
#include <Grammar.h>
#include <map>
#include <string>
class LR0
{
public:
LR0 ();
void createParseTables (Grammar&);
std::string dump () const;
private:
// state column result
// | | |
std::map <int, std::map <std::string, std::string>> _actions;
std::map <int, std::map <std::string, std::string>> _goto;
};
#endif