mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Break and continue keywords are working
This commit is contained in:
@@ -985,6 +985,20 @@ static void forStmt(Parser* parser, Node** nodeHandle) {
|
||||
emitNodePath(nodeHandle, NODE_PATH_FOR, preClause, postClause, condition, thenPath, NULL);
|
||||
}
|
||||
|
||||
static void breakStmt(Parser* parser, Node** nodeHandle) {
|
||||
freeNode(*nodeHandle);
|
||||
emitNodePath(nodeHandle, NODE_PATH_BREAK, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
consume(parser, TOKEN_SEMICOLON, "Expected ';' at end of break statement");
|
||||
}
|
||||
|
||||
static void continueStmt(Parser* parser, Node** nodeHandle) {
|
||||
freeNode(*nodeHandle);
|
||||
emitNodePath(nodeHandle, NODE_PATH_CONTINUE, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
consume(parser, TOKEN_SEMICOLON, "Expected ';' at end of continue statement");
|
||||
}
|
||||
|
||||
//precedence functions
|
||||
static void expressionStmt(Parser* parser, Node** nodeHandle) {
|
||||
//BUGFIX: check for empty statements
|
||||
@@ -1043,6 +1057,18 @@ static void statement(Parser* parser, Node** nodeHandle) {
|
||||
return;
|
||||
}
|
||||
|
||||
//break
|
||||
if (match(parser, TOKEN_BREAK)) {
|
||||
breakStmt(parser, nodeHandle);
|
||||
return;
|
||||
}
|
||||
|
||||
//continue
|
||||
if (match(parser, TOKEN_CONTINUE)) {
|
||||
continueStmt(parser, nodeHandle);
|
||||
return;
|
||||
}
|
||||
|
||||
//default
|
||||
expressionStmt(parser, nodeHandle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user