Fix issues with if and while, also added an else statement

This commit is contained in:
sam-astro 2022-05-23 08:08:43 -04:00 committed by GitHub
parent 664c6de666
commit 572da33ee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -477,6 +477,7 @@ boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unorder
break; break;
whileContents.push_back(words.at(p)); whileContents.push_back(words.at(p));
} }
lineNum = p;
whileContents = removeTabsWdArry(whileContents, 1); whileContents = removeTabsWdArry(whileContents, 1);
while (BooleanLogic(whileParameters.at(0), whileParameters.at(1), whileParameters.at(2), variableValues)) while (BooleanLogic(whileParameters.at(0), whileParameters.at(1), whileParameters.at(2), variableValues))
@ -517,6 +518,8 @@ boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unorder
break; break;
ifContents.push_back(words.at(p)); ifContents.push_back(words.at(p));
} }
lineNum = p;
ifContents = removeTabsWdArry(ifContents, 1); ifContents = removeTabsWdArry(ifContents, 1);
if (BooleanLogic(ifParameters.at(0), ifParameters.at(1), ifParameters.at(2), variableValues)) if (BooleanLogic(ifParameters.at(0), ifParameters.at(1), ifParameters.at(2), variableValues))
@ -529,39 +532,43 @@ boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unorder
return returnVal; return returnVal;
} }
} }
//else if (words.size() > lineNum + 1) else if (words.size() > lineNum + 1)
// if (words[lineNum + 1][0] == "else") {
// { if (words[lineNum + 1].at(0) == "else")
// lineNum += 1; {
vector<vector<string>> elseContents;
// vector<string> elseContents; vector<string> elseParameters;
// int numOfBrackets = 1; int numOfBrackets = 0;
// while (lineNum < (int)words.size()) for (int w = 1; w < (int)words.at(lineNum).size(); w++) {
// { if (count(words.at(lineNum).at(w), '{') != 0)
// numOfBrackets += countInVector(words[lineNum], "{") - countInVector(words[lineNum], "}"); {
// if (numOfBrackets == 0) numOfBrackets = 1;
// break; break;
// elseContents.push_back(""); }
// for (int w = 0; w < (int)words[lineNum].size(); w++) }
// {
// elseContents[(int)elseContents.size() - 1] += words[lineNum][w] + " "; for (int p = lineNum + 1; p < (int)words.size(); p++)
// } {
// lineNum++; numOfBrackets += countInVector(words.at(p), "{") - countInVector(words.at(p), "}");
// } if (numOfBrackets == 0)
// elseContents = removeTabs(elseContents, 2); break;
elseContents.push_back(words.at(p));
// vector<vector<string>> innerWords; }
// for (int i = 0; i < (int)elseContents.size(); i++) lineNum = p;
// innerWords.push_back(split(elseContents[i], ' '));
elseContents = removeTabsWdArry(elseContents, 1);
// //Iterate through all lines in else statement
// for (int lineNum = 0; lineNum < (int)elseContents.size(); lineNum++) //Iterate through all lines in if statement
// { for (int l = 0; l < (int)elseContents.size(); l++)
// ProcessLine(innerWords, lineNum, variableValues); {
// } boost::any returnVal = ProcessLine(elseContents, l, variableValues);
// return nullType; if (!returnVal.empty())
// } return returnVal;
}
}
}
return nullType; return nullType;
} }
//// Gathers else statement contents //// Gathers else statement contents