Changed followset to work on states, fixed many bugs. Kraken now should have a fairly legitimate LALR(1) parser. (null productions have not yet been added.)
This commit is contained in:
@@ -26,9 +26,8 @@ class Parser {
|
||||
std::vector<Symbol*>* firstSet(Symbol* token);
|
||||
void printFirstSets();
|
||||
//std::vector<Symbol*>* followSet(int stateNum, Symbol* token);
|
||||
std::vector<Symbol*>* gramFollowSet(Symbol* token);
|
||||
std::vector<Symbol*>* gramFollowSetAvoid(Symbol* token, std::vector<Symbol*>* avoidList);
|
||||
void printFollowSets();
|
||||
std::vector<Symbol*>* gramFollowSet(State* state, Symbol* token);
|
||||
std::vector<Symbol*>* gramFollowSetAvoid(State* state, Symbol* token, std::vector<Symbol*>* avoidList);
|
||||
void createStateSet();
|
||||
void closure(State* state);
|
||||
void addStates(std::vector< State* >* stateSets, State* state);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
class State {
|
||||
public:
|
||||
State(int number, ParseRule* basis);
|
||||
State(int number, ParseRule* basis, State* parent);
|
||||
~State();
|
||||
bool const operator==(const State &other);
|
||||
bool const basisEquals(const State &other);
|
||||
@@ -26,10 +27,15 @@ class State {
|
||||
bool containsRule(ParseRule* rule);
|
||||
std::string toString();
|
||||
|
||||
void addParents(std::vector<State*>* parents);
|
||||
std::vector<State*>* getParents();
|
||||
std::vector<State*>* getDeepParents(int depth);
|
||||
|
||||
|
||||
std::vector<ParseRule*> basis;
|
||||
std::vector<ParseRule*> remaining;
|
||||
private:
|
||||
std::vector<State*> parents;
|
||||
std::vector<ParseRule*> total;
|
||||
int number;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user