Checks for re-intitialization

This commit is contained in:
sam-astro 2021-12-29 17:38:00 -05:00
parent e7d8f31851
commit d11b8a0c56
2 changed files with 23 additions and 3 deletions

View File

@ -474,6 +474,18 @@ int ProcessLine(vector<vector<string>> words, int lineNum, vector<string>& varia
{
if (words[lineNum][0] == types[t])
{
//Checks if it is a re-init of an existing variable
for (int v = 0; v < (int)variables.size(); v++)
{
if (words[lineNum][1] == split(variables[v], ' ')[1])
{
vector<string> inputs = { words[lineNum][1], words[lineNum][2], words[lineNum][3] };
evalEqu(inputs, variables, variableValues);
return 0;
}
}
//Checks if it is variable
variables.push_back(words[lineNum][0] + " " + words[lineNum][1]);
variableValues.push_back(GetRealValue((string)words[lineNum][3], variables, variableValues));
@ -481,7 +493,7 @@ int ProcessLine(vector<vector<string>> words, int lineNum, vector<string>& varia
return 0;
}
}
// Second, iterate all existing local variable names
// Second, iterate all existing variable names
for (int v = 0; v < (int)variables.size(); v++)
{
if (words[lineNum][0] == split(variables[v], ' ')[1])

View File

@ -13,6 +13,8 @@ void Next(string in, string sin)
void Main(string input, int in2)
{
int x = 0
int a = 0
int b = 1
@ -21,14 +23,20 @@ void Main(string input, int in2)
int k = 0
while x < 1
while x < 100
{
k = a
k += b
a = b
b = k
string str = x
str += "::"
str += k
print k
x += 10
print str
}
Next "seen", "bop"
}