I have been posting a bit about my current side project, a scripting language interpreter. I have gotten past my getline error I talked about in a previous post and am now trying to get the results from the script. I created a map of all the labels in the script with a list of every operation that happens under the list. like this map<string, list<Operation *>>. When ever I try to access the list at a given key I am returned with a bad access error. I try to access the list in the map like this
Operation *currentOP;
std::list<Operation *> *currentLst;
std::map<std::string,std::list<Operation *> >::iterator labelPtr;
labelPtr = this->labelOPMap.find(currentLabel);
*currentLst = labelPtr->second; // Problem Here
This is how I am pushing the list onto the map
if(this->hasLabel(programLine)) {
// push the label and OPlst onto the map
labelOPMap[label] = *OPlst;
// Get the new label
label = this->getLabel(this->positionOfChar('[',programLine),programLine);
if(!this->labelExist(label)) {
// Clip the label off the string
programLine = programLine.substr(this->positionOfChar(']',programLine)+1);
// Create a new Operation List
OPlst = new std::list<Operation *>;
}
}
// Parse the current line of the document and return an operation object
OP = this->ProcessLine(programLine);
// push the Operation onto the list
OPlst->push_back(OP);
Does anyone know why I would be getting an bad access error. I am not the best with pointers either.