2013-12-31 02:53:52 -06:00
|
|
|
#include <fstream>
|
|
|
|
|
|
2014-06-30 01:57:50 -07:00
|
|
|
#include <string>
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
2013-07-16 11:15:58 -04:00
|
|
|
#include "util.h"
|
|
|
|
|
#include "ParseRule.h"
|
|
|
|
|
#include "ParseAction.h"
|
|
|
|
|
#include "Symbol.h"
|
|
|
|
|
#include "State.h"
|
|
|
|
|
|
|
|
|
|
#ifndef TABLE_H
|
|
|
|
|
#define TABLE_H
|
|
|
|
|
|
|
|
|
|
class Table {
|
|
|
|
|
public:
|
|
|
|
|
Table();
|
|
|
|
|
~Table();
|
2013-12-31 02:53:52 -06:00
|
|
|
void exportTable(std::ofstream &file);
|
|
|
|
|
void importTable(char* tableData);
|
2013-10-02 03:15:20 -04:00
|
|
|
void setSymbols(Symbol EOFSymbol, Symbol nullSymbol);
|
|
|
|
|
void add(int stateNum, Symbol tranSymbol, ParseAction* action);
|
|
|
|
|
void remove(int stateNum, Symbol tranSymbol);
|
|
|
|
|
std::vector<ParseAction*>* get(int state, Symbol token);
|
|
|
|
|
ParseAction* getShift(int state, Symbol token);
|
2014-06-30 01:57:50 -07:00
|
|
|
std::vector<std::pair<std::string, ParseAction>> stateAsParseActionVector(int state);
|
|
|
|
|
std::string toString();
|
2013-07-16 11:15:58 -04:00
|
|
|
private:
|
2013-07-28 23:48:10 -04:00
|
|
|
std::vector< std::vector< std::vector<ParseAction*>* >* > table;
|
2013-10-02 03:15:20 -04:00
|
|
|
std::vector<Symbol> symbolIndexVec;
|
2013-07-16 11:15:58 -04:00
|
|
|
//The EOFSymbol, a pointer because of use in table, etc
|
2013-10-02 03:15:20 -04:00
|
|
|
Symbol EOFSymbol;
|
2013-07-16 11:15:58 -04:00
|
|
|
//The nullSymbol, ditto with above. Also used in comparisons
|
2013-10-02 03:15:20 -04:00
|
|
|
Symbol nullSymbol;
|
2013-07-16 11:15:58 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|