From 75993cc48f8e72f7aee4ddf857001dbfcd36f3ac Mon Sep 17 00:00:00 2001 From: Dimitar Trendafilov Date: Mon, 22 Oct 2018 21:51:11 +0300 Subject: Fixed parsing of for loop --- JSImpl/src/Parser.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'JSImpl/src/Parser.cpp') 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); } -- cgit v1.3.1-23-gd82d