Problem was actually in grammer, fixed it. Also made identical rules with different lookahead merge. Now just started on creating parse trees. Stopping for night.

This commit is contained in:
Nathan Braswell
2013-08-06 01:49:45 -04:00
parent 9460bacf1c
commit 680d978dcb
9 changed files with 136 additions and 40 deletions

View File

@@ -89,6 +89,20 @@ void ParseRule::setLookahead(std::vector<Symbol*>* lookahead) {
this->lookahead = lookahead;
}
void ParseRule::addLookahead(std::vector<Symbol*>* lookahead) {
for (std::vector<Symbol*>::size_type i = 0; i < lookahead->size(); i++) {
bool alreadyIn = false;
for (std::vector<Symbol*>::size_type j = 0; j < this->lookahead->size(); j++) {
if (*((*lookahead)[i]) == *((*(this->lookahead))[j])) {
alreadyIn = true;
break;
}
}
if (!alreadyIn)
this->lookahead->push_back((*lookahead)[i]);
}
}
std::vector<Symbol*>* ParseRule::getLookahead() {
return lookahead;
}