Fix loops
This commit is contained in:
@@ -249,20 +249,17 @@ void Interpreter::executeCode(vector<Token> tokens) {
|
||||
if (skipScope > 0) {
|
||||
int braceCount = 0;
|
||||
while (i < tokens.size()) {
|
||||
int braceCount = 0;
|
||||
while (i < tokens.size()) {
|
||||
if (tokens[i].keyword == keywords::OBRAC) {
|
||||
braceCount ++;
|
||||
} else if (tokens[i].keyword == keywords::CBRAC) {
|
||||
if (braceCount == 0) {
|
||||
skipScope --;
|
||||
break;
|
||||
} else {
|
||||
braceCount --;
|
||||
}
|
||||
if (tokens[i].keyword == keywords::OBRAC) {
|
||||
braceCount ++;
|
||||
} else if (tokens[i].keyword == keywords::CBRAC) {
|
||||
if (braceCount == 0) {
|
||||
skipScope --;
|
||||
break;
|
||||
} else {
|
||||
braceCount --;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (repeatScope > 0) {
|
||||
@@ -414,10 +411,18 @@ void Interpreter::executeCode(vector<Token> tokens) {
|
||||
loop = tokenIndex - 2 - lengthOfLine;
|
||||
repeatScope ++;
|
||||
log.debug("While loop condition is true, will skip back to " + to_string(loop));
|
||||
} else if (!get<bool>(tokens[i].value.value)) {
|
||||
int braceLevel = 0;
|
||||
while (++i < tokens.size()) {
|
||||
if (tokens[i].keyword == keywords::OBRAC) braceLevel ++;
|
||||
else if (tokens[i].keyword == keywords::CBRAC) {
|
||||
if (braceLevel == 0) break;
|
||||
braceLevel --;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
log.debug("Condition is false, skipping scope");
|
||||
skipScope ++;
|
||||
return;
|
||||
syntaxError.generalError("Achievement get: How did we get here?");
|
||||
}
|
||||
} else {
|
||||
if (tokens[i].keyword == keywords::VALUE && tokens[i].value.type == valtype::STR && variables.find(get<string>(tokens[i].value.value)) != variables.end()) {
|
||||
|
Reference in New Issue
Block a user