diff options
| Commit | 75993cc48f8e72f7aee4ddf857001dbfcd36f3ac (patch) | |
|---|---|---|
| Author | 2018-10-22 21:51:11 +0300 | |
| Committer | 2018-10-24 19:43:48 +0300 | |
| Files | fac6f5c70ddca8face58288a3affa219c6f0a53c /JSImpl/src | |
| IPL-75993cc48f8e72f7aee4ddf857001dbfcd36f3ac.tar IPL-75993cc48f8e72f7aee4ddf857001dbfcd36f3ac.tar.gz IPL-75993cc48f8e72f7aee4ddf857001dbfcd36f3ac.zip | ||
| Parent | bec327663790db67211262770c37da1a9ed5d76d (diff) | |
Fixed parsing of for loop
1 files changed, 18 insertions, 2 deletions
| -rw-r--r-- | JSImpl/src/Parser.cpp | 20 |
diff --git a/JSImpl/src/Parser.cpp b/JSImpl/src/Parser.cpp index a89e81c..97ad735 100644 --- a/JSImpl/src/Parser.cpp +++ b/JSImpl/src/Parser.cpp @@ -739,13 +739,13 @@ ExpressionPtr Parser::Block() if (Match(TokenType::LeftBrace)) { - if (Match(TokenType::RightBrace)) + if (!Match(TokenType::RightBrace)) { return BlockStatementsPrefix(); } else { - // TODO log error + // TODO log error - empty block? assert(false); return nullptr; } @@ -847,14 +847,30 @@ ExpressionPtr Parser::ForStatement() { if (Match(TokenType::For)) { + if (!Match(TokenType::LeftParen)) + { + assert(false); + } auto initializer = Expression(); if (!initializer) { initializer = VariableDefinition(); } + if (!Match(TokenType::Semicolon)) + { + assert(false); + } auto cond = Expression(); + if (!Match(TokenType::Semicolon)) + { + assert(false); + } auto iteration = Expression(); + if (!Match(TokenType::RightParen)) + { + assert(false); + } auto body = Statement(); return IPLMakeSharePtr<::ForStatement>(initializer, cond, iteration, body); } |
