mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
LR0: Added ::createParseTables, ::dump
This commit is contained in:
parent
fa375615cd
commit
bc22348822
2 changed files with 37 additions and 0 deletions
25
src/LR0.cpp
25
src/LR0.cpp
|
@ -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 ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
12
src/LR0.h
12
src/LR0.h
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue