Redid lookahead in a much much saner way. Now should be a legitimate parser somewhere between LALR(1) and LR(1).
This commit is contained in:
@@ -14,9 +14,9 @@
|
||||
class ParseRule {
|
||||
public:
|
||||
ParseRule();
|
||||
ParseRule(Symbol* leftHandle, int pointerIndex, std::vector<Symbol*> &rightSide, Symbol* lookahead = NULL);
|
||||
ParseRule(Symbol* leftHandle, int pointerIndex, std::vector<Symbol*> &rightSide, std::vector<Symbol*>* lookahead);
|
||||
~ParseRule();
|
||||
|
||||
const bool equalsExceptLookahead(const ParseRule &other);
|
||||
bool const operator==(const ParseRule &other);
|
||||
bool const operator!=(const ParseRule &other);
|
||||
|
||||
@@ -35,13 +35,16 @@ class ParseRule {
|
||||
bool advancePointer();
|
||||
bool isAtEnd();
|
||||
|
||||
void setLookahead(std::vector<Symbol*>* lookahead);
|
||||
std::vector<Symbol*>* getLookahead();
|
||||
|
||||
std::string toString();
|
||||
std::string toDOT();
|
||||
|
||||
private:
|
||||
int pointerIndex;
|
||||
Symbol* leftHandle;
|
||||
Symbol* lookahead;
|
||||
std::vector<Symbol*>* lookahead;
|
||||
std::vector<Symbol*> rightSide;
|
||||
|
||||
};
|
||||
|
||||
@@ -25,9 +25,7 @@ class Parser {
|
||||
void loadGrammer(std::string grammerInputString);
|
||||
std::vector<Symbol*>* firstSet(Symbol* token);
|
||||
void printFirstSets();
|
||||
//std::vector<Symbol*>* followSet(int stateNum, Symbol* token);
|
||||
std::vector<Symbol*>* gramFollowSet(State* state, Symbol* token);
|
||||
std::vector<Symbol*>* gramFollowSetAvoid(State* state, Symbol* token, std::vector<Symbol*>* avoidList);
|
||||
std::vector<Symbol*>* incrementiveFollowSet(ParseRule* rule);
|
||||
void createStateSet();
|
||||
void closure(State* state);
|
||||
void addStates(std::vector< State* >* stateSets, State* state);
|
||||
|
||||
Reference in New Issue
Block a user