Fixed the bug! Probabally other bugs too.

This commit is contained in:
Nathan Braswell
2013-08-26 15:37:49 -04:00
parent 84274ed138
commit d1f2ba5fc8
5 changed files with 17 additions and 30 deletions

View File

@@ -68,6 +68,8 @@ void Table::add(int stateNum, Symbol* tranSymbol, ParseAction* action) {
//std::cout << "State: " << stateNum << " Conflict between old: " << (*(table[stateNum]))[symbolIndex]->toString() << " and new: " << action->toString() << " on " << tranSymbol->toString() << std::endl;
//Check to see if this action is already in the list
//(*(table[stateNum]))[symbolIndex]->push_back(action);
bool alreadyIn = false;
for (std::vector<ParseAction*>::size_type i = 0; i < (*(table[stateNum]))[symbolIndex]->size(); i++)
if (*((*((*(table[stateNum]))[symbolIndex]))[i]) == *action)
@@ -104,16 +106,19 @@ std::vector<ParseAction*>* Table::get(int state, Symbol* token) {
return NULL;
}
//std::cout << "Get for state: " << state << ", and Symbol: " << token->toString() << std::endl;
std::cout << "Get for state: " << state << ", and Symbol: " << token->toString() << std::endl;
if (state < 0 || state >= table.size()) {
std::cout << "State bad: " << state << std::endl;
return NULL;
}
std::vector<ParseAction*>* action = NULL;
if (symbolIndex < 0 || symbolIndex >= table[state]->size()) {
std::cout << "Symbol bad for this state: " << token->toString() << std::endl;
return NULL;
std::cout << "Symbol bad for this state: " << token->toString() << ". This is a reject." << std::endl;
} else {
action = (*(table[state]))[symbolIndex];
}
std::vector<ParseAction*>* action = (*(table[state]))[symbolIndex];
//This is the accepting state, as it is the 1th's state's reduction on EOF, which is 0 in the symbolIndexVec
//(This assumes singular goal assignment, a simplification for now)