mirror of
https://github.com/sam-astro/Z-Sharp.git
synced 2025-12-10 15:52:12 +00:00
Update Main.cpp
Disable for comment checking, make `ZS.` check safer, allow more variables to be initialized outside of functions (global), let people set the global builtin variable of `EXIT_WHEN_DONE` to true or false, depending if they are a developer and want to leave the console window open after the program finishes.
This commit is contained in:
parent
bfc3c4d727
commit
89392bc34d
@ -391,9 +391,9 @@ int varOperation(const vector<string>& str, unordered_map<string, boost::any>& v
|
||||
|
||||
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
|
||||
if (startsWith(words.at(lineNum).at(0), "//"))
|
||||
return nullType;
|
||||
//// Check if the first two chars are '//', which would make it a comment
|
||||
//if (startsWith(words.at(lineNum).at(0), "//"))
|
||||
// return nullType;
|
||||
|
||||
// If print statement (deprecated, now use ZS.System.Print() function)
|
||||
else if (words.at(lineNum).at(0) == "print")
|
||||
@ -407,7 +407,7 @@ boost::any ProcessLine(const vector<vector<string>>& words, int& lineNum, unorde
|
||||
return EvalExpression(unWrapVec(vector<string>(words.at(lineNum).begin() + 1, words.at(lineNum).end())), variableValues);
|
||||
|
||||
// Check if it is ZS Builtin function
|
||||
else if (words.at(lineNum).at(0)[0] == 'Z' && words.at(lineNum).at(0)[1] == 'S' && words.at(lineNum).at(0)[2] == '.')
|
||||
else if (startsWith(words.at(lineNum).at(0), "ZS."))
|
||||
return EvalExpression(unWrapVec(words.at(lineNum)), variableValues);
|
||||
|
||||
// Check if it is function
|
||||
@ -657,7 +657,7 @@ boost::any ExecuteFunction(const string& functionName, const vector<boost::any>&
|
||||
{
|
||||
variableValues[funcArgs[i]] = inputVarVals[i];
|
||||
#if DEVELOPER_MESSAGES == true
|
||||
cout << functionName + " \x1B[33m" << funcArgs[i] << " == " << AnyAsString(inputVarVals[i]) << "\033[0m\t\t" << endl;
|
||||
cout << "in " << functionName + " " << funcArgs[i] << " == " << AnyAsString(inputVarVals[i]) << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -803,26 +803,34 @@ int parseZSharp(string script)
|
||||
InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
||||
#endif
|
||||
}
|
||||
else if (words.at(lineNum).at(0) == "int") {
|
||||
globalVariableValues[words.at(lineNum).at(1)] = stoi(words.at(lineNum).at(3));
|
||||
#if DEVELOPER_MESSAGES == true
|
||||
InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
||||
#endif
|
||||
|
||||
// Iterate through all types to see if line inits or
|
||||
// re-inits a variable then store it with it's value
|
||||
else if (countInVector(types, trim(words.at(lineNum).at(0))) > 0)
|
||||
{
|
||||
//cout << words.at(lineNum).at(1) << "=" << unWrapVec(slice(words.at(lineNum), 3, -1)) << "=" << AnyAsString(EvalExpression(unWrapVec(slice(words.at(lineNum), 3, -1)), variableValues)) << endl;
|
||||
globalVariableValues[words.at(lineNum).at(1)] = EvalExpression(unWrapVec(slice(words.at(lineNum), 3, -1)), variableValues);
|
||||
}
|
||||
else if (words.at(lineNum).at(0) == "float") {
|
||||
globalVariableValues[words.at(lineNum).at(1)] = stof(words.at(lineNum).at(3));
|
||||
#if DEVELOPER_MESSAGES == true
|
||||
InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
||||
#endif
|
||||
}
|
||||
else if (words.at(lineNum).at(0) == "bool") {
|
||||
globalVariableValues[words.at(lineNum).at(1)] = stob(words.at(lineNum).at(3));
|
||||
#if DEVELOPER_MESSAGES == true
|
||||
InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
||||
#endif
|
||||
}
|
||||
/*else
|
||||
LogWarning("unrecognized type \'" + words.at(lineNum).at(0) + "\' on line: " + to_string(lineNum));*/
|
||||
// else if (words.at(lineNum).at(0) == "int") {
|
||||
// globalVariableValues[words.at(lineNum).at(1)] = stoi(words.at(lineNum).at(3));
|
||||
//#if DEVELOPER_MESSAGES == true
|
||||
// InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
||||
//#endif
|
||||
// }
|
||||
// else if (words.at(lineNum).at(0) == "float") {
|
||||
// globalVariableValues[words.at(lineNum).at(1)] = stof(words.at(lineNum).at(3));
|
||||
//#if DEVELOPER_MESSAGES == true
|
||||
// InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
||||
//#endif
|
||||
// }
|
||||
// else if (words.at(lineNum).at(0) == "bool") {
|
||||
// globalVariableValues[words.at(lineNum).at(1)] = stob(words.at(lineNum).at(3));
|
||||
//#if DEVELOPER_MESSAGES == true
|
||||
// InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
||||
//#endif
|
||||
// }
|
||||
else
|
||||
LogWarning("unrecognized type \'" + words.at(lineNum).at(0) + "\' on line: " + to_string(lineNum));
|
||||
}
|
||||
}
|
||||
|
||||
@ -941,6 +949,12 @@ int main(int argc, char* argv[])
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (AnyAsBool(GetVariableValue("EXIT_WHEN_DONE", globalVariableValues)) == false)
|
||||
{
|
||||
cout << "Press Enter to Continue";
|
||||
cin.ignore();
|
||||
exit(1);
|
||||
}
|
||||
#endif // Else exit automatically
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user