Fixed the bug! Probabally other bugs too.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user