#ifndef PARSER_H #define PARSER_H #ifndef NULL #define NULL 0 #endif #include "util.h" #include "ParseRule.h" #include "ParseAction.h" #include "Symbol.h" #include "State.h" #include "StringReader.h" #include "NodeTree.h" #include #include #include #include #include #include class Parser { public: Parser(); ~Parser(); void loadGrammer(std::string grammerInputString); void createStateSet(); void closure(State* state); void addStates(std::vector< State* >* stateSets, State* state); std::string stateSetToString(); void addToTable(State* fromState, Symbol* tranSymbol, ParseAction* action); ParseAction* getTable(int state, Symbol* token); NodeTree* parseInput(std::string inputString); std::string grammerToString(); std::string grammerToDOT(); std::string tableToString(); private: StringReader reader; std::map symbols; std::vector loadedGrammer; std::vector< State* > stateSets; std::vector< std::vector* > table; std::vector symbolIndexVec; std::stack stateStack; std::stack symbolStack; Symbol* getOrAddSymbol(std::string symbolString, bool isTerminal); NodeTree* reduceTreeCombine(Symbol* newSymbol, std::vector &symbols); }; #endif