mirror of
https://github.com/sam-astro/Z-Sharp.git
synced 2025-12-13 09:02:10 +00:00
Update Main.cpp
This commit is contained in:
parent
49c26219fc
commit
29f4ad704f
@ -73,6 +73,11 @@ string StringRaw(string str)
|
|||||||
return withoutQuotes;
|
return withoutQuotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string Quoted(string str)
|
||||||
|
{
|
||||||
|
return "\"" + str + "\"";
|
||||||
|
}
|
||||||
|
|
||||||
string GetVariableValue(string varName, vector<string>& variables, vector<string>& variableVals)
|
string GetVariableValue(string varName, vector<string>& variables, vector<string>& variableVals)
|
||||||
{
|
{
|
||||||
string typ = "string";
|
string typ = "string";
|
||||||
@ -127,7 +132,8 @@ string EvalExpression(string expression, vector<string>& variables, vector<strin
|
|||||||
expression = trim(expression);
|
expression = trim(expression);
|
||||||
cout << "EXPRESSION: " << expression << endl;
|
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);
|
return GetVariableValue(expression, variables, variableVals);
|
||||||
|
|
||||||
string newExpression = "";
|
string newExpression = "";
|
||||||
@ -166,7 +172,6 @@ string EvalExpression(string expression, vector<string>& variables, vector<strin
|
|||||||
}
|
}
|
||||||
if (addStrings)
|
if (addStrings)
|
||||||
{
|
{
|
||||||
string newStr = "";
|
|
||||||
inQuotes = false;
|
inQuotes = false;
|
||||||
string withoutParenthesis = "";
|
string withoutParenthesis = "";
|
||||||
for (int i = 0; i < (int)newExpression.size(); i++)
|
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];
|
withoutParenthesis += newExpression[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "NewSTRING = " << withoutParenthesis << endl;
|
cout << "NewSTRING = " << Quoted(withoutParenthesis) << endl;
|
||||||
return withoutParenthesis;
|
return Quoted(withoutParenthesis);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return to_string(evaluate(newExpression));
|
return to_string(evaluate(newExpression));
|
||||||
@ -514,4 +519,4 @@ int main(int argc, char* argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}*/
|
}*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user