diff --git a/Slang/Main.cpp b/Slang/Main.cpp index 2de0804..3706801 100644 --- a/Slang/Main.cpp +++ b/Slang/Main.cpp @@ -315,6 +315,42 @@ int ProcessLine(vector> words, int l, vector variables, v } } } + // Gathers if statement contents + if (words[l][0] == "if") + { + vector ifContents; + vector 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> 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; } @@ -427,6 +463,10 @@ int main(int argc, char* argv[]) std::stringstream scriptString; scriptString << t.rdbuf(); + while (true) { + system("pause"); + break; + } parseSlang(scriptString.str()); /*if (argc >= 2) diff --git a/Slang/Slang.vcxproj b/Slang/Slang.vcxproj index 122355c..da7153a 100644 --- a/Slang/Slang.vcxproj +++ b/Slang/Slang.vcxproj @@ -88,6 +88,7 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + OldStyle Console diff --git a/Slang/script.sl b/Slang/script.sl index 0569553..de070c5 100644 --- a/Slang/script.sl +++ b/Slang/script.sl @@ -2,11 +2,34 @@ int x = 1 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 - while x < 10 + while x < 10000 { + g /= 2 + h /= 2 + i /= 2 + g /= 2 x += 1 - print x + if x > 0 + { + print x + } } x += 1 print x