mirror of
https://github.com/sam-astro/Z-Sharp.git
synced 2025-12-13 09:02:10 +00:00
Fix issues with if and while, also added an else statement
This commit is contained in:
parent
664c6de666
commit
572da33ee0
@ -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> elseParameters;
|
||||||
|
|
||||||
// vector<string> elseContents;
|
int numOfBrackets = 0;
|
||||||
|
for (int w = 1; w < (int)words.at(lineNum).size(); w++) {
|
||||||
|
if (count(words.at(lineNum).at(w), '{') != 0)
|
||||||
|
{
|
||||||
|
numOfBrackets = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// int numOfBrackets = 1;
|
for (int p = lineNum + 1; p < (int)words.size(); p++)
|
||||||
// while (lineNum < (int)words.size())
|
{
|
||||||
// {
|
numOfBrackets += countInVector(words.at(p), "{") - countInVector(words.at(p), "}");
|
||||||
// numOfBrackets += countInVector(words[lineNum], "{") - countInVector(words[lineNum], "}");
|
if (numOfBrackets == 0)
|
||||||
// if (numOfBrackets == 0)
|
break;
|
||||||
// break;
|
elseContents.push_back(words.at(p));
|
||||||
// elseContents.push_back("");
|
}
|
||||||
// for (int w = 0; w < (int)words[lineNum].size(); w++)
|
lineNum = p;
|
||||||
// {
|
|
||||||
// elseContents[(int)elseContents.size() - 1] += words[lineNum][w] + " ";
|
|
||||||
// }
|
|
||||||
// lineNum++;
|
|
||||||
// }
|
|
||||||
// elseContents = removeTabs(elseContents, 2);
|
|
||||||
|
|
||||||
// vector<vector<string>> innerWords;
|
elseContents = removeTabsWdArry(elseContents, 1);
|
||||||
// for (int i = 0; i < (int)elseContents.size(); i++)
|
|
||||||
// innerWords.push_back(split(elseContents[i], ' '));
|
|
||||||
|
|
||||||
// //Iterate through all lines in else statement
|
//Iterate through all lines in if statement
|
||||||
// for (int lineNum = 0; lineNum < (int)elseContents.size(); lineNum++)
|
for (int l = 0; l < (int)elseContents.size(); l++)
|
||||||
// {
|
{
|
||||||
// ProcessLine(innerWords, lineNum, variableValues);
|
boost::any returnVal = ProcessLine(elseContents, l, variableValues);
|
||||||
// }
|
if (!returnVal.empty())
|
||||||
// return nullType;
|
return returnVal;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
return nullType;
|
return nullType;
|
||||||
}
|
}
|
||||||
//// Gathers else statement contents
|
//// Gathers else statement contents
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user