mirror of
https://github.com/sam-astro/Z-Sharp.git
synced 2025-12-13 09:02:10 +00:00
Added if statements
This commit is contained in:
parent
95966cfc74
commit
68e0ed31c0
@ -315,6 +315,42 @@ int ProcessLine(vector<vector<string>> words, int l, vector<string> variables, v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Gathers if statement contents
|
||||||
|
if (words[l][0] == "if")
|
||||||
|
{
|
||||||
|
vector<string> ifContents;
|
||||||
|
vector<string> ifParameters;
|
||||||
|
|
||||||
|
for (int w = 1; w < (int)words[l].size(); w++)
|
||||||
|
ifParameters.push_back(words[l][w]);
|
||||||
|
|
||||||
|
int numOfBrackets = 1;
|
||||||
|
for (int p = l + 2; p < (int)words.size(); p++)
|
||||||
|
{
|
||||||
|
numOfBrackets += countInVector(words[p], "{") - countInVector(words[p], "}");
|
||||||
|
if (numOfBrackets == 0)
|
||||||
|
break;
|
||||||
|
ifContents.push_back("");
|
||||||
|
for (int w = 0; w < (int)words[p].size(); w++)
|
||||||
|
{
|
||||||
|
ifContents[(int)ifContents.size() - 1] += words[p][w] + " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ifContents = removeTabs(ifContents, 1);
|
||||||
|
|
||||||
|
vector<vector<string>> words;
|
||||||
|
for (int i = 0; i < (int)ifContents.size(); i++)
|
||||||
|
words.push_back(split(ifContents[i], ' '));
|
||||||
|
|
||||||
|
if (BooleanLogic(ifParameters[0], ifParameters[1], ifParameters[2], variables, variableValues))
|
||||||
|
{
|
||||||
|
//Iterate through all lines in while loop
|
||||||
|
for (int l = 0; l < (int)ifContents.size(); l++)
|
||||||
|
{
|
||||||
|
ProcessLine(words, l, variables, variableValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -427,6 +463,10 @@ int main(int argc, char* argv[])
|
|||||||
std::stringstream scriptString;
|
std::stringstream scriptString;
|
||||||
scriptString << t.rdbuf();
|
scriptString << t.rdbuf();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
system("pause");
|
||||||
|
break;
|
||||||
|
}
|
||||||
parseSlang(scriptString.str());
|
parseSlang(scriptString.str());
|
||||||
|
|
||||||
/*if (argc >= 2)
|
/*if (argc >= 2)
|
||||||
|
|||||||
@ -88,6 +88,7 @@
|
|||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
|||||||
@ -2,11 +2,34 @@ int x = 1
|
|||||||
|
|
||||||
void Main(input)
|
void Main(input)
|
||||||
{
|
{
|
||||||
|
string c = 8
|
||||||
|
string d = 8
|
||||||
|
string e = 8
|
||||||
|
string f = 8
|
||||||
|
string g = 8
|
||||||
|
string h = 8
|
||||||
|
string i = 8
|
||||||
|
string j = 8
|
||||||
|
c /= 2
|
||||||
|
d /= 2
|
||||||
|
e /= 2
|
||||||
|
f /= 2
|
||||||
|
g /= 2
|
||||||
|
h /= 2
|
||||||
|
i /= 2
|
||||||
|
g /= 2
|
||||||
print input
|
print input
|
||||||
while x < 10
|
while x < 10000
|
||||||
{
|
{
|
||||||
|
g /= 2
|
||||||
|
h /= 2
|
||||||
|
i /= 2
|
||||||
|
g /= 2
|
||||||
x += 1
|
x += 1
|
||||||
print x
|
if x > 0
|
||||||
|
{
|
||||||
|
print x
|
||||||
|
}
|
||||||
}
|
}
|
||||||
x += 1
|
x += 1
|
||||||
print x
|
print x
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user