Fixes for state generation to reduce memory usage - adding in optional semicolons balooned our memory usage to somewhere under 8 gigs, with some simple refactoring we're back down to a bit over 4. Needs to be smaller, but it's an improvement
This commit is contained in:
@@ -12,9 +12,15 @@
|
||||
#include <iostream>
|
||||
|
||||
class ParseRule {
|
||||
private:
|
||||
int pointerIndex;
|
||||
Symbol leftHandle;
|
||||
std::vector<Symbol> lookahead;
|
||||
std::vector<Symbol> rightSide;
|
||||
|
||||
public:
|
||||
ParseRule();
|
||||
ParseRule(Symbol leftHandle, int pointerIndex, std::vector<Symbol> &rightSide, std::vector<Symbol>* lookahead);
|
||||
ParseRule(Symbol leftHandle, int pointerIndex, std::vector<Symbol> &rightSide, std::vector<Symbol> lookahead);
|
||||
~ParseRule();
|
||||
const bool equalsExceptLookahead(const ParseRule &other) const;
|
||||
bool const operator==(const ParseRule &other) const;
|
||||
@@ -36,19 +42,12 @@ class ParseRule {
|
||||
bool advancePointer();
|
||||
bool isAtEnd();
|
||||
|
||||
void setLookahead(std::vector<Symbol>* lookahead);
|
||||
void addLookahead(std::vector<Symbol>* lookahead);
|
||||
std::vector<Symbol>* getLookahead();
|
||||
void setLookahead(std::vector<Symbol> lookahead);
|
||||
void addLookahead(std::vector<Symbol> lookahead);
|
||||
std::vector<Symbol> getLookahead();
|
||||
|
||||
std::string toString(bool printLookahead = true);
|
||||
std::string toDOT();
|
||||
|
||||
private:
|
||||
int pointerIndex;
|
||||
Symbol leftHandle;
|
||||
std::vector<Symbol>* lookahead;
|
||||
std::vector<Symbol> rightSide;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -44,7 +44,7 @@ class Parser {
|
||||
std::map<Symbol, std::vector<Symbol>> tokenFirstSet;
|
||||
std::map<Symbol, bool> tokenNullable;
|
||||
|
||||
std::vector<Symbol>* incrementiveFollowSet(ParseRule* rule);
|
||||
std::vector<Symbol> incrementiveFollowSet(ParseRule* rule);
|
||||
virtual void closure(State* state);
|
||||
virtual void addStates(std::vector< State* >* stateSets, State* state, std::queue<State*>* toDo);
|
||||
int stateNum(State* state);
|
||||
|
||||
@@ -24,7 +24,7 @@ class State {
|
||||
bool const operator!=(const State &other);
|
||||
std::vector<ParseRule*>* getBasis();
|
||||
std::vector<ParseRule*>* getRemaining();
|
||||
std::vector<ParseRule*>* getTotal();
|
||||
std::vector<ParseRule*> getTotal();
|
||||
bool containsRule(ParseRule* rule);
|
||||
void addRuleCombineLookahead(ParseRule* rule);
|
||||
std::string toString();
|
||||
@@ -40,8 +40,7 @@ class State {
|
||||
std::vector<ParseRule*> remaining;
|
||||
private:
|
||||
std::vector<State*> parents;
|
||||
std::vector<ParseRule*> total;
|
||||
int number;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user