Fixed some bugs in Parser::firstSet and added a bit of caching. It still doesn't work quite right, though, there's some problem with nullable left recursion. However, it's better than it was, and I need to go to bed. More work later.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "Table.h"
|
||||
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
@@ -36,8 +37,13 @@ class Parser {
|
||||
void importTable(char* tableData);
|
||||
|
||||
protected:
|
||||
std::vector<Symbol>* firstSet(Symbol token);
|
||||
std::vector<Symbol>* firstSet(Symbol token, std::vector<Symbol> avoidList);
|
||||
std::vector<Symbol> firstSet(Symbol token, std::vector<Symbol> avoidList = std::vector<Symbol>(), bool addNewTokens = true);
|
||||
bool isNullable(Symbol token);
|
||||
bool isNullableHelper(Symbol token, std::set<Symbol> done);
|
||||
|
||||
std::map<Symbol, std::vector<Symbol>> tokenFirstSet;
|
||||
std::map<Symbol, bool> tokenNullable;
|
||||
|
||||
std::vector<Symbol>* incrementiveFollowSet(ParseRule* rule);
|
||||
virtual void closure(State* state);
|
||||
virtual void addStates(std::vector< State* >* stateSets, State* state, std::queue<State*>* toDo);
|
||||
@@ -65,4 +71,4 @@ class Parser {
|
||||
NodeTree<Symbol>* reduceTreeCombine(Symbol newSymbol, std::vector<Symbol> &symbols);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user