Added main loop of parser.

This commit is contained in:
Nathan Braswell
2013-05-23 01:35:54 -04:00
parent 14fc410e00
commit e4f83cbb67
9 changed files with 142 additions and 2 deletions

View File

@@ -6,11 +6,13 @@
#endif
#include "ParseRule.h"
#include "ParseAction.h"
#include "Symbol.h"
#include "StringReader.h"
#include <map>
#include <vector>
#include <stack>
#include <string>
#include <iostream>
@@ -20,6 +22,10 @@ class Parser {
~Parser();
void loadGrammer(std::string grammerInputString);
int gotoTable(int state, Symbol* token);
ParseAction* actionTable(int state, Symbol* token);
void parseInput(std::string inputString);
std::string grammerToString();
std::string grammerToDOT();
private:
@@ -27,6 +33,9 @@ class Parser {
std::map<std::string, Symbol*> symbols;
std::vector<ParseRule*> loadedGrammer;
std::stack<int> stateStack;
std::stack<Symbol*> symbolStack;
Symbol* getOrAddSymbol(std::string symbolString, bool isTerminal);
};