Files
kraken/include/Parser.h

49 lines
1.0 KiB
C
Raw Normal View History

2013-05-20 19:34:15 -04:00
#ifndef PARSER_H
#define PARSER_H
#ifndef NULL
#define NULL 0
#endif
#include "ParseRule.h"
2013-05-23 01:35:54 -04:00
#include "ParseAction.h"
2013-05-20 19:34:15 -04:00
#include "Symbol.h"
#include "State.h"
2013-05-20 19:34:15 -04:00
#include "StringReader.h"
#include <map>
#include <vector>
2013-05-23 01:35:54 -04:00
#include <stack>
2013-05-20 19:34:15 -04:00
#include <string>
#include <iostream>
class Parser {
public:
Parser();
~Parser();
void loadGrammer(std::string grammerInputString);
void createStateSet();
void closure(State* state);
void addState(std::vector< State* >* stateSets, State* state, Symbol*);
std::string stateSetToString();
2013-05-23 01:35:54 -04:00
int gotoTable(int state, Symbol* token);
ParseAction* actionTable(int state, Symbol* token);
void parseInput(std::string inputString);
2013-05-20 19:34:15 -04:00
std::string grammerToString();
std::string grammerToDOT();
2013-05-20 19:34:15 -04:00
private:
StringReader reader;
std::map<std::string, Symbol*> symbols;
std::vector<ParseRule*> loadedGrammer;
std::vector< State* > stateSets;
2013-05-23 01:35:54 -04:00
std::stack<int> stateStack;
std::stack<Symbol*> symbolStack;
2013-05-20 19:34:15 -04:00
Symbol* getOrAddSymbol(std::string symbolString, bool isTerminal);
};
#endif