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:
Nathan Braswell
2013-06-26 14:27:28 -04:00
parent ee9b8b8c39
commit 6a2977d12a
5 changed files with 78 additions and 109 deletions

View File

@@ -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;
};