Skip to content

Commit

Permalink
update: fix for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohith-Raju committed Apr 11, 2024
1 parent 3b9df60 commit f63b475
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Statement *Parser::statement() {
return ifStatement();
if (match(WHILE))
return whileStatement();
if (match(FOR))
return forStatement();
if (match(LEFT_BRACE))
return new Block(blockStatement());
return expressionStatement();
Expand All @@ -67,9 +69,9 @@ std::vector<Statement *> Parser::blockStatement() {
}

Statement *Parser::ifStatement() {
consume(LEFT_PAREN, "expected ( after if");
consume(LEFT_PAREN, "Expected ( after if");
Expr *expr = expression();
consume(RIGHT_PAREN, "expected ) after if statement");
consume(RIGHT_PAREN, "Expected ) after if statement");

Statement *thenBranch = statement();

Expand Down Expand Up @@ -105,6 +107,8 @@ Statement *Parser::forStatement() {
else
condition = expression();

consume(SEMICOLON, "Expected ; after condition clause");

Expr *increment;
if (match(SEMICOLON))
increment = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion test/lib
Submodule lib updated 1 files
+4 −2 docs/reference/testing.md

0 comments on commit f63b475

Please sign in to comment.