Added first go at creating stateSets. This is a commit to save work, as it still segfaults.:

This commit is contained in:
Nathan Braswell
2013-05-24 00:00:41 -04:00
parent e4f83cbb67
commit 1aec4ee6a7
5 changed files with 115 additions and 0 deletions

View File

@@ -17,6 +17,8 @@ class ParseRule {
ParseRule(Symbol* leftHandle, int pointerIndex, std::vector<Symbol*> &rightSide);
~ParseRule();
bool const operator==(const ParseRule &other);
ParseRule* clone();
void setLeftHandle(Symbol* leftHandle);
@@ -24,6 +26,7 @@ class ParseRule {
Symbol* getLeftSide();
std::vector<Symbol*> getRightSide();
int getIndex();
bool advancePointer();

View File

@@ -14,6 +14,7 @@
#include <vector>
#include <stack>
#include <string>
#include <sstream>
#include <iostream>
class Parser {
@@ -21,7 +22,13 @@ class Parser {
Parser();
~Parser();
std::string intToString(int theInt);
void loadGrammer(std::string grammerInputString);
void createStateSet();
void closure(std::vector<ParseRule*>* state);
void addState(std::vector< std::vector<ParseRule*>* >* stateSets, std::vector<ParseRule*>* state, Symbol*);
std::string stateSetToString();
int gotoTable(int state, Symbol* token);
ParseAction* actionTable(int state, Symbol* token);
void parseInput(std::string inputString);
@@ -33,6 +40,8 @@ class Parser {
std::map<std::string, Symbol*> symbols;
std::vector<ParseRule*> loadedGrammer;
std::vector< std::vector<ParseRule*>* > stateSets;
std::stack<int> stateStack;
std::stack<Symbol*> symbolStack;