Update Main.cpp

This commit is contained in:
sam-astro 2022-01-01 23:46:31 -05:00 committed by GitHub
parent 49c26219fc
commit 29f4ad704f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,6 +73,11 @@ string StringRaw(string str)
return withoutQuotes;
}
string Quoted(string str)
{
return "\"" + str + "\"";
}
string GetVariableValue(string varName, vector<string>& variables, vector<string>& variableVals)
{
string typ = "string";
@ -127,7 +132,8 @@ string EvalExpression(string expression, vector<string>& variables, vector<strin
expression = trim(expression);
cout << "EXPRESSION: " << expression << endl;
if (count(expression, '+') == 0 && count(expression, '-') == 0 && count(expression, '*') == 0 && count(expression, '/') == 0)
// If no operations are applied, then return self
if (count(expression, '+') == 0 && count(expression, '-') == 0 && count(expression, '*') == 0 && count(expression, '/') == 0 && count(expression, '(') == 0 && count(expression, '^') == 0)
return GetVariableValue(expression, variables, variableVals);
string newExpression = "";
@ -166,7 +172,6 @@ string EvalExpression(string expression, vector<string>& variables, vector<strin
}
if (addStrings)
{
string newStr = "";
inQuotes = false;
string withoutParenthesis = "";
for (int i = 0; i < (int)newExpression.size(); i++)
@ -182,8 +187,8 @@ string EvalExpression(string expression, vector<string>& variables, vector<strin
withoutParenthesis += newExpression[i];
}
cout << "NewSTRING = " << withoutParenthesis << endl;
return withoutParenthesis;
cout << "NewSTRING = " << Quoted(withoutParenthesis) << endl;
return Quoted(withoutParenthesis);
}
else
return to_string(evaluate(newExpression));
@ -514,4 +519,4 @@ int main(int argc, char* argv[])
return 1;
}*/
return 0;
}
}