Line number reversion fixed & started on functions issue

Fixed issue where line number was reverted, causing if statements to not skip if false. Started working on problem causing functions to not execute correctly.
This commit is contained in:
sam-astro 2022-05-24 15:39:32 -04:00
parent 61a6d98e49
commit 75914d57b2

View File

@ -155,7 +155,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
// start -> FuncCall(0, x, OtherFunc(a)) // start -> FuncCall(0, x, OtherFunc(a))
// changeto -> 0, x, OtherFunc(a) // changeto -> 0, x, OtherFunc(a)
string insideFunArgs = unWrapVec(rangeInVec(expression, 0, (int)expression.size() - 1)); string insideFunArgs = betweenChars(expression, '(', ')');
vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')'); vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')');
vector<boost::any> funcArgs = VarValues(argList, variableValues); vector<boost::any> funcArgs = VarValues(argList, variableValues);
return ExecuteFunction(trim(split(expression, '(')[0]), funcArgs); return ExecuteFunction(trim(split(expression, '(')[0]), funcArgs);
@ -212,10 +212,10 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
// start -> FuncCall(0, x, OtherFunc(a)) // start -> FuncCall(0, x, OtherFunc(a))
// changeto -> 0, x, OtherFunc(a) // changeto -> 0, x, OtherFunc(a)
string insideFunArgs = unWrapVec(rangeInVec(expression, 0, (int)expression.size() - 1)); string insideFunArgs = betweenChars(expression, '(', ')');
vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')'); vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')');
vector<boost::any> funcArgs = VarValues(argList, variableValues); vector<boost::any> funcArgs = VarValues(argList, variableValues);
string returnVal = ExecuteFunction(trim(split(expression, '(')[0]), funcArgs); string returnVal = AnyAsString(ExecuteFunction(trim(split(expression, '(')[0]), funcArgs));
newExpression += returnVal; newExpression += returnVal;
} }
else if (split(name, '.')[0] == "ZS" && !inQuotes) else if (split(name, '.')[0] == "ZS" && !inQuotes)
@ -387,7 +387,7 @@ int varOperation(const vector<string>& str, unordered_map<string, boost::any>& v
return 1; return 1;
} }
boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unordered_map<string, boost::any>& variableValues) boost::any ProcessLine(const vector<vector<string>>& words, int& lineNum, unordered_map<string, boost::any>& variableValues)
{ {
// Check if the first two chars are '//', which would make it a comment // Check if the first two chars are '//', which would make it a comment
if (words.at(lineNum).at(0)[0] == '/' && words.at(lineNum).at(0)[1] == '/') if (words.at(lineNum).at(0)[0] == '/' && words.at(lineNum).at(0)[1] == '/')
@ -418,7 +418,7 @@ boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unorder
{ // Args provided, parse them first { // Args provided, parse them first
// start -> FuncCall(0, x, OtherFunc(a)) // start -> FuncCall(0, x, OtherFunc(a))
// changeto -> 0, x, OtherFunc(a) // changeto -> 0, x, OtherFunc(a)
string insideFunArgs = unWrapVec(rangeInVec(words.at(lineNum), 0, (int)words.at(lineNum).size() - 1)); string insideFunArgs = betweenChars(unWrapVec(words.at(lineNum)), '(', ')');
vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')'); vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')');
vector<boost::any> funcArgs = VarValues(argList, variableValues); vector<boost::any> funcArgs = VarValues(argList, variableValues);
ExecuteFunction(trim(split(words.at(lineNum).at(0), '(')[0]), funcArgs); ExecuteFunction(trim(split(words.at(lineNum).at(0), '(')[0]), funcArgs);
@ -494,14 +494,16 @@ boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unorder
} }
} }
for (int p = lineNum + 1; p < (int)words.size(); p++) lineNum += 1;
while (lineNum < (int)words.size())
{ {
numOfBrackets += countInVector(words.at(p), "{") - countInVector(words.at(p), "}"); numOfBrackets += countInVector(words.at(lineNum), "{") - countInVector(words.at(lineNum), "}");
if (numOfBrackets == 0) if (numOfBrackets == 0)
break; break;
whileContents.push_back(words.at(p)); whileContents.push_back(words.at(lineNum));
lineNum++;
} }
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))
@ -535,14 +537,15 @@ boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unorder
} }
} }
for (int p = lineNum + 1; p < (int)words.size(); p++) lineNum++;
while (lineNum < (int)words.size())
{ {
numOfBrackets += countInVector(words.at(p), "{") - countInVector(words.at(p), "}"); numOfBrackets += countInVector(words.at(lineNum), "{") - countInVector(words.at(lineNum), "}");
if (numOfBrackets == 0) if (numOfBrackets == 0)
break; break;
ifContents.push_back(words.at(p)); ifContents.push_back(words.at(lineNum));
lineNum++;
} }
lineNum = p;
ifContents = removeTabsWdArry(ifContents, 1); ifContents = removeTabsWdArry(ifContents, 1);
@ -572,14 +575,15 @@ boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unorder
} }
} }
for (int p = lineNum + 1; p < (int)words.size(); p++) lineNum++;
while (lineNum < (int)words.size())
{ {
numOfBrackets += countInVector(words.at(p), "{") - countInVector(words.at(p), "}"); numOfBrackets += countInVector(words.at(lineNum), "{") - countInVector(words.at(lineNum), "}");
if (numOfBrackets == 0) if (numOfBrackets == 0)
break; break;
elseContents.push_back(words.at(p)); elseContents.push_back(words.at(lineNum));
lineNum++;
} }
lineNum = p;
elseContents = removeTabsWdArry(elseContents, 1); elseContents = removeTabsWdArry(elseContents, 1);