From aa8267dcaec6d62242bdf04c9dab25d7e70af87a Mon Sep 17 00:00:00 2001 From: Anna Antipina Date: Wed, 21 Feb 2024 18:26:39 +0300 Subject: [PATCH] Title: Fix if-else-while-do-for-body parsing Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/I92RBV Description: fix if-scope body parsing if it is on the next line and is not marked with braces (also for else, while, doWhile, for body) Test: ${ARK_SOURCE_DIR}/tests/tests-u-runner/runner.sh ${ARK_SOURCE_DIR} --ets-runtime --build-dir="${ARK_BUILD_DIR}" --heap-verifier="fail_on_verification:pre:into:before_g1_concurrent:post" --timeout=30 --force-generate --test-file BlockStatements.ets Signed-off-by: Anna Antipina Signed-off-by: Bolshov Maxim --- ets2panda/parser/parserImpl.h | 11 +- ets2panda/parser/statementParser.cpp | 145 +- .../ets/generic_arrayaslist-expected.txt | 681 ++++---- .../compiler/ets/union_types_5-expected.txt | 812 ++++----- .../parser/ets/AccessBinaryTrees-expected.txt | 388 +++-- .../parser/ets/AccessFannkuch-expected.txt | 1447 +++++++++-------- .../test/parser/ets/AccessNSieve-expected.txt | 161 +- .../parser/ets/BitopsNSieveBits-expected.txt | 271 +-- ets2panda/test/parser/ets/break-expected.txt | 27 +- .../test/parser/ets/continue-expected.txt | 27 +- .../parser/ets/forofUnboxing-expected.txt | 47 +- .../parser/ets/generic_function-expected.txt | 222 +-- ets2panda/test/parser/ets/if-expected.txt | 1416 +++++++++------- ets2panda/test/parser/ets/ifs-expected.txt | 414 +++-- .../test/parser/ets/instanceof-expected.txt | 476 +++--- .../ets/labeledDoWhileStatement-expected.txt | 365 +++-- .../ets/labeledForStatement-expected.txt | 804 ++++----- .../ets/labeledSwitchStatement-expected.txt | 505 +++--- .../ets/labeledWhileStatement-expected.txt | 1024 ++++++------ ets2panda/test/parser/ets/loops-expected.txt | 692 ++++---- ets2panda/test/parser/ets/return-expected.txt | 27 +- ets2panda/test/parser/js/test-if-expected.txt | 1002 +++++++----- .../js/test-labelled-statement-expected.txt | 168 +- ets2panda/test/parser/ts/test-if-expected.txt | 234 ++- .../test/runtime/ets/BlockStatements.ets | 66 + 25 files changed, 6375 insertions(+), 5057 deletions(-) create mode 100644 ets2panda/test/runtime/ets/BlockStatements.ets diff --git a/ets2panda/parser/parserImpl.h b/ets2panda/parser/parserImpl.h index adf31834c6..0f8b435d86 100644 --- a/ets2panda/parser/parserImpl.h +++ b/ets2panda/parser/parserImpl.h @@ -261,6 +261,7 @@ protected: std::tuple ParseForInOf(ir::AstNode *initNode, ExpressionParseFlags exprFlags, bool isAwait); + std::tuple ParseInitOrLeftNode(VariableParsingFlags varFlags, bool isAwait); std::tuple ParseForUpdate(bool isAwait); ir::SwitchCaseStatement *ParseSwitchCaseStatement(bool *seenDefault); virtual ir::Expression *ParseCatchParam(); @@ -350,9 +351,11 @@ protected: ArenaVector ParseStatementList(StatementParsingFlags flags = StatementParsingFlags::ALLOW_LEXICAL); virtual ir::Statement *ParseAssertStatement(); virtual void ValidateLabeledStatement(lexer::TokenType type); - ir::BlockStatement *ParseBlockStatement(); + ir::Statement *ParseStatementBody(StatementParsingFlags flags); + ir::BlockStatement *ParseBlockStatement(bool inBraces = true, + StatementParsingFlags flags = StatementParsingFlags::NONE); ir::EmptyStatement *ParseEmptyStatement(); - ir::Statement *ParseForStatement(); + ir::Statement *ParseForStatement(StatementParsingFlags flags = StatementParsingFlags::NONE); ir::IfStatement *ParseIfStatement(); virtual ir::Statement *ParseFunctionStatement(StatementParsingFlags flags); // NOLINTNEXTLINE(google-default-arguments) @@ -367,8 +370,8 @@ protected: ir::Statement *ParseLetStatement(StatementParsingFlags flags); ir::BreakStatement *ParseBreakStatement(); ir::ContinueStatement *ParseContinueStatement(); - ir::DoWhileStatement *ParseDoWhileStatement(); - ir::WhileStatement *ParseWhileStatement(); + ir::DoWhileStatement *ParseDoWhileStatement(StatementParsingFlags flags = StatementParsingFlags::NONE); + ir::WhileStatement *ParseWhileStatement(StatementParsingFlags flags = StatementParsingFlags::NONE); ir::SwitchStatement *ParseSwitchStatement(); ir::ReturnStatement *ParseReturnStatement(); ir::Statement *ParseExpressionStatement(StatementParsingFlags flags = StatementParsingFlags::NONE); diff --git a/ets2panda/parser/statementParser.cpp b/ets2panda/parser/statementParser.cpp index 5f652a1f39..33a3b538f1 100644 --- a/ets2panda/parser/statementParser.cpp +++ b/ets2panda/parser/statementParser.cpp @@ -112,16 +112,16 @@ ir::Statement *ParserImpl::ParseStatement(StatementParsingFlags flags) return ParseIfStatement(); } case lexer::TokenType::KEYW_DO: { - return ParseDoWhileStatement(); + return ParseDoWhileStatement(flags); } case lexer::TokenType::KEYW_FOR: { - return ParseForStatement(); + return ParseForStatement(flags); } case lexer::TokenType::KEYW_TRY: { return ParseTryStatement(); } case lexer::TokenType::KEYW_WHILE: { - return ParseWhileStatement(); + return ParseWhileStatement(flags); } case lexer::TokenType::KEYW_BREAK: { return ParseBreakStatement(); @@ -398,22 +398,45 @@ ir::Statement *ParserImpl::ParseAssertStatement() void ParserImpl::ValidateLabeledStatement([[maybe_unused]] lexer::TokenType type) {} -ir::BlockStatement *ParserImpl::ParseBlockStatement() +ir::BlockStatement *ParserImpl::ParseBlockStatement(bool inBraces, StatementParsingFlags flags) { - ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_BRACE); + ASSERT(!inBraces || lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_BRACE); lexer::SourcePosition startLoc = lexer_->GetToken().Start(); - lexer_->NextToken(); - auto statements = ParseStatementList(); + if (inBraces) { + lexer_->NextToken(); + } + + auto statementToken = lexer_->GetToken().Type(); + + auto statements = [this, inBraces, flags]() { + if (inBraces) { + if (flags == StatementParsingFlags::NONE) { + return ParseStatementList(); + } + return ParseStatementList(flags); + } + auto statement = ParseStatement(flags); + ArenaVector res(Allocator()->Adapter()); + res.push_back(statement); + return res; + }(); - if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { + if (inBraces && lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { ThrowSyntaxError("Expected a '}'"); } + if (!inBraces && statementToken != lexer::TokenType::PUNCTUATOR_SEMI_COLON && + lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_BRACE) { + ThrowSyntaxError("Lexical declaration is not allowed in single statement context"); + } + auto *blockNode = AllocNode(Allocator(), std::move(statements)); blockNode->SetRange({startLoc, lexer_->GetToken().End()}); - lexer_->NextToken(); + if (inBraces) { + lexer_->NextToken(); + } return blockNode; } @@ -529,13 +552,13 @@ ir::ContinueStatement *ParserImpl::ParseContinueStatement() return continueStatement; } -ir::DoWhileStatement *ParserImpl::ParseDoWhileStatement() +ir::DoWhileStatement *ParserImpl::ParseDoWhileStatement(StatementParsingFlags flags) { IterationContext iterCtx(&context_); lexer::SourcePosition startLoc = lexer_->GetToken().Start(); lexer_->NextToken(); - ir::Statement *body = ParseStatement(); + ir::Statement *body = ParseStatementBody(flags); if (lexer_->GetToken().Type() != lexer::TokenType::KEYW_WHILE) { ThrowSyntaxError("Missing 'while' keyword in a 'DoWhileStatement'"); @@ -844,36 +867,24 @@ std::tuple ParserImpl::ParseForUpdate(bool i return {rightNode, updateNode}; } -ir::Statement *ParserImpl::ParseForStatement() +ir::Statement *ParserImpl::ParseStatementBody(StatementParsingFlags flags) { - lexer::SourcePosition startLoc = lexer_->GetToken().Start(); - ForStatementKind forKind = ForStatementKind::UPDATE; - ir::AstNode *initNode = nullptr; - ir::Expression *updateNode = nullptr; - ir::Expression *leftNode = nullptr; - ir::Expression *rightNode = nullptr; - bool canBeForInOf = true; - bool isAwait = false; - lexer_->NextToken(); - VariableParsingFlags varFlags = VariableParsingFlags::IN_FOR; - ExpressionParseFlags exprFlags = ExpressionParseFlags::NO_OPTS; - - if (lexer_->GetToken().Type() == lexer::TokenType::KEYW_AWAIT) { - isAwait = true; - varFlags |= VariableParsingFlags::DISALLOW_INIT; - lexer_->NextToken(); + if (flags == StatementParsingFlags::STMT_GLOBAL_LEXICAL) { + return ParseStatement(); } - - if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS) { - ThrowSyntaxError(MISSING_LEFT_IN_FOR, lexer_->GetToken().Start()); + if (flags == StatementParsingFlags::ALLOW_LEXICAL) { + return ParseStatement(flags); } - lexer_->NextToken(); + return ParseBlockStatement(false); +} +static VariableParsingFlags UpdateVarFlags(lexer::Lexer *lexer, VariableParsingFlags varFlags) +{ lexer::TokenType tokenType; - auto const currentPosition = lexer_->Save(); + auto const currentPosition = lexer->Save(); do { - tokenType = lexer_->GetToken().Type(); - if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_OF) { + tokenType = lexer->GetToken().Type(); + if (lexer->GetToken().KeywordType() == lexer::TokenType::KEYW_OF) { varFlags |= VariableParsingFlags::FOR_OF; break; } @@ -881,11 +892,20 @@ ir::Statement *ParserImpl::ParseForStatement() varFlags |= VariableParsingFlags::STOP_AT_IN; break; } - lexer_->NextToken(); + lexer->NextToken(); } while (tokenType != lexer::TokenType::PUNCTUATOR_RIGHT_PARENTHESIS && tokenType != lexer::TokenType::PUNCTUATOR_LEFT_BRACE && tokenType != lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS && tokenType != lexer::TokenType::EOS); - lexer_->Rewind(currentPosition); + lexer->Rewind(currentPosition); + return varFlags; +} + +std::tuple ParserImpl::ParseInitOrLeftNode(VariableParsingFlags varFlags, + bool isAwait) +{ + ir::AstNode *initNode = nullptr; + ir::Expression *leftNode = nullptr; + bool canBeForInOf = true; switch (lexer_->GetToken().Type()) { case lexer::TokenType::KEYW_VAR: { @@ -905,7 +925,6 @@ ir::Statement *ParserImpl::ParseForStatement() if (isAwait) { ThrowSyntaxError(UNEXPECTED_TOKEN, lexer_->GetToken().Start()); } - canBeForInOf = false; lexer_->NextToken(); break; @@ -916,8 +935,6 @@ ir::Statement *ParserImpl::ParseForStatement() } } - IterationContext iterCtx(&context_); - if (initNode != nullptr) { if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SEMI_COLON) { lexer_->NextToken(); @@ -927,6 +944,37 @@ ir::Statement *ParserImpl::ParseForStatement() } } + return {initNode, leftNode, canBeForInOf}; +} + +ir::Statement *ParserImpl::ParseForStatement(StatementParsingFlags flags) +{ + lexer::SourcePosition startLoc = lexer_->GetToken().Start(); + lexer_->NextToken(); + + VariableParsingFlags varFlags = VariableParsingFlags::IN_FOR; + bool isAwait = false; + if (lexer_->GetToken().Type() == lexer::TokenType::KEYW_AWAIT) { + isAwait = true; + varFlags |= VariableParsingFlags::DISALLOW_INIT; + lexer_->NextToken(); + } + + if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_LEFT_PARENTHESIS) { + ThrowSyntaxError(MISSING_LEFT_IN_FOR, lexer_->GetToken().Start()); + } + lexer_->NextToken(); + + varFlags = UpdateVarFlags(lexer_, varFlags); + + auto [initNode, leftNode, canBeForInOf] = ParseInitOrLeftNode(varFlags, isAwait); + + IterationContext iterCtx(&context_); + + ForStatementKind forKind = ForStatementKind::UPDATE; + ir::Expression *updateNode = nullptr; + ir::Expression *rightNode = nullptr; + ExpressionParseFlags exprFlags = ExpressionParseFlags::NO_OPTS; // VariableDeclaration->DeclarationSize > 1 or seen semi_colon if (!canBeForInOf) { std::tie(rightNode, updateNode) = ParseForUpdate(isAwait); @@ -949,9 +997,7 @@ ir::Statement *ParserImpl::ParseForStatement() } lexer_->NextToken(); - ir::Statement *bodyNode = ParseStatement(); - lexer::SourcePosition endLoc = bodyNode->End(); - + ir::Statement *bodyNode = ParseStatementBody(flags); ir::Statement *forStatement = nullptr; if (forKind == ForStatementKind::UPDATE) { @@ -962,7 +1008,7 @@ ir::Statement *ParserImpl::ParseForStatement() forStatement = AllocNode(initNode, rightNode, bodyNode, isAwait); } - forStatement->SetRange({startLoc, endLoc}); + forStatement->SetRange({startLoc, bodyNode->End()}); return forStatement; } @@ -987,7 +1033,9 @@ ir::IfStatement *ParserImpl::ParseIfStatement() } lexer_->NextToken(); - ir::Statement *consequent = ParseStatement(StatementParsingFlags::IF_ELSE | StatementParsingFlags::ALLOW_LEXICAL); + ir::Statement *consequent = + ParseBlockStatement(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_BRACE, + StatementParsingFlags::IF_ELSE | StatementParsingFlags::ALLOW_LEXICAL); ThrowIfBodyEmptyError(consequent); @@ -996,7 +1044,8 @@ ir::IfStatement *ParserImpl::ParseIfStatement() if (lexer_->GetToken().Type() == lexer::TokenType::KEYW_ELSE) { lexer_->NextToken(); // eat ELSE keyword - alternate = ParseStatement(StatementParsingFlags::IF_ELSE | StatementParsingFlags::ALLOW_LEXICAL); + alternate = ParseBlockStatement(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_BRACE, + StatementParsingFlags::IF_ELSE | StatementParsingFlags::ALLOW_LEXICAL); endLoc = alternate->End(); } @@ -1432,7 +1481,7 @@ ir::Statement *ParserImpl::ParseVariableDeclaration(VariableParsingFlags flags) return declaration; } -ir::WhileStatement *ParserImpl::ParseWhileStatement() +ir::WhileStatement *ParserImpl::ParseWhileStatement(StatementParsingFlags flags) { lexer::SourcePosition startLoc = lexer_->GetToken().Start(); lexer_->NextToken(); @@ -1449,7 +1498,7 @@ ir::WhileStatement *ParserImpl::ParseWhileStatement() lexer_->NextToken(); IterationContext iterCtx(&context_); - ir::Statement *body = ParseStatement(); + ir::Statement *body = ParseStatementBody(flags); lexer::SourcePosition endLoc = body->End(); auto *whileStatement = AllocNode(test, body); diff --git a/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt b/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt index ed829d9f09..3bdaeac72c 100644 --- a/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt +++ b/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt @@ -5474,147 +5474,162 @@ "type": "BlockStatement", "statements": [ { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "newData", - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 16 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "newData", + "decorators": [], + "loc": { + "start": { + "line": 62, + "column": 16 + }, + "end": { + "line": 62, + "column": 23 + } + } }, - "end": { - "line": 62, - "column": 23 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 24 + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 62, + "column": 24 + }, + "end": { + "line": 62, + "column": 25 + } + } }, - "end": { - "line": 62, - "column": 25 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 62, - "column": 16 - }, - "end": { - "line": 62, - "column": 26 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", + "computed": true, + "optional": false, "loc": { "start": { "line": 62, - "column": 29 + "column": 16 }, "end": { "line": 62, - "column": 33 + "column": 26 } } }, - "property": { - "type": "Identifier", - "name": "data", - "decorators": [], + "right": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 62, + "column": 29 + }, + "end": { + "line": 62, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "decorators": [], + "loc": { + "start": { + "line": 62, + "column": 34 + }, + "end": { + "line": 62, + "column": 38 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 62, + "column": 29 + }, + "end": { + "line": 62, + "column": 38 + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 62, + "column": 39 + }, + "end": { + "line": 62, + "column": 40 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 62, - "column": 34 + "column": 29 }, "end": { "line": 62, - "column": 38 + "column": 41 } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 62, - "column": 29 - }, - "end": { - "line": 62, - "column": 38 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 39 + "column": 16 }, "end": { "line": 62, - "column": 40 + "column": 41 } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 62, - "column": 29 + "column": 16 }, "end": { "line": 62, - "column": 41 + "column": 42 } } - }, - "loc": { - "start": { - "line": 62, - "column": 16 - }, - "end": { - "line": 62, - "column": 41 - } } - }, + ], "loc": { "start": { - "line": 62, - "column": 16 + "line": 61, + "column": 52 }, "end": { - "line": 62, - "column": 42 + "line": 63, + "column": 14 } } } @@ -5625,8 +5640,8 @@ "column": 52 }, "end": { - "line": 63, - "column": 14 + "line": 64, + "column": 17 } } }, @@ -5636,8 +5651,8 @@ "column": 13 }, "end": { - "line": 63, - "column": 14 + "line": 64, + "column": 17 } } }, @@ -9144,147 +9159,162 @@ "type": "BlockStatement", "statements": [ { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "newData", - "decorators": [], - "loc": { - "start": { - "line": 106, - "column": 17 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "newData", + "decorators": [], + "loc": { + "start": { + "line": 106, + "column": 17 + }, + "end": { + "line": 106, + "column": 24 + } + } }, - "end": { - "line": 106, - "column": 24 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 106, - "column": 25 + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 106, + "column": 25 + }, + "end": { + "line": 106, + "column": 26 + } + } }, - "end": { - "line": 106, - "column": 26 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 106, - "column": 17 - }, - "end": { - "line": 106, - "column": 27 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", + "computed": true, + "optional": false, "loc": { "start": { "line": 106, - "column": 30 + "column": 17 + }, + "end": { + "line": 106, + "column": 27 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 106, + "column": 30 + }, + "end": { + "line": 106, + "column": 34 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "decorators": [], + "loc": { + "start": { + "line": 106, + "column": 35 + }, + "end": { + "line": 106, + "column": 39 + } + } }, - "end": { - "line": 106, - "column": 34 + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 106, + "column": 30 + }, + "end": { + "line": 106, + "column": 39 + } } - } - }, - "property": { - "type": "Identifier", - "name": "data", - "decorators": [], + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 106, + "column": 40 + }, + "end": { + "line": 106, + "column": 41 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 106, - "column": 35 + "column": 30 }, "end": { "line": 106, - "column": 39 + "column": 42 } } }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 106, - "column": 30 - }, - "end": { - "line": 106, - "column": 39 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], "loc": { "start": { "line": 106, - "column": 40 + "column": 17 }, "end": { "line": 106, - "column": 41 + "column": 42 } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 106, - "column": 30 + "column": 17 }, "end": { "line": 106, - "column": 42 + "column": 43 } } - }, - "loc": { - "start": { - "line": 106, - "column": 17 - }, - "end": { - "line": 106, - "column": 42 - } } - }, + ], "loc": { "start": { - "line": 106, - "column": 17 + "line": 105, + "column": 52 }, "end": { - "line": 106, - "column": 43 + "line": 107, + "column": 14 } } } @@ -9295,8 +9325,8 @@ "column": 52 }, "end": { - "line": 107, - "column": 14 + "line": 108, + "column": 17 } } }, @@ -9306,8 +9336,8 @@ "column": 13 }, "end": { - "line": 107, - "column": 14 + "line": 108, + "column": 17 } } }, @@ -13689,163 +13719,178 @@ "type": "BlockStatement", "statements": [ { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "res", - "decorators": [], - "loc": { - "start": { - "line": 160, - "column": 17 - }, - "end": { - "line": 160, - "column": 20 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "combine", - "decorators": [], - "loc": { - "start": { - "line": 160, - "column": 23 - }, - "end": { - "line": 160, - "column": 30 - } - } - }, - "arguments": [ - { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { "type": "Identifier", "name": "res", "decorators": [], "loc": { "start": { "line": 160, - "column": 31 + "column": 17 }, "end": { "line": 160, - "column": 34 + "column": 20 } } }, - { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", + "right": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "combine", + "decorators": [], + "loc": { + "start": { + "line": 160, + "column": 23 + }, + "end": { + "line": 160, + "column": 30 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "res", + "decorators": [], "loc": { "start": { "line": 160, - "column": 36 + "column": 31 }, "end": { "line": 160, - "column": 40 + "column": 34 } } }, - "property": { - "type": "Identifier", - "name": "data", - "decorators": [], + { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 160, + "column": 36 + }, + "end": { + "line": 160, + "column": 40 + } + } + }, + "property": { + "type": "Identifier", + "name": "data", + "decorators": [], + "loc": { + "start": { + "line": 160, + "column": 41 + }, + "end": { + "line": 160, + "column": 45 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 160, + "column": 36 + }, + "end": { + "line": 160, + "column": 45 + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 160, + "column": 46 + }, + "end": { + "line": 160, + "column": 47 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 160, - "column": 41 + "column": 36 }, "end": { "line": 160, - "column": 45 + "column": 48 } } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 160, - "column": 36 - }, - "end": { - "line": 160, - "column": 45 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 160, - "column": 46 - }, - "end": { - "line": 160, - "column": 47 - } } - }, - "computed": true, + ], "optional": false, "loc": { "start": { "line": 160, - "column": 36 + "column": 23 }, "end": { "line": 160, - "column": 48 + "column": 49 } } + }, + "loc": { + "start": { + "line": 160, + "column": 17 + }, + "end": { + "line": 160, + "column": 49 + } } - ], - "optional": false, + }, "loc": { "start": { "line": 160, - "column": 23 + "column": 17 }, "end": { "line": 160, - "column": 49 + "column": 50 } } - }, - "loc": { - "start": { - "line": 160, - "column": 17 - }, - "end": { - "line": 160, - "column": 49 - } } - }, + ], "loc": { "start": { - "line": 160, - "column": 17 + "line": 159, + "column": 52 }, "end": { - "line": 160, - "column": 50 + "line": 161, + "column": 14 } } } @@ -13856,8 +13901,8 @@ "column": 52 }, "end": { - "line": 161, - "column": 14 + "line": 162, + "column": 19 } } }, @@ -13867,8 +13912,8 @@ "column": 13 }, "end": { - "line": 161, - "column": 14 + "line": 162, + "column": 19 } } }, diff --git a/ets2panda/test/compiler/ets/union_types_5-expected.txt b/ets2panda/test/compiler/ets/union_types_5-expected.txt index f503ba0d24..e21ceac265 100644 --- a/ets2panda/test/compiler/ets/union_types_5-expected.txt +++ b/ets2panda/test/compiler/ets/union_types_5-expected.txt @@ -1176,33 +1176,58 @@ } }, "alternate": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "instanceof", - "left": { - "type": "Identifier", - "name": "x", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 16 - }, - "end": { - "line": 29, - "column": 17 - } - } - }, - "right": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { "type": "Identifier", - "name": "C", + "name": "x", "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 16 + }, + "end": { + "line": 29, + "column": 17 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 29 + }, + "end": { + "line": 29, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 29 + }, + "end": { + "line": 29, + "column": 31 + } + } + }, "loc": { "start": { "line": 29, @@ -1210,14 +1235,14 @@ }, "end": { "line": 29, - "column": 30 + "column": 31 } } }, "loc": { "start": { "line": 29, - "column": 29 + "column": 16 }, "end": { "line": 29, @@ -1225,42 +1250,73 @@ } } }, - "loc": { - "start": { - "line": 29, - "column": 29 - }, - "end": { - "line": 29, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 29, - "column": 16 - }, - "end": { - "line": 29, - "column": 31 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "AssertStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "decorators": [], + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "AssertStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "x", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 16 + }, + "end": { + "line": 30, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "num", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 18 + }, + "end": { + "line": 30, + "column": 21 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 30, + "column": 16 + }, + "end": { + "line": 30, + "column": 21 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 43, + "loc": { + "start": { + "line": 30, + "column": 25 + }, + "end": { + "line": 30, + "column": 27 + } + } + }, "loc": { "start": { "line": 30, @@ -1268,164 +1324,123 @@ }, "end": { "line": 30, - "column": 17 + "column": 27 } } }, - "property": { - "type": "Identifier", - "name": "num", - "decorators": [], + "second": { + "type": "StringLiteral", + "value": "Error! num field must be 43", "loc": { "start": { "line": 30, - "column": 18 + "column": 29 }, "end": { "line": 30, - "column": 21 + "column": 58 } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 30, - "column": 16 + "column": 9 }, "end": { "line": 30, - "column": 21 + "column": 59 } } - }, - "right": { - "type": "NumberLiteral", - "value": 43, - "loc": { - "start": { - "line": 30, - "column": 25 - }, - "end": { - "line": 30, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 30, - "column": 16 - }, - "end": { - "line": 30, - "column": 27 - } } - }, - "second": { - "type": "StringLiteral", - "value": "Error! num field must be 43", - "loc": { - "start": { - "line": 30, - "column": 29 - }, - "end": { - "line": 30, - "column": 58 - } - } - }, + ], "loc": { "start": { - "line": 30, - "column": 9 + "line": 29, + "column": 32 }, "end": { - "line": 30, - "column": 59 + "line": 31, + "column": 6 } } - } - ], - "loc": { - "start": { - "line": 29, - "column": 32 }, - "end": { - "line": 31, - "column": 6 - } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ - { - "type": "AssertStatement", - "test": { - "type": "BooleanLiteral", - "value": false, - "loc": { - "start": { - "line": 32, - "column": 16 + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "AssertStatement", + "test": { + "type": "BooleanLiteral", + "value": false, + "loc": { + "start": { + "line": 32, + "column": 16 + }, + "end": { + "line": 32, + "column": 21 + } + } }, - "end": { - "line": 32, - "column": 21 - } - } - }, - "second": { - "type": "StringLiteral", - "value": "Error! x must be instanceof B|C", - "loc": { - "start": { - "line": 32, - "column": 23 + "second": { + "type": "StringLiteral", + "value": "Error! x must be instanceof B|C", + "loc": { + "start": { + "line": 32, + "column": 23 + }, + "end": { + "line": 32, + "column": 56 + } + } }, - "end": { - "line": 32, - "column": 56 + "loc": { + "start": { + "line": 32, + "column": 9 + }, + "end": { + "line": 32, + "column": 57 + } } } - }, + ], "loc": { "start": { - "line": 32, - "column": 9 + "line": 31, + "column": 12 }, "end": { - "line": 32, - "column": 57 + "line": 33, + "column": 6 } } - } - ], - "loc": { - "start": { - "line": 31, - "column": 12 }, - "end": { - "line": 33, - "column": 6 + "loc": { + "start": { + "line": 29, + "column": 12 + }, + "end": { + "line": 33, + "column": 6 + } } } - }, + ], "loc": { "start": { "line": 29, "column": 12 }, "end": { - "line": 33, - "column": 6 + "line": 34, + "column": 2 } } }, @@ -1435,8 +1450,8 @@ "column": 5 }, "end": { - "line": 33, - "column": 6 + "line": 34, + "column": 2 } } } @@ -1965,63 +1980,88 @@ } }, "alternate": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "instanceof", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "decorators": [], - "loc": { - "start": { - "line": 39, - "column": 16 + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "x", + "decorators": [], + "loc": { + "start": { + "line": 39, + "column": 16 + }, + "end": { + "line": 39, + "column": 17 + } + } }, - "end": { - "line": 39, - "column": 17 - } - } - }, - "property": { - "type": "Identifier", - "name": "union0", - "decorators": [], - "loc": { - "start": { - "line": 39, - "column": 18 + "property": { + "type": "Identifier", + "name": "union0", + "decorators": [], + "loc": { + "start": { + "line": 39, + "column": 18 + }, + "end": { + "line": 39, + "column": 24 + } + } }, - "end": { - "line": 39, - "column": 24 + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 39, + "column": 16 + }, + "end": { + "line": 39, + "column": 24 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 39, - "column": 16 }, - "end": { - "line": 39, - "column": 24 - } - } - }, - "right": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "C", - "decorators": [], + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 39, + "column": 36 + }, + "end": { + "line": 39, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 39, + "column": 36 + }, + "end": { + "line": 39, + "column": 38 + } + } + }, "loc": { "start": { "line": 39, @@ -2029,14 +2069,14 @@ }, "end": { "line": 39, - "column": 37 + "column": 38 } } }, "loc": { "start": { "line": 39, - "column": 36 + "column": 16 }, "end": { "line": 39, @@ -2044,44 +2084,78 @@ } } }, - "loc": { - "start": { - "line": 39, - "column": 36 - }, - "end": { - "line": 39, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 39, - "column": 16 - }, - "end": { - "line": 39, - "column": 38 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "AssertStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "x", - "decorators": [], + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "AssertStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "x", + "decorators": [], + "loc": { + "start": { + "line": 40, + "column": 16 + }, + "end": { + "line": 40, + "column": 17 + } + } + }, + "property": { + "type": "Identifier", + "name": "union0", + "decorators": [], + "loc": { + "start": { + "line": 40, + "column": 18 + }, + "end": { + "line": 40, + "column": 24 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 40, + "column": 16 + }, + "end": { + "line": 40, + "column": 24 + } + } + }, + "property": { + "type": "Identifier", + "name": "num", + "decorators": [], + "loc": { + "start": { + "line": 40, + "column": 25 + }, + "end": { + "line": 40, + "column": 28 + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 40, @@ -2089,27 +2163,24 @@ }, "end": { "line": 40, - "column": 17 + "column": 28 } } }, - "property": { - "type": "Identifier", - "name": "union0", - "decorators": [], + "right": { + "type": "NumberLiteral", + "value": 43, "loc": { "start": { "line": 40, - "column": 18 + "column": 32 }, "end": { "line": 40, - "column": 24 + "column": 34 } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 40, @@ -2117,164 +2188,123 @@ }, "end": { "line": 40, - "column": 24 + "column": 34 } } }, - "property": { - "type": "Identifier", - "name": "num", - "decorators": [], + "second": { + "type": "StringLiteral", + "value": "Error! x.union0.num field must be 43", "loc": { "start": { "line": 40, - "column": 25 + "column": 36 }, "end": { "line": 40, - "column": 28 + "column": 74 } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 40, - "column": 16 + "column": 9 }, "end": { "line": 40, - "column": 28 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 43, - "loc": { - "start": { - "line": 40, - "column": 32 - }, - "end": { - "line": 40, - "column": 34 + "column": 75 } } - }, - "loc": { - "start": { - "line": 40, - "column": 16 - }, - "end": { - "line": 40, - "column": 34 - } - } - }, - "second": { - "type": "StringLiteral", - "value": "Error! x.union0.num field must be 43", - "loc": { - "start": { - "line": 40, - "column": 36 - }, - "end": { - "line": 40, - "column": 74 - } } - }, + ], "loc": { "start": { - "line": 40, - "column": 9 + "line": 39, + "column": 39 }, "end": { - "line": 40, - "column": 75 + "line": 41, + "column": 6 } } - } - ], - "loc": { - "start": { - "line": 39, - "column": 39 }, - "end": { - "line": 41, - "column": 6 - } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ - { - "type": "AssertStatement", - "test": { - "type": "BooleanLiteral", - "value": false, - "loc": { - "start": { - "line": 42, - "column": 16 + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "AssertStatement", + "test": { + "type": "BooleanLiteral", + "value": false, + "loc": { + "start": { + "line": 42, + "column": 16 + }, + "end": { + "line": 42, + "column": 21 + } + } }, - "end": { - "line": 42, - "column": 21 - } - } - }, - "second": { - "type": "StringLiteral", - "value": "Error! x.union0 must be instanceof B|C", - "loc": { - "start": { - "line": 42, - "column": 23 + "second": { + "type": "StringLiteral", + "value": "Error! x.union0 must be instanceof B|C", + "loc": { + "start": { + "line": 42, + "column": 23 + }, + "end": { + "line": 42, + "column": 63 + } + } }, - "end": { - "line": 42, - "column": 63 + "loc": { + "start": { + "line": 42, + "column": 9 + }, + "end": { + "line": 42, + "column": 64 + } } } - }, + ], "loc": { "start": { - "line": 42, - "column": 9 + "line": 41, + "column": 12 }, "end": { - "line": 42, - "column": 64 + "line": 43, + "column": 6 } } - } - ], - "loc": { - "start": { - "line": 41, - "column": 12 }, - "end": { - "line": 43, - "column": 6 + "loc": { + "start": { + "line": 39, + "column": 12 + }, + "end": { + "line": 43, + "column": 6 + } } } - }, + ], "loc": { "start": { "line": 39, "column": 12 }, "end": { - "line": 43, - "column": 6 + "line": 44, + "column": 2 } } }, @@ -2284,8 +2314,8 @@ "column": 5 }, "end": { - "line": 43, - "column": 6 + "line": 44, + "column": 2 } } } diff --git a/ets2panda/test/parser/ets/AccessBinaryTrees-expected.txt b/ets2panda/test/parser/ets/AccessBinaryTrees-expected.txt index 0f884e5274..3801a68ef3 100644 --- a/ets2panda/test/parser/ets/AccessBinaryTrees-expected.txt +++ b/ets2panda/test/parser/ets/AccessBinaryTrees-expected.txt @@ -1002,80 +1002,21 @@ } }, "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 29, - "column": 14 - }, - "end": { - "line": 29, - "column": 18 - } - } - }, - "property": { - "type": "Identifier", - "name": "item", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 19 - }, - "end": { - "line": 29, - "column": 23 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 29, - "column": 14 - }, - "end": { - "line": 29, - "column": 23 - } - } - }, - "loc": { - "start": { - "line": 29, - "column": 7 - }, - "end": { - "line": 29, - "column": 24 - } - } - }, - "alternate": { - "type": "ReturnStatement", - "argument": { - "type": "BinaryExpression", - "operator": "-", - "left": { - "type": "BinaryExpression", - "operator": "+", - "left": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { "type": "MemberExpression", "object": { "type": "ThisExpression", "loc": { "start": { - "line": 31, + "line": 29, "column": 14 }, "end": { - "line": 31, + "line": 29, "column": 18 } } @@ -1086,11 +1027,11 @@ "decorators": [], "loc": { "start": { - "line": 31, + "line": 29, "column": 19 }, "end": { - "line": 31, + "line": 29, "column": 23 } } @@ -1099,25 +1040,141 @@ "optional": false, "loc": { "start": { - "line": 31, + "line": 29, "column": 14 }, "end": { - "line": 31, + "line": 29, "column": 23 } } }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "TSNonNullExpression", - "expression": { + "loc": { + "start": { + "line": 29, + "column": 7 + }, + "end": { + "line": 29, + "column": 24 + } + } + } + ], + "loc": { + "start": { + "line": 29, + "column": 7 + }, + "end": { + "line": 30, + "column": 9 + } + } + }, + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "-", + "left": { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 31, + "column": 14 + }, + "end": { + "line": 31, + "column": 18 + } + } + }, + "property": { + "type": "Identifier", + "name": "item", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 19 + }, + "end": { + "line": 31, + "column": 23 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 31, + "column": 14 + }, + "end": { + "line": 31, + "column": 23 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { "type": "MemberExpression", "object": { - "type": "ThisExpression", + "type": "TSNonNullExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 31, + "column": 26 + }, + "end": { + "line": 31, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "left", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 31 + }, + "end": { + "line": 31, + "column": 35 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 31, + "column": 26 + }, + "end": { + "line": 31, + "column": 35 + } + } + }, "loc": { "start": { "line": 31, @@ -1125,22 +1182,22 @@ }, "end": { "line": 31, - "column": 30 + "column": 36 } } }, "property": { "type": "Identifier", - "name": "left", + "name": "itemCheck", "decorators": [], "loc": { "start": { "line": 31, - "column": 31 + "column": 37 }, "end": { "line": 31, - "column": 35 + "column": 46 } } }, @@ -1153,10 +1210,12 @@ }, "end": { "line": 31, - "column": 35 + "column": 46 } } }, + "arguments": [], + "optional": false, "loc": { "start": { "line": 31, @@ -1164,72 +1223,70 @@ }, "end": { "line": 31, - "column": 36 - } - } - }, - "property": { - "type": "Identifier", - "name": "itemCheck", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 37 - }, - "end": { - "line": 31, - "column": 46 + "column": 48 } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 31, - "column": 26 + "column": 14 }, "end": { "line": 31, - "column": 46 + "column": 48 } } }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 31, - "column": 26 - }, - "end": { - "line": 31, - "column": 48 - } - } - }, - "loc": { - "start": { - "line": 31, - "column": 14 - }, - "end": { - "line": 31, - "column": 48 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "TSNonNullExpression", - "expression": { + "right": { + "type": "CallExpression", + "callee": { "type": "MemberExpression", "object": { - "type": "ThisExpression", + "type": "TSNonNullExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 31, + "column": 51 + }, + "end": { + "line": 31, + "column": 55 + } + } + }, + "property": { + "type": "Identifier", + "name": "right", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 56 + }, + "end": { + "line": 31, + "column": 61 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 31, + "column": 51 + }, + "end": { + "line": 31, + "column": 61 + } + } + }, "loc": { "start": { "line": 31, @@ -1237,22 +1294,22 @@ }, "end": { "line": 31, - "column": 55 + "column": 62 } } }, "property": { "type": "Identifier", - "name": "right", + "name": "itemCheck", "decorators": [], "loc": { "start": { "line": 31, - "column": 56 + "column": 63 }, "end": { "line": 31, - "column": 61 + "column": 72 } } }, @@ -1265,10 +1322,12 @@ }, "end": { "line": 31, - "column": 61 + "column": 72 } } }, + "arguments": [], + "optional": false, "loc": { "start": { "line": 31, @@ -1276,70 +1335,41 @@ }, "end": { "line": 31, - "column": 62 - } - } - }, - "property": { - "type": "Identifier", - "name": "itemCheck", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 63 - }, - "end": { - "line": 31, - "column": 72 + "column": 74 } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 31, - "column": 51 + "column": 14 }, "end": { "line": 31, - "column": 72 + "column": 74 } } }, - "arguments": [], - "optional": false, "loc": { "start": { "line": 31, - "column": 51 + "column": 7 }, "end": { "line": 31, - "column": 74 + "column": 75 } } - }, - "loc": { - "start": { - "line": 31, - "column": 14 - }, - "end": { - "line": 31, - "column": 74 - } } - }, + ], "loc": { "start": { "line": 31, "column": 7 }, "end": { - "line": 31, - "column": 75 + "line": 32, + "column": 4 } } }, @@ -1349,8 +1379,8 @@ "column": 5 }, "end": { - "line": 31, - "column": 75 + "line": 32, + "column": 4 } } } diff --git a/ets2panda/test/parser/ets/AccessFannkuch-expected.txt b/ets2panda/test/parser/ets/AccessFannkuch-expected.txt index 8f73d986b7..bf26e97eba 100644 --- a/ets2panda/test/parser/ets/AccessFannkuch-expected.txt +++ b/ets2panda/test/parser/ets/AccessFannkuch-expected.txt @@ -2148,119 +2148,134 @@ } }, "body": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "perm", - "decorators": [], - "loc": { - "start": { - "line": 45, - "column": 55 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "perm", + "decorators": [], + "loc": { + "start": { + "line": 45, + "column": 55 + }, + "end": { + "line": 45, + "column": 59 + } + } }, - "end": { - "line": 45, - "column": 59 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 45, - "column": 60 + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 45, + "column": 60 + }, + "end": { + "line": 45, + "column": 61 + } + } }, - "end": { - "line": 45, - "column": 61 + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 45, + "column": 55 + }, + "end": { + "line": 45, + "column": 62 + } } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 45, - "column": 55 }, - "end": { - "line": 45, - "column": 62 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "perm1", - "decorators": [], - "loc": { - "start": { - "line": 45, - "column": 65 + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "perm1", + "decorators": [], + "loc": { + "start": { + "line": 45, + "column": 65 + }, + "end": { + "line": 45, + "column": 70 + } + } }, - "end": { - "line": 45, - "column": 70 + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 45, + "column": 71 + }, + "end": { + "line": 45, + "column": 72 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 45, + "column": 65 + }, + "end": { + "line": 45, + "column": 73 + } } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], + }, "loc": { "start": { "line": 45, - "column": 71 + "column": 55 }, "end": { "line": 45, - "column": 72 + "column": 73 } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 45, - "column": 65 + "column": 55 }, "end": { "line": 45, - "column": 73 + "column": 74 } } - }, - "loc": { - "start": { - "line": 45, - "column": 55 - }, - "end": { - "line": 45, - "column": 73 - } } - }, + ], "loc": { "start": { "line": 45, "column": 55 }, "end": { - "line": 45, - "column": 74 + "line": 47, + "column": 20 } } }, @@ -2270,8 +2285,8 @@ "column": 17 }, "end": { - "line": 45, - "column": 74 + "line": 47, + "column": 20 } } }, @@ -2526,667 +2541,692 @@ "type": "BlockStatement", "statements": [ { - "type": "VariableDeclaration", - "declarations": [ + "type": "BlockStatement", + "statements": [ { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "k2", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 51, - "column": 25 - }, - "end": { - "line": 51, - "column": 28 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 51, - "column": 21 - }, - "end": { - "line": 51, - "column": 23 - } - } - }, - "init": { - "type": "BinaryExpression", - "operator": ">>", - "left": { - "type": "BinaryExpression", - "operator": "+", - "left": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { "type": "Identifier", - "name": "k", + "name": "k2", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 51, + "column": 25 + }, + "end": { + "line": 51, + "column": 28 + } + } + }, "decorators": [], "loc": { "start": { "line": 51, - "column": 32 + "column": 21 }, "end": { "line": 51, - "column": 33 + "column": 23 } } }, - "right": { - "type": "NumberLiteral", - "value": 1, + "init": { + "type": "BinaryExpression", + "operator": ">>", + "left": { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "Identifier", + "name": "k", + "decorators": [], + "loc": { + "start": { + "line": 51, + "column": 32 + }, + "end": { + "line": 51, + "column": 33 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 51, + "column": 36 + }, + "end": { + "line": 51, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 51, + "column": 31 + }, + "end": { + "line": 51, + "column": 38 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 51, + "column": 42 + }, + "end": { + "line": 51, + "column": 43 + } + } + }, "loc": { "start": { "line": 51, - "column": 36 + "column": 31 }, "end": { "line": 51, - "column": 37 + "column": 43 } } }, "loc": { "start": { "line": 51, - "column": 31 - }, - "end": { - "line": 51, - "column": 38 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 51, - "column": 42 + "column": 21 }, "end": { "line": 51, "column": 43 } } - }, - "loc": { - "start": { - "line": 51, - "column": 31 - }, - "end": { - "line": 51, - "column": 43 - } } - }, + ], + "kind": "let", "loc": { "start": { "line": 51, - "column": 21 + "column": 17 }, "end": { "line": 51, - "column": 43 + "column": 44 } } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 51, - "column": 17 }, - "end": { - "line": 51, - "column": 44 - } - } - }, - { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 52, + "column": 30 + }, + "end": { + "line": 52, + "column": 31 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 52, + "column": 34 + }, + "end": { + "line": 52, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 30 + }, + "end": { + "line": 52, + "column": 35 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 52, + "column": 26 + }, + "end": { + "line": 52, + "column": 35 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", "name": "i", "decorators": [], "loc": { "start": { "line": 52, - "column": 30 + "column": 37 }, "end": { "line": 52, - "column": 31 + "column": 38 } } }, - "init": { - "type": "NumberLiteral", - "value": 0, + "right": { + "type": "Identifier", + "name": "k2", + "decorators": [], "loc": { "start": { "line": 52, - "column": 34 + "column": 41 }, "end": { "line": 52, - "column": 35 + "column": 43 } } }, "loc": { "start": { "line": 52, - "column": 30 + "column": 37 }, "end": { "line": 52, - "column": 35 + "column": 43 } } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 52, - "column": 26 - }, - "end": { - "line": 52, - "column": 35 - } - } - }, - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 37 - }, - "end": { - "line": 52, - "column": 38 - } - } - }, - "right": { - "type": "Identifier", - "name": "k2", - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 41 - }, - "end": { - "line": 52, - "column": 43 - } - } - }, - "loc": { - "start": { - "line": 52, - "column": 37 }, - "end": { - "line": 52, - "column": 43 - } - } - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": false, - "argument": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 45 + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": false, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 52, + "column": 45 + }, + "end": { + "line": 52, + "column": 46 + } + } }, - "end": { - "line": 52, - "column": 46 + "loc": { + "start": { + "line": 52, + "column": 45 + }, + "end": { + "line": 52, + "column": 48 + } } - } - }, - "loc": { - "start": { - "line": 52, - "column": 45 }, - "end": { - "line": 52, - "column": 48 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ + "body": { + "type": "BlockStatement", + "statements": [ { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "temp", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 53, - "column": 35 + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "temp", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 53, + "column": 35 + }, + "end": { + "line": 53, + "column": 38 + } + } }, - "end": { - "line": 53, - "column": 38 + "decorators": [], + "loc": { + "start": { + "line": 53, + "column": 29 + }, + "end": { + "line": 53, + "column": 33 + } } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 53, - "column": 29 }, - "end": { - "line": 53, - "column": 33 - } - } - }, - "init": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "perm", - "decorators": [], - "loc": { - "start": { - "line": 53, - "column": 41 + "init": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "perm", + "decorators": [], + "loc": { + "start": { + "line": 53, + "column": 41 + }, + "end": { + "line": 53, + "column": 45 + } + } }, - "end": { - "line": 53, - "column": 45 + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 53, + "column": 46 + }, + "end": { + "line": 53, + "column": 47 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 53, + "column": 41 + }, + "end": { + "line": 53, + "column": 48 + } } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], + }, "loc": { "start": { "line": 53, - "column": 46 + "column": 29 }, "end": { "line": 53, - "column": 47 + "column": 48 } } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 53, - "column": 41 - }, - "end": { - "line": 53, - "column": 48 - } } - }, + ], + "kind": "let", "loc": { "start": { "line": 53, - "column": 29 + "column": 25 }, "end": { "line": 53, - "column": 48 + "column": 49 } } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 53, - "column": 25 }, - "end": { - "line": 53, - "column": 49 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "perm", - "decorators": [], - "loc": { - "start": { - "line": 54, - "column": 25 - }, - "end": { - "line": 54, - "column": 29 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 54, - "column": 30 + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "perm", + "decorators": [], + "loc": { + "start": { + "line": 54, + "column": 25 + }, + "end": { + "line": 54, + "column": 29 + } + } }, - "end": { - "line": 54, - "column": 31 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 54, - "column": 25 - }, - "end": { - "line": 54, - "column": 32 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "perm", - "decorators": [], - "loc": { - "start": { - "line": 54, - "column": 35 + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 54, + "column": 30 + }, + "end": { + "line": 54, + "column": 31 + } + } }, - "end": { - "line": 54, - "column": 39 - } - } - }, - "property": { - "type": "BinaryExpression", - "operator": "-", - "left": { - "type": "Identifier", - "name": "k", - "decorators": [], + "computed": true, + "optional": false, "loc": { "start": { "line": 54, - "column": 40 + "column": 25 }, "end": { "line": 54, - "column": 41 + "column": 32 } } }, "right": { - "type": "Identifier", - "name": "i", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "perm", + "decorators": [], + "loc": { + "start": { + "line": 54, + "column": 35 + }, + "end": { + "line": 54, + "column": 39 + } + } + }, + "property": { + "type": "BinaryExpression", + "operator": "-", + "left": { + "type": "Identifier", + "name": "k", + "decorators": [], + "loc": { + "start": { + "line": 54, + "column": 40 + }, + "end": { + "line": 54, + "column": 41 + } + } + }, + "right": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 54, + "column": 44 + }, + "end": { + "line": 54, + "column": 45 + } + } + }, + "loc": { + "start": { + "line": 54, + "column": 40 + }, + "end": { + "line": 54, + "column": 45 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 54, - "column": 44 + "column": 35 }, "end": { "line": 54, - "column": 45 + "column": 46 } } }, "loc": { "start": { "line": 54, - "column": 40 + "column": 25 }, "end": { "line": 54, - "column": 45 + "column": 46 } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 54, - "column": 35 + "column": 25 }, "end": { "line": 54, - "column": 46 + "column": 47 } } }, - "loc": { - "start": { - "line": 54, - "column": 25 - }, - "end": { - "line": 54, - "column": 46 - } - } - }, - "loc": { - "start": { - "line": 54, - "column": 25 - }, - "end": { - "line": 54, - "column": 47 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "perm", - "decorators": [], - "loc": { - "start": { - "line": 55, - "column": 25 - }, - "end": { - "line": 55, - "column": 29 - } - } - }, - "property": { - "type": "BinaryExpression", - "operator": "-", + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", "left": { - "type": "Identifier", - "name": "k", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "perm", + "decorators": [], + "loc": { + "start": { + "line": 55, + "column": 25 + }, + "end": { + "line": 55, + "column": 29 + } + } + }, + "property": { + "type": "BinaryExpression", + "operator": "-", + "left": { + "type": "Identifier", + "name": "k", + "decorators": [], + "loc": { + "start": { + "line": 55, + "column": 30 + }, + "end": { + "line": 55, + "column": 31 + } + } + }, + "right": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 55, + "column": 34 + }, + "end": { + "line": 55, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 55, + "column": 30 + }, + "end": { + "line": 55, + "column": 35 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 55, - "column": 30 + "column": 25 }, "end": { "line": 55, - "column": 31 + "column": 36 } } }, "right": { "type": "Identifier", - "name": "i", + "name": "temp", "decorators": [], "loc": { "start": { "line": 55, - "column": 34 + "column": 39 }, "end": { "line": 55, - "column": 35 + "column": 43 } } }, "loc": { "start": { "line": 55, - "column": 30 + "column": 25 }, "end": { "line": 55, - "column": 35 + "column": 43 } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 55, - "column": 25 - }, - "end": { - "line": 55, - "column": 36 - } - } - }, - "right": { - "type": "Identifier", - "name": "temp", - "decorators": [], + } + }, "loc": { "start": { "line": 55, - "column": 39 + "column": 25 }, "end": { "line": 55, - "column": 43 + "column": 44 } } + } + ], + "loc": { + "start": { + "line": 52, + "column": 50 }, + "end": { + "line": 56, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 21 + }, + "end": { + "line": 56, + "column": 22 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "UpdateExpression", + "operator": "++", + "prefix": false, + "argument": { + "type": "Identifier", + "name": "flipsCount", + "decorators": [], "loc": { "start": { - "line": 55, - "column": 25 + "line": 57, + "column": 21 }, "end": { - "line": 55, - "column": 43 + "line": 57, + "column": 31 } } }, "loc": { "start": { - "line": 55, - "column": 25 + "line": 57, + "column": 21 }, "end": { - "line": 55, - "column": 44 + "line": 57, + "column": 33 } } - } - ], - "loc": { - "start": { - "line": 52, - "column": 50 }, - "end": { - "line": 56, - "column": 22 - } - } - }, - "loc": { - "start": { - "line": 52, - "column": 21 - }, - "end": { - "line": 56, - "column": 22 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "UpdateExpression", - "operator": "++", - "prefix": false, - "argument": { - "type": "Identifier", - "name": "flipsCount", - "decorators": [], "loc": { "start": { "line": 57, @@ -3194,29 +3234,19 @@ }, "end": { "line": 57, - "column": 31 + "column": 34 } } - }, - "loc": { - "start": { - "line": 57, - "column": 21 - }, - "end": { - "line": 57, - "column": 33 - } } - }, + ], "loc": { "start": { - "line": 57, - "column": 21 + "line": 50, + "column": 47 }, "end": { - "line": 57, - "column": 34 + "line": 58, + "column": 18 } } } @@ -3227,8 +3257,8 @@ "column": 47 }, "end": { - "line": 58, - "column": 18 + "line": 60, + "column": 19 } } }, @@ -3238,8 +3268,8 @@ "column": 17 }, "end": { - "line": 58, - "column": 18 + "line": 60, + "column": 19 } } }, @@ -3512,119 +3542,134 @@ } }, "body": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "maxPerm", - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 54 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "maxPerm", + "decorators": [], + "loc": { + "start": { + "line": 62, + "column": 54 + }, + "end": { + "line": 62, + "column": 61 + } + } }, - "end": { - "line": 62, - "column": 61 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 62 + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 62, + "column": 62 + }, + "end": { + "line": 62, + "column": 63 + } + } }, - "end": { - "line": 62, - "column": 63 + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 62, + "column": 54 + }, + "end": { + "line": 62, + "column": 64 + } } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 62, - "column": 54 }, - "end": { - "line": 62, - "column": 64 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "perm1", - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 67 + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "perm1", + "decorators": [], + "loc": { + "start": { + "line": 62, + "column": 67 + }, + "end": { + "line": 62, + "column": 72 + } + } }, - "end": { - "line": 62, - "column": 72 + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 62, + "column": 73 + }, + "end": { + "line": 62, + "column": 74 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 62, + "column": 67 + }, + "end": { + "line": 62, + "column": 75 + } } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], + }, "loc": { "start": { "line": 62, - "column": 73 + "column": 54 }, "end": { "line": 62, - "column": 74 + "column": 75 } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 62, - "column": 67 + "column": 54 }, "end": { "line": 62, - "column": 75 + "column": 76 } } - }, - "loc": { - "start": { - "line": 62, - "column": 54 - }, - "end": { - "line": 62, - "column": 75 - } } - }, + ], "loc": { "start": { "line": 62, "column": 54 }, "end": { - "line": 62, - "column": 76 + "line": 63, + "column": 18 } } }, @@ -3634,8 +3679,8 @@ "column": 21 }, "end": { - "line": 62, - "column": 76 + "line": 63, + "column": 18 } } } @@ -3753,30 +3798,45 @@ } }, "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "maxFlipsCount", - "decorators": [], - "loc": { - "start": { - "line": 67, - "column": 36 + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "maxFlipsCount", + "decorators": [], + "loc": { + "start": { + "line": 67, + "column": 36 + }, + "end": { + "line": 67, + "column": 49 + } + } }, - "end": { - "line": 67, - "column": 49 + "loc": { + "start": { + "line": 67, + "column": 29 + }, + "end": { + "line": 67, + "column": 50 + } } } - }, + ], "loc": { "start": { "line": 67, "column": 29 }, "end": { - "line": 67, - "column": 50 + "line": 68, + "column": 20 } } }, @@ -3787,8 +3847,8 @@ "column": 17 }, "end": { - "line": 67, - "column": 50 + "line": 68, + "column": 20 } } }, @@ -4618,16 +4678,31 @@ } }, "consequent": { - "type": "BreakStatement", - "label": null, + "type": "BlockStatement", + "statements": [ + { + "type": "BreakStatement", + "label": null, + "loc": { + "start": { + "line": 78, + "column": 35 + }, + "end": { + "line": 78, + "column": 41 + } + } + } + ], "loc": { "start": { "line": 78, "column": 35 }, "end": { - "line": 78, - "column": 41 + "line": 79, + "column": 18 } } }, @@ -4638,8 +4713,8 @@ "column": 17 }, "end": { - "line": 78, - "column": 41 + "line": 79, + "column": 18 } } }, diff --git a/ets2panda/test/parser/ets/AccessNSieve-expected.txt b/ets2panda/test/parser/ets/AccessNSieve-expected.txt index 7638c0a7f0..05d1339712 100644 --- a/ets2panda/test/parser/ets/AccessNSieve-expected.txt +++ b/ets2panda/test/parser/ets/AccessNSieve-expected.txt @@ -1527,18 +1527,77 @@ "type": "BlockStatement", "statements": [ { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "AccessNSieve", - "decorators": [], + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "AccessNSieve", + "decorators": [], + "loc": { + "start": { + "line": 36, + "column": 11 + }, + "end": { + "line": 36, + "column": 23 + } + } + }, + "property": { + "type": "Identifier", + "name": "isPrime", + "decorators": [], + "loc": { + "start": { + "line": 36, + "column": 24 + }, + "end": { + "line": 36, + "column": 31 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 36, + "column": 11 + }, + "end": { + "line": 36, + "column": 31 + } + } + }, + "property": { + "type": "Identifier", + "name": "k", + "decorators": [], + "loc": { + "start": { + "line": 36, + "column": 32 + }, + "end": { + "line": 36, + "column": 33 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 36, @@ -1546,27 +1605,24 @@ }, "end": { "line": 36, - "column": 23 + "column": 34 } } }, - "property": { - "type": "Identifier", - "name": "isPrime", - "decorators": [], + "right": { + "type": "BooleanLiteral", + "value": false, "loc": { "start": { "line": 36, - "column": 24 + "column": 37 }, "end": { "line": 36, - "column": 31 + "column": 42 } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 36, @@ -1574,27 +1630,10 @@ }, "end": { "line": 36, - "column": 31 + "column": 42 } } }, - "property": { - "type": "Identifier", - "name": "k", - "decorators": [], - "loc": { - "start": { - "line": 36, - "column": 32 - }, - "end": { - "line": 36, - "column": 33 - } - } - }, - "computed": true, - "optional": false, "loc": { "start": { "line": 36, @@ -1602,43 +1641,19 @@ }, "end": { "line": 36, - "column": 34 - } - } - }, - "right": { - "type": "BooleanLiteral", - "value": false, - "loc": { - "start": { - "line": 36, - "column": 37 - }, - "end": { - "line": 36, - "column": 42 + "column": 43 } } - }, - "loc": { - "start": { - "line": 36, - "column": 11 - }, - "end": { - "line": 36, - "column": 42 - } } - }, + ], "loc": { "start": { - "line": 36, - "column": 11 + "line": 35, + "column": 50 }, "end": { - "line": 36, - "column": 43 + "line": 37, + "column": 10 } } } @@ -1649,8 +1664,8 @@ "column": 50 }, "end": { - "line": 37, - "column": 10 + "line": 38, + "column": 14 } } }, @@ -1660,8 +1675,8 @@ "column": 9 }, "end": { - "line": 37, - "column": 10 + "line": 38, + "column": 14 } } }, diff --git a/ets2panda/test/parser/ets/BitopsNSieveBits-expected.txt b/ets2panda/test/parser/ets/BitopsNSieveBits-expected.txt index bd39afb2f6..58627a9b9c 100644 --- a/ets2panda/test/parser/ets/BitopsNSieveBits-expected.txt +++ b/ets2panda/test/parser/ets/BitopsNSieveBits-expected.txt @@ -1261,151 +1261,176 @@ "type": "BlockStatement", "statements": [ { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "&=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "isPrime", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 11 - }, - "end": { - "line": 29, - "column": 18 - } - } - }, - "property": { - "type": "BinaryExpression", - "operator": ">>", + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "&=", "left": { - "type": "Identifier", - "name": "j", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 19 - }, - "end": { - "line": 29, - "column": 20 + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "isPrime", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 11 + }, + "end": { + "line": 29, + "column": 18 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 5, - "loc": { - "start": { - "line": 29, - "column": 24 + }, + "property": { + "type": "BinaryExpression", + "operator": ">>", + "left": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 19 + }, + "end": { + "line": 29, + "column": 20 + } + } }, - "end": { - "line": 29, - "column": 25 + "right": { + "type": "NumberLiteral", + "value": 5, + "loc": { + "start": { + "line": 29, + "column": 24 + }, + "end": { + "line": 29, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 19 + }, + "end": { + "line": 29, + "column": 25 + } } - } - }, - "loc": { - "start": { - "line": 29, - "column": 19 }, - "end": { - "line": 29, - "column": 25 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 29, - "column": 11 - }, - "end": { - "line": 29, - "column": 26 - } - } - }, - "right": { - "type": "UnaryExpression", - "operator": "~", - "prefix": true, - "argument": { - "type": "BinaryExpression", - "operator": "<<", - "left": { - "type": "NumberLiteral", - "value": 1, + "computed": true, + "optional": false, "loc": { "start": { "line": 29, - "column": 32 + "column": 11 }, "end": { "line": 29, - "column": 33 + "column": 26 } } }, "right": { - "type": "BinaryExpression", - "operator": "&", - "left": { - "type": "Identifier", - "name": "j", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 38 + "type": "UnaryExpression", + "operator": "~", + "prefix": true, + "argument": { + "type": "BinaryExpression", + "operator": "<<", + "left": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 29, + "column": 32 + }, + "end": { + "line": 29, + "column": 33 + } + } + }, + "right": { + "type": "BinaryExpression", + "operator": "&", + "left": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 38 + }, + "end": { + "line": 29, + "column": 39 + } + } }, - "end": { - "line": 29, - "column": 39 + "right": { + "type": "NumberLiteral", + "value": 31, + "loc": { + "start": { + "line": 29, + "column": 42 + }, + "end": { + "line": 29, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 37 + }, + "end": { + "line": 29, + "column": 45 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 31, + }, "loc": { "start": { "line": 29, - "column": 42 + "column": 31 }, "end": { "line": 29, - "column": 44 + "column": 46 } } }, "loc": { "start": { "line": 29, - "column": 37 + "column": 30 }, "end": { "line": 29, - "column": 45 + "column": 46 } } }, "loc": { "start": { "line": 29, - "column": 31 + "column": 11 }, "end": { "line": 29, @@ -1416,33 +1441,23 @@ "loc": { "start": { "line": 29, - "column": 30 + "column": 11 }, "end": { "line": 29, - "column": 46 + "column": 47 } } - }, - "loc": { - "start": { - "line": 29, - "column": 11 - }, - "end": { - "line": 29, - "column": 46 - } } - }, + ], "loc": { "start": { - "line": 29, - "column": 11 + "line": 28, + "column": 49 }, "end": { - "line": 29, - "column": 47 + "line": 30, + "column": 10 } } } @@ -1453,8 +1468,8 @@ "column": 49 }, "end": { - "line": 30, - "column": 10 + "line": 31, + "column": 8 } } }, @@ -1464,8 +1479,8 @@ "column": 9 }, "end": { - "line": 30, - "column": 10 + "line": 31, + "column": 8 } } } diff --git a/ets2panda/test/parser/ets/break-expected.txt b/ets2panda/test/parser/ets/break-expected.txt index fa59f207e9..c304192b48 100644 --- a/ets2panda/test/parser/ets/break-expected.txt +++ b/ets2panda/test/parser/ets/break-expected.txt @@ -451,16 +451,31 @@ } }, "consequent": { - "type": "BreakStatement", - "label": null, + "type": "BlockStatement", + "statements": [ + { + "type": "BreakStatement", + "label": null, + "loc": { + "start": { + "line": 19, + "column": 17 + }, + "end": { + "line": 19, + "column": 23 + } + } + } + ], "loc": { "start": { "line": 19, "column": 17 }, "end": { - "line": 19, - "column": 23 + "line": 20, + "column": 4 } } }, @@ -471,8 +486,8 @@ "column": 5 }, "end": { - "line": 19, - "column": 23 + "line": 20, + "column": 4 } } } diff --git a/ets2panda/test/parser/ets/continue-expected.txt b/ets2panda/test/parser/ets/continue-expected.txt index 7ed4b554ab..0854b014d9 100644 --- a/ets2panda/test/parser/ets/continue-expected.txt +++ b/ets2panda/test/parser/ets/continue-expected.txt @@ -451,16 +451,31 @@ } }, "consequent": { - "type": "ContinueStatement", - "label": null, + "type": "BlockStatement", + "statements": [ + { + "type": "ContinueStatement", + "label": null, + "loc": { + "start": { + "line": 19, + "column": 17 + }, + "end": { + "line": 19, + "column": 26 + } + } + } + ], "loc": { "start": { "line": 19, "column": 17 }, "end": { - "line": 19, - "column": 26 + "line": 20, + "column": 4 } } }, @@ -471,8 +486,8 @@ "column": 5 }, "end": { - "line": 19, - "column": 26 + "line": 20, + "column": 4 } } } diff --git a/ets2panda/test/parser/ets/forofUnboxing-expected.txt b/ets2panda/test/parser/ets/forofUnboxing-expected.txt index a70e8ee94f..c9fd2e48f0 100644 --- a/ets2panda/test/parser/ets/forofUnboxing-expected.txt +++ b/ets2panda/test/parser/ets/forofUnboxing-expected.txt @@ -826,29 +826,44 @@ } }, "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 20, - "column": 33 + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 20, + "column": 33 + }, + "end": { + "line": 20, + "column": 34 + } + } }, - "end": { - "line": 20, - "column": 34 + "loc": { + "start": { + "line": 20, + "column": 26 + }, + "end": { + "line": 20, + "column": 35 + } } } - }, + ], "loc": { "start": { "line": 20, "column": 26 }, "end": { - "line": 20, - "column": 35 + "line": 21, + "column": 11 } } }, @@ -859,8 +874,8 @@ "column": 5 }, "end": { - "line": 20, - "column": 35 + "line": 21, + "column": 11 } } }, diff --git a/ets2panda/test/parser/ets/generic_function-expected.txt b/ets2panda/test/parser/ets/generic_function-expected.txt index 51bffc58e1..11c14fd1cf 100644 --- a/ets2panda/test/parser/ets/generic_function-expected.txt +++ b/ets2panda/test/parser/ets/generic_function-expected.txt @@ -738,77 +738,102 @@ } }, "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "ConditionalExpression", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "y", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 25 + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "y", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 25 + }, + "end": { + "line": 21, + "column": 26 + } + } }, - "end": { - "line": 21, - "column": 26 - } - } - }, - "right": { - "type": "NullLiteral", - "value": null, - "loc": { - "start": { - "line": 21, - "column": 30 + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 21, + "column": 30 + }, + "end": { + "line": 21, + "column": 34 + } + } }, - "end": { - "line": 21, - "column": 34 + "loc": { + "start": { + "line": 21, + "column": 25 + }, + "end": { + "line": 21, + "column": 34 + } } - } - }, - "loc": { - "start": { - "line": 21, - "column": 25 }, - "end": { - "line": 21, - "column": 34 - } - } - }, - "consequent": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 21, - "column": 37 + "consequent": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 21, + "column": 37 + }, + "end": { + "line": 21, + "column": 38 + } + } + }, + "alternate": { + "type": "UnaryExpression", + "operator": "-", + "prefix": true, + "argument": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 21, + "column": 42 + }, + "end": { + "line": 21, + "column": 43 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 41 + }, + "end": { + "line": 21, + "column": 43 + } + } }, - "end": { - "line": 21, - "column": 38 - } - } - }, - "alternate": { - "type": "UnaryExpression", - "operator": "-", - "prefix": true, - "argument": { - "type": "NumberLiteral", - "value": 1, "loc": { "start": { "line": 21, - "column": 42 + "column": 25 }, "end": { "line": 21, @@ -819,33 +844,23 @@ "loc": { "start": { "line": 21, - "column": 41 + "column": 18 }, "end": { "line": 21, - "column": 43 + "column": 44 } } - }, - "loc": { - "start": { - "line": 21, - "column": 25 - }, - "end": { - "line": 21, - "column": 43 - } } - }, + ], "loc": { "start": { "line": 21, "column": 18 }, "end": { - "line": 21, - "column": 44 + "line": 22, + "column": 5 } } }, @@ -856,8 +871,8 @@ "column": 3 }, "end": { - "line": 21, - "column": 44 + "line": 22, + "column": 5 } } }, @@ -907,29 +922,44 @@ } }, "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 22, - "column": 25 + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 22, + "column": 25 + }, + "end": { + "line": 22, + "column": 26 + } + } }, - "end": { - "line": 22, - "column": 26 + "loc": { + "start": { + "line": 22, + "column": 18 + }, + "end": { + "line": 22, + "column": 27 + } } } - }, + ], "loc": { "start": { "line": 22, "column": 18 }, "end": { - "line": 22, - "column": 27 + "line": 23, + "column": 9 } } }, @@ -940,8 +970,8 @@ "column": 3 }, "end": { - "line": 22, - "column": 27 + "line": 23, + "column": 9 } } }, diff --git a/ets2panda/test/parser/ets/if-expected.txt b/ets2panda/test/parser/ets/if-expected.txt index fcf38d2ba6..4331ef54b0 100644 --- a/ets2panda/test/parser/ets/if-expected.txt +++ b/ets2panda/test/parser/ets/if-expected.txt @@ -412,58 +412,73 @@ } }, "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 16 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 17 + } + } }, - "end": { - "line": 22, - "column": 17 + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 22, + "column": 20 + }, + "end": { + "line": 22, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 21 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 1, + }, "loc": { "start": { "line": 22, - "column": 20 + "column": 16 }, "end": { "line": 22, - "column": 21 + "column": 22 } } - }, - "loc": { - "start": { - "line": 22, - "column": 16 - }, - "end": { - "line": 22, - "column": 21 - } } - }, + ], "loc": { "start": { "line": 22, "column": 16 }, "end": { - "line": 22, - "column": 22 + "line": 23, + "column": 11 } } }, @@ -474,8 +489,8 @@ "column": 9 }, "end": { - "line": 22, - "column": 22 + "line": 23, + "column": 11 } } }, @@ -497,114 +512,144 @@ } }, "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 16 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 17 + } + } }, - "end": { - "line": 23, - "column": 17 + "right": { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 23, + "column": 20 + }, + "end": { + "line": 23, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 21 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 2, + }, "loc": { "start": { "line": 23, - "column": 20 + "column": 16 }, "end": { "line": 23, - "column": 21 + "column": 22 } } - }, - "loc": { - "start": { - "line": 23, - "column": 16 - }, - "end": { - "line": 23, - "column": 21 - } } - }, + ], "loc": { "start": { "line": 23, "column": 16 }, "end": { - "line": 23, - "column": 22 + "line": 24, + "column": 13 } } }, "alternate": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 24, - "column": 14 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 14 + }, + "end": { + "line": 24, + "column": 15 + } + } }, - "end": { - "line": 24, - "column": 15 + "right": { + "type": "NumberLiteral", + "value": 3, + "loc": { + "start": { + "line": 24, + "column": 18 + }, + "end": { + "line": 24, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 14 + }, + "end": { + "line": 24, + "column": 19 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 3, + }, "loc": { "start": { "line": 24, - "column": 18 + "column": 14 }, "end": { "line": 24, - "column": 19 + "column": 20 } } - }, - "loc": { - "start": { - "line": 24, - "column": 14 - }, - "end": { - "line": 24, - "column": 19 - } } - }, + ], "loc": { "start": { "line": 24, "column": 14 }, "end": { - "line": 24, - "column": 20 + "line": 25, + "column": 11 } } }, @@ -614,8 +659,8 @@ "column": 9 }, "end": { - "line": 24, - "column": 20 + "line": 25, + "column": 11 } } }, @@ -1075,58 +1120,73 @@ } }, "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 37, - "column": 16 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 37, + "column": 16 + }, + "end": { + "line": 37, + "column": 17 + } + } }, - "end": { - "line": 37, - "column": 17 + "right": { + "type": "NumberLiteral", + "value": 7, + "loc": { + "start": { + "line": 37, + "column": 20 + }, + "end": { + "line": 37, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 16 + }, + "end": { + "line": 37, + "column": 21 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 7, + }, "loc": { "start": { "line": 37, - "column": 20 + "column": 16 }, "end": { "line": 37, - "column": 21 + "column": 22 } } - }, - "loc": { - "start": { - "line": 37, - "column": 16 - }, - "end": { - "line": 37, - "column": 21 - } } - }, + ], "loc": { "start": { "line": 37, "column": 16 }, "end": { - "line": 37, - "column": 22 + "line": 38, + "column": 13 } } }, @@ -1413,58 +1473,73 @@ } }, "alternate": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 46, - "column": 14 - }, - "end": { - "line": 46, - "column": 15 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 46, + "column": 14 + }, + "end": { + "line": 46, + "column": 15 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 10, + "loc": { + "start": { + "line": 46, + "column": 18 + }, + "end": { + "line": 46, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 46, + "column": 14 + }, + "end": { + "line": 46, + "column": 20 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 10, + }, "loc": { "start": { "line": 46, - "column": 18 + "column": 14 }, "end": { "line": 46, - "column": 20 + "column": 21 } } - }, - "loc": { - "start": { - "line": 46, - "column": 14 - }, - "end": { - "line": 46, - "column": 20 - } } - }, + ], "loc": { "start": { "line": 46, "column": 14 }, "end": { - "line": 46, - "column": 21 + "line": 47, + "column": 12 } } }, @@ -1474,8 +1549,8 @@ "column": 9 }, "end": { - "line": 46, - "column": 21 + "line": 47, + "column": 12 } } }, @@ -1568,142 +1643,187 @@ } }, "consequent": { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "p", - "decorators": [], - "loc": { - "start": { - "line": 48, - "column": 20 - }, - "end": { - "line": 48, - "column": 21 - } - } - }, - "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { "type": "Identifier", - "name": "a", + "name": "p", "decorators": [], "loc": { "start": { "line": 48, - "column": 23 + "column": 20 }, "end": { "line": 48, - "column": 24 + "column": 21 } } }, - "right": { - "type": "NumberLiteral", - "value": 11, - "loc": { - "start": { - "line": 48, - "column": 27 - }, - "end": { - "line": 48, - "column": 29 + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 48, + "column": 23 + }, + "end": { + "line": 48, + "column": 24 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 11, + "loc": { + "start": { + "line": 48, + "column": 27 + }, + "end": { + "line": 48, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 48, + "column": 23 + }, + "end": { + "line": 48, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 48, + "column": 23 + }, + "end": { + "line": 48, + "column": 30 + } + } } - } - }, - "loc": { - "start": { - "line": 48, - "column": 23 - }, - "end": { - "line": 48, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 48, - "column": 23 - }, - "end": { - "line": 48, - "column": 30 - } - } - }, - "alternate": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], + ], "loc": { "start": { - "line": 49, - "column": 14 + "line": 48, + "column": 23 }, "end": { "line": 49, - "column": 15 + "column": 13 } } }, - "right": { - "type": "NumberLiteral", - "value": 12, + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 49, + "column": 14 + }, + "end": { + "line": 49, + "column": 15 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 12, + "loc": { + "start": { + "line": 49, + "column": 18 + }, + "end": { + "line": 49, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 49, + "column": 14 + }, + "end": { + "line": 49, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 49, + "column": 14 + }, + "end": { + "line": 49, + "column": 21 + } + } + } + ], "loc": { "start": { "line": 49, - "column": 18 + "column": 14 }, "end": { - "line": 49, - "column": 20 + "line": 50, + "column": 11 } } }, "loc": { "start": { - "line": 49, - "column": 14 + "line": 48, + "column": 16 }, "end": { - "line": 49, - "column": 20 + "line": 50, + "column": 11 } } - }, - "loc": { - "start": { - "line": 49, - "column": 14 - }, - "end": { - "line": 49, - "column": 21 - } } - }, + ], "loc": { "start": { "line": 48, "column": 16 }, "end": { - "line": 49, - "column": 21 + "line": 50, + "column": 11 } } }, @@ -1714,8 +1834,8 @@ "column": 9 }, "end": { - "line": 49, - "column": 21 + "line": 50, + "column": 11 } } }, @@ -1737,158 +1857,188 @@ } }, "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 50, - "column": 16 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 50, + "column": 16 + }, + "end": { + "line": 50, + "column": 17 + } + } }, - "end": { - "line": 50, - "column": 17 + "right": { + "type": "NumberLiteral", + "value": 13, + "loc": { + "start": { + "line": 50, + "column": 20 + }, + "end": { + "line": 50, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 50, + "column": 16 + }, + "end": { + "line": 50, + "column": 22 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 13, + }, "loc": { "start": { "line": 50, - "column": 20 + "column": 16 }, "end": { "line": 50, - "column": 22 + "column": 23 } } - }, - "loc": { - "start": { - "line": 50, - "column": 16 - }, - "end": { - "line": 50, - "column": 22 - } } - }, + ], "loc": { "start": { "line": 50, "column": 16 }, "end": { - "line": 50, - "column": 23 + "line": 51, + "column": 13 } } }, "alternate": { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "p", - "decorators": [], - "loc": { - "start": { - "line": 51, - "column": 18 + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "Identifier", + "name": "p", + "decorators": [], + "loc": { + "start": { + "line": 51, + "column": 18 + }, + "end": { + "line": 51, + "column": 19 + } + } }, - "end": { - "line": 51, - "column": 19 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 13 + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 52, + "column": 13 + }, + "end": { + "line": 52, + "column": 14 + } + } }, - "end": { - "line": 52, - "column": 14 + "right": { + "type": "NumberLiteral", + "value": 14, + "loc": { + "start": { + "line": 52, + "column": 17 + }, + "end": { + "line": 52, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 52, + "column": 13 + }, + "end": { + "line": 52, + "column": 19 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 14, + }, "loc": { "start": { "line": 52, - "column": 17 + "column": 13 }, "end": { "line": 52, - "column": 19 + "column": 20 } } - }, - "loc": { - "start": { - "line": 52, - "column": 13 - }, - "end": { - "line": 52, - "column": 19 - } } - }, + ], "loc": { "start": { - "line": 52, - "column": 13 + "line": 51, + "column": 21 }, "end": { - "line": 52, - "column": 20 + "line": 53, + "column": 10 } } - } - ], - "loc": { - "start": { - "line": 51, - "column": 21 }, - "end": { - "line": 53, - "column": 10 + "alternate": null, + "loc": { + "start": { + "line": 51, + "column": 14 + }, + "end": { + "line": 53, + "column": 10 + } } } - }, - "alternate": null, + ], "loc": { "start": { "line": 51, "column": 14 }, "end": { - "line": 53, - "column": 10 + "line": 54, + "column": 11 } } }, @@ -1898,8 +2048,8 @@ "column": 9 }, "end": { - "line": 53, - "column": 10 + "line": 54, + "column": 11 } } }, @@ -1921,58 +2071,73 @@ } }, "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 54, - "column": 16 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 54, + "column": 16 + }, + "end": { + "line": 54, + "column": 17 + } + } }, - "end": { - "line": 54, - "column": 17 + "right": { + "type": "NumberLiteral", + "value": 15, + "loc": { + "start": { + "line": 54, + "column": 20 + }, + "end": { + "line": 54, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 54, + "column": 16 + }, + "end": { + "line": 54, + "column": 22 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 15, + }, "loc": { "start": { "line": 54, - "column": 20 + "column": 16 }, "end": { "line": 54, - "column": 22 + "column": 23 } } - }, - "loc": { - "start": { - "line": 54, - "column": 16 - }, - "end": { - "line": 54, - "column": 22 - } } - }, + ], "loc": { "start": { "line": 54, "column": 16 }, "end": { - "line": 54, - "column": 23 + "line": 55, + "column": 13 } } }, @@ -1997,114 +2162,144 @@ } }, "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 56, - "column": 20 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 56, + "column": 20 + }, + "end": { + "line": 56, + "column": 21 + } + } }, - "end": { - "line": 56, - "column": 21 + "right": { + "type": "NumberLiteral", + "value": 16, + "loc": { + "start": { + "line": 56, + "column": 24 + }, + "end": { + "line": 56, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 56, + "column": 20 + }, + "end": { + "line": 56, + "column": 26 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 16, + }, "loc": { "start": { "line": 56, - "column": 24 + "column": 20 }, "end": { "line": 56, - "column": 26 + "column": 27 } } - }, - "loc": { - "start": { - "line": 56, - "column": 20 - }, - "end": { - "line": 56, - "column": 26 - } } - }, + ], "loc": { "start": { "line": 56, "column": 20 }, "end": { - "line": 56, - "column": 27 + "line": 57, + "column": 17 } } }, "alternate": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 57, - "column": 18 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 57, + "column": 18 + }, + "end": { + "line": 57, + "column": 19 + } + } }, - "end": { - "line": 57, - "column": 19 + "right": { + "type": "NumberLiteral", + "value": 17, + "loc": { + "start": { + "line": 57, + "column": 22 + }, + "end": { + "line": 57, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 57, + "column": 18 + }, + "end": { + "line": 57, + "column": 24 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 17, + }, "loc": { "start": { "line": 57, - "column": 22 + "column": 18 }, "end": { "line": 57, - "column": 24 + "column": 25 } } - }, - "loc": { - "start": { - "line": 57, - "column": 18 - }, - "end": { - "line": 57, - "column": 24 - } } - }, + ], "loc": { "start": { "line": 57, "column": 18 }, "end": { - "line": 57, - "column": 25 + "line": 58, + "column": 10 } } }, @@ -2114,8 +2309,8 @@ "column": 13 }, "end": { - "line": 57, - "column": 25 + "line": 58, + "column": 10 } } } @@ -2457,142 +2652,187 @@ } }, "alternate": { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "p", - "decorators": [], - "loc": { - "start": { - "line": 69, - "column": 18 - }, - "end": { - "line": 69, - "column": 19 - } - } - }, - "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { "type": "Identifier", - "name": "a", + "name": "p", "decorators": [], "loc": { "start": { "line": 69, - "column": 21 + "column": 18 }, "end": { "line": 69, - "column": 22 + "column": 19 } } }, - "right": { - "type": "NumberLiteral", - "value": 20, - "loc": { - "start": { - "line": 69, - "column": 25 - }, - "end": { - "line": 69, - "column": 27 + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 69, + "column": 21 + }, + "end": { + "line": 69, + "column": 22 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 20, + "loc": { + "start": { + "line": 69, + "column": 25 + }, + "end": { + "line": 69, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 69, + "column": 21 + }, + "end": { + "line": 69, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 69, + "column": 21 + }, + "end": { + "line": 69, + "column": 28 + } + } } - } - }, - "loc": { - "start": { - "line": 69, - "column": 21 - }, - "end": { - "line": 69, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 69, - "column": 21 - }, - "end": { - "line": 69, - "column": 28 - } - } - }, - "alternate": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "a", - "decorators": [], + ], "loc": { "start": { - "line": 70, - "column": 14 + "line": 69, + "column": 21 }, "end": { "line": 70, - "column": 15 + "column": 13 } } }, - "right": { - "type": "NumberLiteral", - "value": 21, + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 70, + "column": 14 + }, + "end": { + "line": 70, + "column": 15 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 21, + "loc": { + "start": { + "line": 70, + "column": 18 + }, + "end": { + "line": 70, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 70, + "column": 14 + }, + "end": { + "line": 70, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 70, + "column": 14 + }, + "end": { + "line": 70, + "column": 21 + } + } + } + ], "loc": { "start": { "line": 70, - "column": 18 + "column": 14 }, "end": { - "line": 70, - "column": 20 + "line": 71, + "column": 6 } } }, "loc": { "start": { - "line": 70, + "line": 69, "column": 14 }, "end": { - "line": 70, - "column": 20 + "line": 71, + "column": 6 } } - }, - "loc": { - "start": { - "line": 70, - "column": 14 - }, - "end": { - "line": 70, - "column": 21 - } } - }, + ], "loc": { "start": { "line": 69, "column": 14 }, "end": { - "line": 70, - "column": 21 + "line": 71, + "column": 6 } } }, @@ -2602,8 +2842,8 @@ "column": 9 }, "end": { - "line": 70, - "column": 21 + "line": 71, + "column": 6 } } } diff --git a/ets2panda/test/parser/ets/ifs-expected.txt b/ets2panda/test/parser/ets/ifs-expected.txt index 4073fcd3ea..6d56f24c2a 100644 --- a/ets2panda/test/parser/ets/ifs-expected.txt +++ b/ets2panda/test/parser/ets/ifs-expected.txt @@ -194,29 +194,44 @@ } }, "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 17, - "column": 21 + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 17, + "column": 21 + }, + "end": { + "line": 17, + "column": 22 + } + } }, - "end": { - "line": 17, - "column": 22 + "loc": { + "start": { + "line": 17, + "column": 14 + }, + "end": { + "line": 17, + "column": 23 + } } } - }, + ], "loc": { "start": { "line": 17, "column": 14 }, "end": { - "line": 17, - "column": 23 + "line": 18, + "column": 5 } } }, @@ -227,8 +242,8 @@ "column": 3 }, "end": { - "line": 17, - "column": 23 + "line": 18, + "column": 5 } } }, @@ -249,29 +264,44 @@ } }, "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 18, - "column": 21 + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 18, + "column": 21 + }, + "end": { + "line": 18, + "column": 22 + } + } }, - "end": { - "line": 18, - "column": 22 + "loc": { + "start": { + "line": 18, + "column": 14 + }, + "end": { + "line": 18, + "column": 23 + } } } - }, + ], "loc": { "start": { "line": 18, "column": 14 }, "end": { - "line": 18, - "column": 23 + "line": 19, + "column": 7 } } }, @@ -295,164 +325,254 @@ } }, "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 20, - "column": 23 + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 20, + "column": 23 + }, + "end": { + "line": 20, + "column": 24 + } + } }, - "end": { - "line": 20, - "column": 24 + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 25 + } } } - }, + ], "loc": { "start": { "line": 20, "column": 16 }, "end": { - "line": 20, - "column": 25 + "line": 21, + "column": 9 } } }, "alternate": { - "type": "IfStatement", - "test": { - "type": "BooleanLiteral", - "value": false, - "loc": { - "start": { - "line": 22, - "column": 11 - }, - "end": { - "line": 22, - "column": 16 - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 3, - "loc": { - "start": { - "line": 22, - "column": 25 - }, - "end": { - "line": 22, - "column": 26 + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BooleanLiteral", + "value": false, + "loc": { + "start": { + "line": 22, + "column": 11 + }, + "end": { + "line": 22, + "column": 16 + } } - } - }, - "loc": { - "start": { - "line": 22, - "column": 18 }, - "end": { - "line": 22, - "column": 27 - } - } - }, - "alternate": { - "type": "IfStatement", - "test": { - "type": "BooleanLiteral", - "value": false, - "loc": { - "start": { - "line": 23, - "column": 16 - }, - "end": { - "line": 23, - "column": 21 - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 4, + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 3, + "loc": { + "start": { + "line": 22, + "column": 25 + }, + "end": { + "line": 22, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 18 + }, + "end": { + "line": 22, + "column": 27 + } + } + } + ], "loc": { "start": { - "line": 23, - "column": 30 + "line": 22, + "column": 18 }, "end": { "line": 23, - "column": 31 + "column": 11 } } }, - "loc": { - "start": { - "line": 23, - "column": 23 - }, - "end": { - "line": 23, - "column": 32 - } - } - }, - "alternate": { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 5, + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BooleanLiteral", + "value": false, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 21 + } + } + }, + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 4, + "loc": { + "start": { + "line": 23, + "column": 30 + }, + "end": { + "line": 23, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 23 + }, + "end": { + "line": 23, + "column": 32 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 23 + }, + "end": { + "line": 24, + "column": 11 + } + } + }, + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 5, + "loc": { + "start": { + "line": 24, + "column": 19 + }, + "end": { + "line": 24, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 12 + }, + "end": { + "line": 24, + "column": 21 + } + } + } + ], + "loc": { + "start": { + "line": 24, + "column": 12 + }, + "end": { + "line": 25, + "column": 4 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 25, + "column": 4 + } + } + } + ], "loc": { "start": { - "line": 24, - "column": 19 + "line": 23, + "column": 12 }, "end": { - "line": 24, - "column": 20 + "line": 25, + "column": 4 } } }, "loc": { "start": { - "line": 24, - "column": 12 + "line": 22, + "column": 7 }, "end": { - "line": 24, - "column": 21 + "line": 25, + "column": 4 } } - }, - "loc": { - "start": { - "line": 23, - "column": 12 - }, - "end": { - "line": 24, - "column": 21 - } } - }, + ], "loc": { "start": { "line": 22, "column": 7 }, "end": { - "line": 24, - "column": 21 + "line": 25, + "column": 4 } } }, @@ -462,8 +582,8 @@ "column": 5 }, "end": { - "line": 24, - "column": 21 + "line": 25, + "column": 4 } } } diff --git a/ets2panda/test/parser/ets/instanceof-expected.txt b/ets2panda/test/parser/ets/instanceof-expected.txt index 9c79f62b0f..9f82297a83 100644 --- a/ets2panda/test/parser/ets/instanceof-expected.txt +++ b/ets2panda/test/parser/ets/instanceof-expected.txt @@ -362,292 +362,322 @@ } }, "alternate": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "instanceof", - "left": { - "type": "Identifier", - "name": "v", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 14 - }, - "end": { - "line": 19, - "column": 15 - } - } - }, - "right": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 19, - "column": 27 - }, - "end": { - "line": 19, - "column": 30 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 32 - }, - "end": { - "line": 19, - "column": 33 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 14 - }, - "end": { - "line": 19, - "column": 33 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 2, + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "v", + "decorators": [], "loc": { "start": { - "line": 20, - "column": 12 + "line": 19, + "column": 14 }, "end": { - "line": 20, - "column": 13 + "line": 19, + "column": 15 } } }, - "loc": { - "start": { - "line": 20, - "column": 5 + "right": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 19, + "column": 27 + }, + "end": { + "line": 19, + "column": 30 + } + } }, - "end": { - "line": 20, - "column": 14 + "loc": { + "start": { + "line": 19, + "column": 32 + }, + "end": { + "line": 19, + "column": 33 + } } - } - } - ], - "loc": { - "start": { - "line": 19, - "column": 34 - }, - "end": { - "line": 21, - "column": 4 - } - } - }, - "alternate": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "instanceof", - "left": { - "type": "Identifier", - "name": "v", - "decorators": [], + }, "loc": { "start": { - "line": 21, + "line": 19, "column": 14 }, "end": { - "line": 21, - "column": 15 + "line": 19, + "column": 33 } } }, - "right": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Double", - "decorators": [], + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 2, "loc": { "start": { - "line": 21, - "column": 27 + "line": 20, + "column": 12 }, "end": { - "line": 21, - "column": 33 + "line": 20, + "column": 13 } } }, "loc": { "start": { - "line": 21, - "column": 27 + "line": 20, + "column": 5 }, "end": { - "line": 21, - "column": 34 + "line": 20, + "column": 14 } } - }, - "loc": { - "start": { - "line": 21, - "column": 27 - }, - "end": { - "line": 21, - "column": 34 - } } - }, + ], "loc": { "start": { - "line": 21, - "column": 35 + "line": 19, + "column": 34 }, "end": { "line": 21, - "column": 36 + "column": 4 } } }, - "loc": { - "start": { - "line": 21, - "column": 14 - }, - "end": { - "line": 21, - "column": 36 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 3, - "loc": { - "start": { - "line": 22, - "column": 12 + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "v", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 14 + }, + "end": { + "line": 21, + "column": 15 + } + } }, - "end": { - "line": 22, - "column": 13 + "right": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Double", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 27 + }, + "end": { + "line": 21, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 27 + }, + "end": { + "line": 21, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 27 + }, + "end": { + "line": 21, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 35 + }, + "end": { + "line": 21, + "column": 36 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 14 + }, + "end": { + "line": 21, + "column": 36 + } + } + }, + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 3, + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 22, + "column": 13 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 5 + }, + "end": { + "line": 22, + "column": 14 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 37 + }, + "end": { + "line": 23, + "column": 4 + } + } + }, + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 4, + "loc": { + "start": { + "line": 24, + "column": 12 + }, + "end": { + "line": 24, + "column": 13 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 14 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 10 + }, + "end": { + "line": 25, + "column": 4 + } } - } - }, - "loc": { - "start": { - "line": 22, - "column": 5 }, - "end": { - "line": 22, - "column": 14 - } - } - } - ], - "loc": { - "start": { - "line": 21, - "column": 37 - }, - "end": { - "line": 23, - "column": 4 - } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 4, "loc": { "start": { - "line": 24, - "column": 12 + "line": 21, + "column": 10 }, "end": { - "line": 24, - "column": 13 + "line": 25, + "column": 4 } } + } + ], + "loc": { + "start": { + "line": 21, + "column": 10 }, - "loc": { - "start": { - "line": 24, - "column": 5 - }, - "end": { - "line": 24, - "column": 14 - } + "end": { + "line": 26, + "column": 2 } } - ], + }, "loc": { "start": { - "line": 23, + "line": 19, "column": 10 }, "end": { - "line": 25, - "column": 4 + "line": 26, + "column": 2 } } - }, - "loc": { - "start": { - "line": 21, - "column": 10 - }, - "end": { - "line": 25, - "column": 4 - } } - }, + ], "loc": { "start": { "line": 19, "column": 10 }, "end": { - "line": 25, - "column": 4 + "line": 26, + "column": 2 } } }, @@ -657,8 +687,8 @@ "column": 3 }, "end": { - "line": 25, - "column": 4 + "line": 26, + "column": 2 } } } diff --git a/ets2panda/test/parser/ets/labeledDoWhileStatement-expected.txt b/ets2panda/test/parser/ets/labeledDoWhileStatement-expected.txt index 07b3af4cc8..9c91800d88 100644 --- a/ets2panda/test/parser/ets/labeledDoWhileStatement-expected.txt +++ b/ets2panda/test/parser/ets/labeledDoWhileStatement-expected.txt @@ -258,228 +258,243 @@ "type": "BlockStatement", "statements": [ { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 5 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "+=", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 6 + } + } }, - "end": { - "line": 21, - "column": 6 + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 11 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 1, + }, "loc": { "start": { "line": 21, - "column": 10 + "column": 5 }, "end": { "line": 21, - "column": 11 + "column": 12 } } }, - "loc": { - "start": { - "line": 21, - "column": 5 - }, - "end": { - "line": 21, - "column": 11 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 5 - }, - "end": { - "line": 21, - "column": 12 - } - } - }, - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "!=", - "left": { - "type": "BinaryExpression", - "operator": "/", - "left": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 9 + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!=", + "left": { + "type": "BinaryExpression", + "operator": "/", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 9 + }, + "end": { + "line": 22, + "column": 10 + } + } }, - "end": { - "line": 22, - "column": 10 + "right": { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 14 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 9 + }, + "end": { + "line": 22, + "column": 14 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 2, + }, + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 22, + "column": 18 + }, + "end": { + "line": 22, + "column": 19 + } + } + }, "loc": { "start": { "line": 22, - "column": 13 + "column": 9 }, "end": { "line": 22, - "column": 14 + "column": 19 } } }, - "loc": { - "start": { - "line": 22, - "column": 9 - }, - "end": { - "line": 22, - "column": 14 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 22, - "column": 18 - }, - "end": { - "line": 22, - "column": 19 - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 9 - }, - "end": { - "line": 22, - "column": 19 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 16 + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ContinueStatement", + "label": { + "type": "Identifier", + "name": "label1", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 22 + } + } }, - "end": { - "line": 23, - "column": 22 + "loc": { + "start": { + "line": 23, + "column": 7 + }, + "end": { + "line": 23, + "column": 23 + } } } - }, + ], "loc": { "start": { - "line": 23, - "column": 7 + "line": 22, + "column": 21 }, "end": { - "line": 23, - "column": 23 + "line": 24, + "column": 6 } } - } - ], - "loc": { - "start": { - "line": 22, - "column": 21 }, - "end": { - "line": 24, - "column": 6 - } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ - { - "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 13 + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "BreakStatement", + "label": { + "type": "Identifier", + "name": "label1", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 13 + }, + "end": { + "line": 25, + "column": 19 + } + } }, - "end": { - "line": 25, - "column": 19 + "loc": { + "start": { + "line": 25, + "column": 7 + }, + "end": { + "line": 25, + "column": 20 + } } } - }, + ], "loc": { "start": { - "line": 25, - "column": 7 + "line": 24, + "column": 12 }, "end": { - "line": 25, - "column": 20 + "line": 26, + "column": 6 } } - } - ], - "loc": { - "start": { - "line": 24, - "column": 12 }, - "end": { - "line": 26, - "column": 6 + "loc": { + "start": { + "line": 22, + "column": 5 + }, + "end": { + "line": 26, + "column": 6 + } } } - }, + ], "loc": { "start": { - "line": 22, - "column": 5 + "line": 20, + "column": 6 }, "end": { - "line": 26, - "column": 6 + "line": 27, + "column": 4 } } } @@ -491,7 +506,7 @@ }, "end": { "line": 27, - "column": 4 + "column": 10 } } }, diff --git a/ets2panda/test/parser/ets/labeledForStatement-expected.txt b/ets2panda/test/parser/ets/labeledForStatement-expected.txt index 49245fba59..a49f17d286 100644 --- a/ets2panda/test/parser/ets/labeledForStatement-expected.txt +++ b/ets2panda/test/parser/ets/labeledForStatement-expected.txt @@ -331,144 +331,159 @@ "type": "BlockStatement", "statements": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": ">", - "left": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 9 - }, - "end": { - "line": 19, - "column": 10 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 19, - "column": 13 - }, - "end": { - "line": 19, - "column": 14 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 9 - }, - "end": { - "line": 19, - "column": 14 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ContinueStatement", - "label": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": ">", + "left": { "type": "Identifier", - "name": "label1", + "name": "i", "decorators": [], "loc": { "start": { - "line": 20, - "column": 16 + "line": 19, + "column": 9 }, "end": { - "line": 20, - "column": 22 + "line": 19, + "column": 10 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 19, + "column": 13 + }, + "end": { + "line": 19, + "column": 14 } } }, "loc": { "start": { - "line": 20, - "column": 7 + "line": 19, + "column": 9 }, "end": { - "line": 20, - "column": 23 + "line": 19, + "column": 14 } } - } - ], - "loc": { - "start": { - "line": 19, - "column": 16 }, - "end": { - "line": 21, - "column": 6 - } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ - { - "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 13 + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ContinueStatement", + "label": { + "type": "Identifier", + "name": "label1", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 22 + } + } }, - "end": { - "line": 22, - "column": 19 + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 20, + "column": 23 + } } } - }, + ], "loc": { "start": { - "line": 22, - "column": 7 + "line": 19, + "column": 16 }, "end": { - "line": 22, - "column": 20 + "line": 21, + "column": 6 } } - } - ], - "loc": { - "start": { - "line": 21, - "column": 12 }, - "end": { - "line": 23, - "column": 6 + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "BreakStatement", + "label": { + "type": "Identifier", + "name": "label1", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 7 + }, + "end": { + "line": 22, + "column": 20 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 12 + }, + "end": { + "line": 23, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 23, + "column": 6 + } } } - }, + ], "loc": { "start": { - "line": 19, - "column": 5 + "line": 18, + "column": 32 }, "end": { - "line": 23, - "column": 6 + "line": 24, + "column": 4 } } } @@ -479,8 +494,8 @@ "column": 32 }, "end": { - "line": 24, - "column": 4 + "line": 26, + "column": 9 } } }, @@ -490,8 +505,8 @@ "column": 3 }, "end": { - "line": 24, - "column": 4 + "line": 26, + "column": 9 } } }, @@ -501,8 +516,8 @@ "column": 3 }, "end": { - "line": 24, - "column": 4 + "line": 26, + "column": 9 } } }, @@ -660,214 +675,239 @@ "type": "BlockStatement", "statements": [ { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 14 + }, + "end": { + "line": 28, + "column": 15 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 28, + "column": 18 + }, + "end": { + "line": 28, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 14 + }, + "end": { + "line": 28, + "column": 19 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 28, + "column": 10 + }, + "end": { + "line": 28, + "column": 19 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", "name": "j", "decorators": [], "loc": { "start": { "line": 28, - "column": 14 + "column": 21 }, "end": { "line": 28, - "column": 15 + "column": 22 } } }, - "init": { + "right": { "type": "NumberLiteral", - "value": 0, + "value": 10, "loc": { "start": { "line": 28, - "column": 18 + "column": 25 }, "end": { "line": 28, - "column": 19 + "column": 27 } } }, "loc": { "start": { "line": 28, - "column": 14 + "column": 21 }, "end": { "line": 28, - "column": 19 + "column": 27 } } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 28, - "column": 10 - }, - "end": { - "line": 28, - "column": 19 - } - } - }, - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "j", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 21 - }, - "end": { - "line": 28, - "column": 22 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 10, - "loc": { - "start": { - "line": 28, - "column": 25 - }, - "end": { - "line": 28, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 28, - "column": 21 }, - "end": { - "line": 28, - "column": 27 - } - } - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": true, - "argument": { - "type": "Identifier", - "name": "j", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 31 + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 31 + }, + "end": { + "line": 28, + "column": 32 + } + } }, - "end": { - "line": 28, - "column": 32 + "loc": { + "start": { + "line": 28, + "column": 29 + }, + "end": { + "line": 28, + "column": 32 + } } - } - }, - "loc": { - "start": { - "line": 28, - "column": 29 }, - "end": { - "line": 28, - "column": 32 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "IfStatement", - "test": { - "type": "LogicalExpression", - "operator": "||", - "left": { - "type": "BinaryExpression", - "operator": ">", - "left": { - "type": "Identifier", - "name": "j", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 11 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "LogicalExpression", + "operator": "||", + "left": { + "type": "BinaryExpression", + "operator": ">", + "left": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 11 + }, + "end": { + "line": 29, + "column": 12 + } + } }, - "end": { - "line": 29, - "column": 12 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 29, - "column": 15 + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 29, + "column": 15 + }, + "end": { + "line": 29, + "column": 16 + } + } }, - "end": { - "line": 29, - "column": 16 + "loc": { + "start": { + "line": 29, + "column": 11 + }, + "end": { + "line": 29, + "column": 16 + } } - } - }, - "loc": { - "start": { - "line": 29, - "column": 11 }, - "end": { - "line": 29, - "column": 16 - } - } - }, - "right": { - "type": "BinaryExpression", - "operator": ">", - "left": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 20 + "right": { + "type": "BinaryExpression", + "operator": ">", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 20 + }, + "end": { + "line": 29, + "column": 21 + } + } }, - "end": { - "line": 29, - "column": 21 + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 29, + "column": 24 + }, + "end": { + "line": 29, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 20 + }, + "end": { + "line": 29, + "column": 25 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 1, + }, "loc": { "start": { "line": 29, - "column": 24 + "column": 11 }, "end": { "line": 29, @@ -875,145 +915,135 @@ } } }, - "loc": { - "start": { - "line": 29, - "column": 20 - }, - "end": { - "line": 29, - "column": 25 - } - } - }, - "loc": { - "start": { - "line": 29, - "column": 11 - }, - "end": { - "line": 29, - "column": 25 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "label2", - "decorators": [], - "loc": { - "start": { - "line": 30, - "column": 18 + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ContinueStatement", + "label": { + "type": "Identifier", + "name": "label2", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 18 + }, + "end": { + "line": 30, + "column": 24 + } + } }, - "end": { - "line": 30, - "column": 24 + "loc": { + "start": { + "line": 30, + "column": 9 + }, + "end": { + "line": 30, + "column": 25 + } } } - }, + ], "loc": { "start": { - "line": 30, - "column": 9 + "line": 29, + "column": 27 }, "end": { - "line": 30, - "column": 25 + "line": 31, + "column": 8 } } - } - ], - "loc": { - "start": { - "line": 29, - "column": 27 }, - "end": { - "line": 31, - "column": 8 - } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ - { - "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label2", - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 15 + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "BreakStatement", + "label": { + "type": "Identifier", + "name": "label2", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 15 + }, + "end": { + "line": 32, + "column": 21 + } + } }, - "end": { - "line": 32, - "column": 21 + "loc": { + "start": { + "line": 32, + "column": 9 + }, + "end": { + "line": 32, + "column": 22 + } } } - }, + ], "loc": { "start": { - "line": 32, - "column": 9 + "line": 31, + "column": 14 }, "end": { - "line": 32, - "column": 22 + "line": 33, + "column": 8 } } - } - ], - "loc": { - "start": { - "line": 31, - "column": 14 }, - "end": { - "line": 33, - "column": 8 + "loc": { + "start": { + "line": 29, + "column": 7 + }, + "end": { + "line": 33, + "column": 8 + } } } - }, + ], "loc": { "start": { - "line": 29, - "column": 7 + "line": 28, + "column": 34 }, "end": { - "line": 33, - "column": 8 + "line": 34, + "column": 6 } } - } - ], - "loc": { - "start": { - "line": 28, - "column": 34 }, - "end": { - "line": 34, - "column": 6 + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 34, + "column": 6 + } } } - }, + ], "loc": { "start": { - "line": 28, - "column": 5 + "line": 27, + "column": 32 }, "end": { - "line": 34, - "column": 6 + "line": 35, + "column": 4 } } } @@ -1024,8 +1054,8 @@ "column": 32 }, "end": { - "line": 35, - "column": 4 + "line": 36, + "column": 2 } } }, @@ -1035,8 +1065,8 @@ "column": 3 }, "end": { - "line": 35, - "column": 4 + "line": 36, + "column": 2 } } }, @@ -1046,8 +1076,8 @@ "column": 3 }, "end": { - "line": 35, - "column": 4 + "line": 36, + "column": 2 } } } diff --git a/ets2panda/test/parser/ets/labeledSwitchStatement-expected.txt b/ets2panda/test/parser/ets/labeledSwitchStatement-expected.txt index 3dd740a25f..3452055fcd 100644 --- a/ets2panda/test/parser/ets/labeledSwitchStatement-expected.txt +++ b/ets2panda/test/parser/ets/labeledSwitchStatement-expected.txt @@ -460,316 +460,331 @@ "type": "BlockStatement", "statements": [ { - "type": "SwitchStatement", - "discriminant": { - "type": "Identifier", - "name": "value", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 17 - }, - "end": { - "line": 22, - "column": 22 - } - } - }, - "cases": [ + "type": "BlockStatement", + "statements": [ { - "type": "SwitchCase", - "test": { - "type": "NumberLiteral", - "value": 0, + "type": "SwitchStatement", + "discriminant": { + "type": "Identifier", + "name": "value", + "decorators": [], "loc": { "start": { - "line": 23, - "column": 18 + "line": 22, + "column": 17 }, "end": { - "line": 23, - "column": 19 + "line": 22, + "column": 22 } } }, - "consequent": [], - "loc": { - "start": { - "line": 23, - "column": 13 - }, - "end": { - "line": 23, - "column": 20 - } - } - }, - { - "type": "SwitchCase", - "test": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 24, - "column": 18 - }, - "end": { - "line": 24, - "column": 19 - } - } - }, - "consequent": [ + "cases": [ { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "result", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 17 - }, - "end": { - "line": 25, - "column": 23 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 25, - "column": 26 - }, - "end": { - "line": 25, - "column": 27 - } - } - }, + "type": "SwitchCase", + "test": { + "type": "NumberLiteral", + "value": 0, "loc": { "start": { - "line": 25, - "column": 17 + "line": 23, + "column": 18 }, "end": { - "line": 25, - "column": 27 + "line": 23, + "column": 19 } } }, + "consequent": [], "loc": { "start": { - "line": 25, - "column": 17 + "line": 23, + "column": 13 }, "end": { - "line": 25, - "column": 28 + "line": 23, + "column": 20 } } }, { - "type": "BreakStatement", - "label": null, - "loc": { - "start": { - "line": 26, - "column": 17 - }, - "end": { - "line": 26, - "column": 23 + "type": "SwitchCase", + "test": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 24, + "column": 18 + }, + "end": { + "line": 24, + "column": 19 + } } - } - } - ], - "loc": { - "start": { - "line": 24, - "column": 13 - }, - "end": { - "line": 26, - "column": 23 - } - } - }, - { - "type": "SwitchCase", - "test": { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 27, - "column": 18 }, - "end": { - "line": 27, - "column": 19 - } - } - }, - "consequent": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "result", - "decorators": [], + "consequent": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "result", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 17 + }, + "end": { + "line": 25, + "column": 23 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 25, + "column": 26 + }, + "end": { + "line": 25, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 17 + }, + "end": { + "line": 25, + "column": 27 + } + } + }, "loc": { "start": { - "line": 28, + "line": 25, "column": 17 }, "end": { - "line": 28, - "column": 23 + "line": 25, + "column": 28 } } }, - "right": { - "type": "NumberLiteral", - "value": 2, + { + "type": "BreakStatement", + "label": null, "loc": { "start": { - "line": 28, - "column": 26 + "line": 26, + "column": 17 }, "end": { - "line": 28, - "column": 27 + "line": 26, + "column": 23 } } - }, - "loc": { - "start": { - "line": 28, - "column": 17 - }, - "end": { - "line": 28, - "column": 27 - } } - }, + ], "loc": { "start": { - "line": 28, - "column": 17 + "line": 24, + "column": 13 }, "end": { - "line": 28, - "column": 28 + "line": 26, + "column": 23 } } }, { - "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], + "type": "SwitchCase", + "test": { + "type": "NumberLiteral", + "value": 2, "loc": { "start": { - "line": 29, - "column": 26 + "line": 27, + "column": 18 }, "end": { - "line": 29, - "column": 32 + "line": 27, + "column": 19 } } }, + "consequent": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "result", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 17 + }, + "end": { + "line": 28, + "column": 23 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 28, + "column": 26 + }, + "end": { + "line": 28, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 17 + }, + "end": { + "line": 28, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 17 + }, + "end": { + "line": 28, + "column": 28 + } + } + }, + { + "type": "ContinueStatement", + "label": { + "type": "Identifier", + "name": "label1", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 26 + }, + "end": { + "line": 29, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 17 + }, + "end": { + "line": 29, + "column": 33 + } + } + } + ], "loc": { "start": { - "line": 29, - "column": 17 + "line": 27, + "column": 13 }, "end": { "line": 29, "column": 33 } } - } - ], - "loc": { - "start": { - "line": 27, - "column": 13 }, - "end": { - "line": 29, - "column": 33 - } - } - }, - { - "type": "SwitchCase", - "test": null, - "consequent": [ { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "result", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 17 + "type": "SwitchCase", + "test": null, + "consequent": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "result", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 17 + }, + "end": { + "line": 31, + "column": 23 + } + } }, - "end": { - "line": 31, - "column": 23 + "right": { + "type": "NumberLiteral", + "value": 3400, + "loc": { + "start": { + "line": 31, + "column": 26 + }, + "end": { + "line": 31, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 17 + }, + "end": { + "line": 31, + "column": 30 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 3400, + }, "loc": { "start": { "line": 31, - "column": 26 + "column": 17 }, "end": { "line": 31, - "column": 30 + "column": 31 } } - }, - "loc": { - "start": { - "line": 31, - "column": 17 - }, - "end": { - "line": 31, - "column": 30 - } } - }, + ], "loc": { "start": { - "line": 31, - "column": 17 + "line": 30, + "column": 13 }, "end": { "line": 31, @@ -780,24 +795,24 @@ ], "loc": { "start": { - "line": 30, - "column": 13 + "line": 22, + "column": 9 }, "end": { - "line": 31, - "column": 31 + "line": 32, + "column": 10 } } } ], "loc": { "start": { - "line": 22, - "column": 9 + "line": 21, + "column": 34 }, "end": { - "line": 32, - "column": 10 + "line": 33, + "column": 6 } } } @@ -808,8 +823,8 @@ "column": 34 }, "end": { - "line": 33, - "column": 6 + "line": 34, + "column": 2 } } }, @@ -819,8 +834,8 @@ "column": 5 }, "end": { - "line": 33, - "column": 6 + "line": 34, + "column": 2 } } }, @@ -830,8 +845,8 @@ "column": 5 }, "end": { - "line": 33, - "column": 6 + "line": 34, + "column": 2 } } } diff --git a/ets2panda/test/parser/ets/labeledWhileStatement-expected.txt b/ets2panda/test/parser/ets/labeledWhileStatement-expected.txt index ed679bcd28..59ecae18f5 100644 --- a/ets2panda/test/parser/ets/labeledWhileStatement-expected.txt +++ b/ets2panda/test/parser/ets/labeledWhileStatement-expected.txt @@ -417,215 +417,230 @@ "type": "BlockStatement", "statements": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "!=", - "left": { - "type": "BinaryExpression", - "operator": "/", - "left": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 9 - }, - "end": { - "line": 23, - "column": 10 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 23, - "column": 13 - }, - "end": { - "line": 23, - "column": 14 - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 9 - }, - "end": { - "line": 23, - "column": 14 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 23, - "column": 18 - }, - "end": { - "line": 23, - "column": 19 - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 9 - }, - "end": { - "line": 23, - "column": 19 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "UpdateExpression", - "operator": "++", - "prefix": false, - "argument": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "!=", + "left": { + "type": "BinaryExpression", + "operator": "/", + "left": { "type": "Identifier", "name": "i", "decorators": [], "loc": { "start": { - "line": 24, - "column": 7 + "line": 23, + "column": 9 }, "end": { - "line": 24, - "column": 8 + "line": 23, + "column": 10 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 23, + "column": 13 + }, + "end": { + "line": 23, + "column": 14 } } }, "loc": { "start": { - "line": 24, - "column": 7 + "line": 23, + "column": 9 }, "end": { - "line": 24, - "column": 10 + "line": 23, + "column": 14 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 23, + "column": 18 + }, + "end": { + "line": 23, + "column": 19 } } }, "loc": { "start": { - "line": 24, - "column": 7 + "line": 23, + "column": 9 }, "end": { - "line": 24, - "column": 11 + "line": 23, + "column": 19 } } }, - { - "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 16 + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "UpdateExpression", + "operator": "++", + "prefix": false, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 7 + }, + "end": { + "line": 24, + "column": 8 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 7 + }, + "end": { + "line": 24, + "column": 10 + } + } }, - "end": { - "line": 25, - "column": 22 + "loc": { + "start": { + "line": 24, + "column": 7 + }, + "end": { + "line": 24, + "column": 11 + } + } + }, + { + "type": "ContinueStatement", + "label": { + "type": "Identifier", + "name": "label1", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 16 + }, + "end": { + "line": 25, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 7 + }, + "end": { + "line": 25, + "column": 23 + } } } - }, + ], "loc": { "start": { - "line": 25, - "column": 7 + "line": 23, + "column": 21 }, "end": { - "line": 25, - "column": 23 + "line": 26, + "column": 6 } } - } - ], - "loc": { - "start": { - "line": 23, - "column": 21 }, - "end": { - "line": 26, - "column": 6 - } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ - { - "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 13 + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "BreakStatement", + "label": { + "type": "Identifier", + "name": "label1", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 13 + }, + "end": { + "line": 27, + "column": 19 + } + } }, - "end": { - "line": 27, - "column": 19 + "loc": { + "start": { + "line": 27, + "column": 7 + }, + "end": { + "line": 27, + "column": 20 + } } } - }, + ], "loc": { "start": { - "line": 27, - "column": 7 + "line": 26, + "column": 12 }, "end": { - "line": 27, - "column": 20 + "line": 28, + "column": 6 } } - } - ], - "loc": { - "start": { - "line": 26, - "column": 12 }, - "end": { - "line": 28, - "column": 6 + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 28, + "column": 6 + } } } - }, + ], "loc": { "start": { - "line": 23, - "column": 5 + "line": 22, + "column": 18 }, "end": { - "line": 28, - "column": 6 + "line": 29, + "column": 4 } } } @@ -636,8 +651,8 @@ "column": 18 }, "end": { - "line": 29, - "column": 4 + "line": 31, + "column": 9 } } }, @@ -647,8 +662,8 @@ "column": 3 }, "end": { - "line": 29, - "column": 4 + "line": 31, + "column": 9 } } }, @@ -658,8 +673,8 @@ "column": 3 }, "end": { - "line": 29, - "column": 4 + "line": 31, + "column": 9 } } }, @@ -729,298 +744,323 @@ "type": "BlockStatement", "statements": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "j", - "decorators": [], - "loc": { - "start": { - "line": 33, - "column": 9 + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 33, + "column": 9 + }, + "end": { + "line": 33, + "column": 10 + } + } }, - "end": { - "line": 33, - "column": 10 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 4, - "loc": { - "start": { - "line": 33, - "column": 14 + "right": { + "type": "NumberLiteral", + "value": 4, + "loc": { + "start": { + "line": 33, + "column": 14 + }, + "end": { + "line": 33, + "column": 15 + } + } }, - "end": { - "line": 33, - "column": 15 + "loc": { + "start": { + "line": 33, + "column": 9 + }, + "end": { + "line": 33, + "column": 15 + } } - } - }, - "loc": { - "start": { - "line": 33, - "column": 9 }, - "end": { - "line": 33, - "column": 15 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "BreakStatement", - "label": null, + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "BreakStatement", + "label": null, + "loc": { + "start": { + "line": 34, + "column": 7 + }, + "end": { + "line": 34, + "column": 13 + } + } + } + ], "loc": { "start": { - "line": 34, - "column": 7 + "line": 33, + "column": 17 }, "end": { - "line": 34, - "column": 13 + "line": 35, + "column": 6 } } - } - ], - "loc": { - "start": { - "line": 33, - "column": 17 }, - "end": { - "line": 35, - "column": 6 - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 33, - "column": 5 - }, - "end": { - "line": 35, - "column": 6 - } - } - }, - { - "type": "WhileStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "k", - "decorators": [], - "loc": { - "start": { - "line": 37, - "column": 12 - }, - "end": { - "line": 37, - "column": 13 - } - } - }, - "right": { - "type": "Identifier", - "name": "j", - "decorators": [], + "alternate": null, "loc": { "start": { - "line": 37, - "column": 16 + "line": 33, + "column": 5 }, "end": { - "line": 37, - "column": 17 + "line": 35, + "column": 6 } } }, - "loc": { - "start": { - "line": 37, - "column": 12 - }, - "end": { - "line": 37, - "column": 17 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "k", - "decorators": [], - "loc": { - "start": { - "line": 38, - "column": 11 - }, - "end": { - "line": 38, - "column": 12 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 7, - "loc": { - "start": { - "line": 38, - "column": 16 - }, - "end": { - "line": 38, - "column": 17 - } + { + "type": "WhileStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "k", + "decorators": [], + "loc": { + "start": { + "line": 37, + "column": 12 + }, + "end": { + "line": 37, + "column": 13 } - }, + } + }, + "right": { + "type": "Identifier", + "name": "j", + "decorators": [], "loc": { "start": { - "line": 38, - "column": 11 + "line": 37, + "column": 16 }, "end": { - "line": 38, + "line": 37, "column": 17 } } }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "BreakStatement", - "label": { + "loc": { + "start": { + "line": 37, + "column": 12 + }, + "end": { + "line": 37, + "column": 17 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { "type": "Identifier", - "name": "label2", + "name": "k", "decorators": [], "loc": { "start": { - "line": 39, - "column": 15 + "line": 38, + "column": 11 + }, + "end": { + "line": 38, + "column": 12 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 7, + "loc": { + "start": { + "line": 38, + "column": 16 }, "end": { - "line": 39, - "column": 21 + "line": 38, + "column": 17 } } }, "loc": { "start": { - "line": 39, - "column": 9 + "line": 38, + "column": 11 }, "end": { - "line": 39, - "column": 22 + "line": 38, + "column": 17 } } - } - ], - "loc": { - "start": { - "line": 38, - "column": 19 }, - "end": { - "line": 40, - "column": 8 - } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "k", - "decorators": [], + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "BreakStatement", + "label": { + "type": "Identifier", + "name": "label2", + "decorators": [], + "loc": { + "start": { + "line": 39, + "column": 15 + }, + "end": { + "line": 39, + "column": 21 + } + } + }, "loc": { "start": { - "line": 41, + "line": 39, "column": 9 }, "end": { - "line": 41, - "column": 10 + "line": 39, + "column": 22 } } + } + ], + "loc": { + "start": { + "line": 38, + "column": 19 }, - "right": { - "type": "Identifier", - "name": "j", - "decorators": [], + "end": { + "line": 40, + "column": 8 + } + } + }, + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "+=", + "left": { + "type": "Identifier", + "name": "k", + "decorators": [], + "loc": { + "start": { + "line": 41, + "column": 9 + }, + "end": { + "line": 41, + "column": 10 + } + } + }, + "right": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 41, + "column": 14 + }, + "end": { + "line": 41, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 41, + "column": 9 + }, + "end": { + "line": 41, + "column": 15 + } + } + }, "loc": { "start": { "line": 41, - "column": 14 + "column": 9 }, "end": { "line": 41, - "column": 15 + "column": 16 } } }, - "loc": { - "start": { - "line": 41, - "column": 9 + { + "type": "ExpressionStatement", + "expression": { + "type": "UpdateExpression", + "operator": "++", + "prefix": false, + "argument": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 9 + }, + "end": { + "line": 42, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 42, + "column": 9 + }, + "end": { + "line": 42, + "column": 12 + } + } }, - "end": { - "line": 41, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 41, - "column": 9 - }, - "end": { - "line": 41, - "column": 16 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "UpdateExpression", - "operator": "++", - "prefix": false, - "argument": { - "type": "Identifier", - "name": "j", - "decorators": [], "loc": { "start": { "line": 42, @@ -1028,146 +1068,136 @@ }, "end": { "line": 42, - "column": 10 + "column": 13 } } }, - "loc": { - "start": { - "line": 42, - "column": 9 + { + "type": "ContinueStatement", + "label": { + "type": "Identifier", + "name": "label2", + "decorators": [], + "loc": { + "start": { + "line": 43, + "column": 18 + }, + "end": { + "line": 43, + "column": 24 + } + } }, - "end": { - "line": 42, - "column": 12 + "loc": { + "start": { + "line": 43, + "column": 9 + }, + "end": { + "line": 43, + "column": 25 + } } } - }, + ], "loc": { "start": { - "line": 42, - "column": 9 + "line": 40, + "column": 14 }, "end": { - "line": 42, - "column": 13 + "line": 44, + "column": 8 } } }, - { - "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "label2", - "decorators": [], - "loc": { - "start": { - "line": 43, - "column": 18 - }, - "end": { - "line": 43, - "column": 24 - } - } + "loc": { + "start": { + "line": 38, + "column": 7 }, - "loc": { - "start": { - "line": 43, - "column": 9 - }, - "end": { - "line": 43, - "column": 25 - } + "end": { + "line": 44, + "column": 8 } } - ], + } + ], + "loc": { + "start": { + "line": 37, + "column": 19 + }, + "end": { + "line": 45, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 5 + }, + "end": { + "line": 45, + "column": 6 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "j", + "decorators": [], "loc": { "start": { - "line": 40, - "column": 14 + "line": 47, + "column": 7 }, "end": { - "line": 44, + "line": 47, "column": 8 } } }, "loc": { "start": { - "line": 38, - "column": 7 + "line": 47, + "column": 5 }, "end": { - "line": 44, + "line": 47, "column": 8 } } - } - ], - "loc": { - "start": { - "line": 37, - "column": 19 }, - "end": { - "line": 45, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 37, - "column": 5 - }, - "end": { - "line": 45, - "column": 6 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "UpdateExpression", - "operator": "++", - "prefix": true, - "argument": { - "type": "Identifier", - "name": "j", - "decorators": [], "loc": { "start": { "line": 47, - "column": 7 + "column": 5 }, "end": { "line": 47, - "column": 8 + "column": 9 } } - }, - "loc": { - "start": { - "line": 47, - "column": 5 - }, - "end": { - "line": 47, - "column": 8 - } } - }, + ], "loc": { "start": { - "line": 47, - "column": 5 + "line": 32, + "column": 18 }, "end": { - "line": 47, - "column": 9 + "line": 48, + "column": 4 } } } @@ -1178,8 +1208,8 @@ "column": 18 }, "end": { - "line": 48, - "column": 4 + "line": 49, + "column": 2 } } }, @@ -1189,8 +1219,8 @@ "column": 3 }, "end": { - "line": 48, - "column": 4 + "line": 49, + "column": 2 } } }, @@ -1200,8 +1230,8 @@ "column": 3 }, "end": { - "line": 48, - "column": 4 + "line": 49, + "column": 2 } } } diff --git a/ets2panda/test/parser/ets/loops-expected.txt b/ets2panda/test/parser/ets/loops-expected.txt index 1ea34dabb4..4afe2623f8 100644 --- a/ets2panda/test/parser/ets/loops-expected.txt +++ b/ets2panda/test/parser/ets/loops-expected.txt @@ -1666,217 +1666,247 @@ "type": "BlockStatement", "statements": [ { - "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "loop2", - "decorators": [], - "loc": { - "start": { - "line": 49, - "column": 5 + "type": "BlockStatement", + "statements": [ + { + "type": "LabelledStatement", + "label": { + "type": "Identifier", + "name": "loop2", + "decorators": [], + "loc": { + "start": { + "line": 49, + "column": 5 + }, + "end": { + "line": 49, + "column": 10 + } + } }, - "end": { - "line": 49, - "column": 10 - } - } - }, - "body": { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { + "body": { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 50, + "column": 14 + }, + "end": { + "line": 50, + "column": 15 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 50, + "column": 18 + }, + "end": { + "line": 50, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 50, + "column": 14 + }, + "end": { + "line": 50, + "column": 19 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 50, + "column": 10 + }, + "end": { + "line": 50, + "column": 19 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", "name": "j", "decorators": [], "loc": { "start": { "line": 50, - "column": 14 + "column": 21 }, "end": { "line": 50, - "column": 15 + "column": 22 } } }, - "init": { + "right": { "type": "NumberLiteral", - "value": 1, + "value": 5, "loc": { "start": { "line": 50, - "column": 18 + "column": 25 }, "end": { "line": 50, - "column": 19 + "column": 26 } } }, "loc": { "start": { "line": 50, - "column": 14 + "column": 21 }, "end": { "line": 50, - "column": 19 + "column": 26 } } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 50, - "column": 10 }, - "end": { - "line": 50, - "column": 19 - } - } - }, - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "j", - "decorators": [], - "loc": { - "start": { - "line": 50, - "column": 21 - }, - "end": { - "line": 50, - "column": 22 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 5, - "loc": { - "start": { - "line": 50, - "column": 25 - }, - "end": { - "line": 50, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 50, - "column": 21 - }, - "end": { - "line": 50, - "column": 26 - } - } - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": false, - "argument": { - "type": "Identifier", - "name": "j", - "decorators": [], - "loc": { - "start": { - "line": 50, - "column": 28 - }, - "end": { - "line": 50, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 50, - "column": 28 - }, - "end": { - "line": 50, - "column": 31 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "BreakStatement", - "label": { + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": false, + "argument": { "type": "Identifier", - "name": "loop1", + "name": "j", "decorators": [], "loc": { "start": { - "line": 51, - "column": 13 + "line": 50, + "column": 28 }, "end": { - "line": 51, - "column": 18 + "line": 50, + "column": 29 } } }, "loc": { "start": { - "line": 51, - "column": 7 + "line": 50, + "column": 28 }, "end": { - "line": 51, - "column": 19 + "line": 50, + "column": 31 } } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "BlockStatement", + "statements": [ + { + "type": "BreakStatement", + "label": { + "type": "Identifier", + "name": "loop1", + "decorators": [], + "loc": { + "start": { + "line": 51, + "column": 13 + }, + "end": { + "line": 51, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 51, + "column": 7 + }, + "end": { + "line": 51, + "column": 19 + } + } + } + ], + "loc": { + "start": { + "line": 50, + "column": 33 + }, + "end": { + "line": 52, + "column": 6 + } + } + } + ], + "loc": { + "start": { + "line": 50, + "column": 33 + }, + "end": { + "line": 53, + "column": 4 + } + } + }, + "loc": { + "start": { + "line": 50, + "column": 5 + }, + "end": { + "line": 53, + "column": 4 + } } - ], + }, "loc": { "start": { - "line": 50, - "column": 33 + "line": 49, + "column": 5 }, "end": { - "line": 52, - "column": 6 + "line": 53, + "column": 4 } } - }, - "loc": { - "start": { - "line": 50, - "column": 5 - }, - "end": { - "line": 52, - "column": 6 - } } - }, + ], "loc": { "start": { - "line": 49, - "column": 5 + "line": 48, + "column": 31 }, "end": { - "line": 52, - "column": 6 + "line": 53, + "column": 4 } } } @@ -1887,8 +1917,8 @@ "column": 31 }, "end": { - "line": 53, - "column": 4 + "line": 54, + "column": 2 } } }, @@ -1898,8 +1928,8 @@ "column": 3 }, "end": { - "line": 53, - "column": 4 + "line": 54, + "column": 2 } } }, @@ -1909,8 +1939,8 @@ "column": 3 }, "end": { - "line": 53, - "column": 4 + "line": 54, + "column": 2 } } } @@ -2176,217 +2206,247 @@ "type": "BlockStatement", "statements": [ { - "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "loop2", - "decorators": [], - "loc": { - "start": { - "line": 60, - "column": 5 + "type": "BlockStatement", + "statements": [ + { + "type": "LabelledStatement", + "label": { + "type": "Identifier", + "name": "loop2", + "decorators": [], + "loc": { + "start": { + "line": 60, + "column": 5 + }, + "end": { + "line": 60, + "column": 10 + } + } }, - "end": { - "line": 60, - "column": 10 - } - } - }, - "body": { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { + "body": { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "j", + "decorators": [], + "loc": { + "start": { + "line": 61, + "column": 14 + }, + "end": { + "line": 61, + "column": 15 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 61, + "column": 18 + }, + "end": { + "line": 61, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 61, + "column": 14 + }, + "end": { + "line": 61, + "column": 19 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 61, + "column": 10 + }, + "end": { + "line": 61, + "column": 19 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", "name": "j", "decorators": [], "loc": { "start": { "line": 61, - "column": 14 + "column": 21 }, "end": { "line": 61, - "column": 15 + "column": 22 } } }, - "init": { + "right": { "type": "NumberLiteral", - "value": 1, + "value": 5, "loc": { "start": { "line": 61, - "column": 18 + "column": 25 }, "end": { "line": 61, - "column": 19 + "column": 26 } } }, "loc": { "start": { "line": 61, - "column": 14 + "column": 21 }, "end": { "line": 61, - "column": 19 + "column": 26 } } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 61, - "column": 10 }, - "end": { - "line": 61, - "column": 19 - } - } - }, - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "j", - "decorators": [], - "loc": { - "start": { - "line": 61, - "column": 21 - }, - "end": { - "line": 61, - "column": 22 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 5, - "loc": { - "start": { - "line": 61, - "column": 25 - }, - "end": { - "line": 61, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 61, - "column": 21 - }, - "end": { - "line": 61, - "column": 26 - } - } - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": false, - "argument": { - "type": "Identifier", - "name": "j", - "decorators": [], - "loc": { - "start": { - "line": 61, - "column": 28 - }, - "end": { - "line": 61, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 61, - "column": 28 - }, - "end": { - "line": 61, - "column": 31 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ContinueStatement", - "label": { + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": false, + "argument": { "type": "Identifier", - "name": "loop1", + "name": "j", "decorators": [], "loc": { "start": { - "line": 62, - "column": 16 + "line": 61, + "column": 28 }, "end": { - "line": 62, - "column": 21 + "line": 61, + "column": 29 } } }, "loc": { "start": { - "line": 62, - "column": 7 + "line": 61, + "column": 28 }, "end": { - "line": 62, - "column": 22 + "line": 61, + "column": 31 } } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "BlockStatement", + "statements": [ + { + "type": "ContinueStatement", + "label": { + "type": "Identifier", + "name": "loop1", + "decorators": [], + "loc": { + "start": { + "line": 62, + "column": 16 + }, + "end": { + "line": 62, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 62, + "column": 7 + }, + "end": { + "line": 62, + "column": 22 + } + } + } + ], + "loc": { + "start": { + "line": 61, + "column": 33 + }, + "end": { + "line": 63, + "column": 6 + } + } + } + ], + "loc": { + "start": { + "line": 61, + "column": 33 + }, + "end": { + "line": 64, + "column": 4 + } + } + }, + "loc": { + "start": { + "line": 61, + "column": 5 + }, + "end": { + "line": 64, + "column": 4 + } } - ], + }, "loc": { "start": { - "line": 61, - "column": 33 + "line": 60, + "column": 5 }, "end": { - "line": 63, - "column": 6 + "line": 64, + "column": 4 } } - }, - "loc": { - "start": { - "line": 61, - "column": 5 - }, - "end": { - "line": 63, - "column": 6 - } } - }, + ], "loc": { "start": { - "line": 60, - "column": 5 + "line": 59, + "column": 31 }, "end": { - "line": 63, - "column": 6 + "line": 64, + "column": 4 } } } @@ -2397,8 +2457,8 @@ "column": 31 }, "end": { - "line": 64, - "column": 4 + "line": 65, + "column": 2 } } }, @@ -2408,8 +2468,8 @@ "column": 3 }, "end": { - "line": 64, - "column": 4 + "line": 65, + "column": 2 } } }, @@ -2419,8 +2479,8 @@ "column": 3 }, "end": { - "line": 64, - "column": 4 + "line": 65, + "column": 2 } } } diff --git a/ets2panda/test/parser/ets/return-expected.txt b/ets2panda/test/parser/ets/return-expected.txt index 9fbd1a66f1..0cdedee7c3 100644 --- a/ets2panda/test/parser/ets/return-expected.txt +++ b/ets2panda/test/parser/ets/return-expected.txt @@ -451,16 +451,31 @@ } }, "consequent": { - "type": "ReturnStatement", - "argument": null, + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": null, + "loc": { + "start": { + "line": 19, + "column": 17 + }, + "end": { + "line": 19, + "column": 24 + } + } + } + ], "loc": { "start": { "line": 19, "column": 17 }, "end": { - "line": 19, - "column": 24 + "line": 20, + "column": 4 } } }, @@ -471,8 +486,8 @@ "column": 5 }, "end": { - "line": 19, - "column": 24 + "line": 20, + "column": 4 } } } diff --git a/ets2panda/test/parser/js/test-if-expected.txt b/ets2panda/test/parser/js/test-if-expected.txt index cb2b29bc5e..76287aec2c 100644 --- a/ets2panda/test/parser/js/test-if-expected.txt +++ b/ets2panda/test/parser/js/test-if-expected.txt @@ -33,58 +33,73 @@ } }, "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "alma", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 2 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "alma", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 2 + }, + "end": { + "line": 18, + "column": 6 + } + } }, - "end": { - "line": 18, - "column": 6 + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 18, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 2 + }, + "end": { + "line": 18, + "column": 10 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 0, + }, "loc": { "start": { "line": 18, - "column": 9 + "column": 2 }, "end": { "line": 18, "column": 10 } } - }, - "loc": { - "start": { - "line": 18, - "column": 2 - }, - "end": { - "line": 18, - "column": 10 - } } - }, + ], "loc": { "start": { "line": 18, "column": 2 }, "end": { - "line": 18, - "column": 10 + "line": 20, + "column": 3 } } }, @@ -95,8 +110,8 @@ "column": 1 }, "end": { - "line": 18, - "column": 10 + "line": 20, + "column": 3 } } }, @@ -117,58 +132,73 @@ } }, "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "fa", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 7 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "fa", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 20, + "column": 9 + } + } }, - "end": { - "line": 20, - "column": 9 + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 20, + "column": 13 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 20, + "column": 13 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 1, + }, "loc": { "start": { "line": 20, - "column": 12 + "column": 7 }, "end": { "line": 20, "column": 13 } } - }, - "loc": { - "start": { - "line": 20, - "column": 7 - }, - "end": { - "line": 20, - "column": 13 - } } - }, + ], "loc": { "start": { "line": 20, "column": 7 }, "end": { - "line": 20, - "column": 13 + "line": 22, + "column": 3 } } }, @@ -179,8 +209,8 @@ "column": 1 }, "end": { - "line": 20, - "column": 13 + "line": 22, + "column": 3 } } }, @@ -201,50 +231,65 @@ } }, "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "alma", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 7 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "alma", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 7 + }, + "end": { + "line": 22, + "column": 11 + } + } }, - "end": { - "line": 22, - "column": 11 + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 22, + "column": 14 + }, + "end": { + "line": 22, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 7 + }, + "end": { + "line": 22, + "column": 15 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 0, + }, "loc": { "start": { "line": 22, - "column": 14 + "column": 7 }, "end": { "line": 22, - "column": 15 + "column": 16 } } - }, - "loc": { - "start": { - "line": 22, - "column": 7 - }, - "end": { - "line": 22, - "column": 15 - } } - }, + ], "loc": { "start": { "line": 22, @@ -252,63 +297,78 @@ }, "end": { "line": 22, - "column": 16 + "column": 21 } } }, "alternate": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "fa", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 22 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "fa", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 22 + }, + "end": { + "line": 22, + "column": 24 + } + } }, - "end": { - "line": 22, - "column": 24 + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 22, + "column": 27 + }, + "end": { + "line": 22, + "column": 28 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 22 + }, + "end": { + "line": 22, + "column": 28 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 1, + }, "loc": { "start": { "line": 22, - "column": 27 + "column": 22 }, "end": { "line": 22, "column": 28 } } - }, - "loc": { - "start": { - "line": 22, - "column": 22 - }, - "end": { - "line": 22, - "column": 28 - } } - }, + ], "loc": { "start": { "line": 22, "column": 22 }, "end": { - "line": 22, - "column": 28 + "line": 24, + "column": 3 } } }, @@ -318,8 +378,8 @@ "column": 1 }, "end": { - "line": 22, - "column": 28 + "line": 24, + "column": 3 } } }, @@ -340,114 +400,144 @@ } }, "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "alma", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 3 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "alma", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 3 + }, + "end": { + "line": 25, + "column": 7 + } + } }, - "end": { - "line": 25, - "column": 7 + "right": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 25, + "column": 10 + }, + "end": { + "line": 25, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 3 + }, + "end": { + "line": 25, + "column": 11 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 0, + }, "loc": { "start": { "line": 25, - "column": 10 + "column": 3 }, "end": { "line": 25, - "column": 11 + "column": 12 } } - }, - "loc": { - "start": { - "line": 25, - "column": 3 - }, - "end": { - "line": 25, - "column": 11 - } } - }, + ], "loc": { "start": { "line": 25, "column": 3 }, "end": { - "line": 25, - "column": 12 + "line": 26, + "column": 5 } } }, "alternate": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "fa", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 6 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "fa", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 6 + }, + "end": { + "line": 26, + "column": 8 + } + } }, - "end": { - "line": 26, - "column": 8 + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 26, + "column": 11 + }, + "end": { + "line": 26, + "column": 12 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 6 + }, + "end": { + "line": 26, + "column": 12 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 1, + }, "loc": { "start": { "line": 26, - "column": 11 + "column": 6 }, "end": { "line": 26, "column": 12 } } - }, - "loc": { - "start": { - "line": 26, - "column": 6 - }, - "end": { - "line": 26, - "column": 12 - } } - }, + ], "loc": { "start": { "line": 26, "column": 6 }, "end": { - "line": 26, - "column": 12 + "line": 28, + "column": 3 } } }, @@ -457,8 +547,8 @@ "column": 1 }, "end": { - "line": 26, - "column": 12 + "line": 28, + "column": 3 } } }, @@ -550,58 +640,73 @@ } }, "alternate": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "fa", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 23 + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "fa", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 23 + }, + "end": { + "line": 28, + "column": 25 + } + } }, - "end": { - "line": 28, - "column": 25 + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 28, + "column": 28 + }, + "end": { + "line": 28, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 23 + }, + "end": { + "line": 28, + "column": 29 + } } - } - }, - "right": { - "type": "NumberLiteral", - "value": 1, + }, "loc": { "start": { "line": 28, - "column": 28 + "column": 23 }, "end": { "line": 28, "column": 29 } } - }, - "loc": { - "start": { - "line": 28, - "column": 23 - }, - "end": { - "line": 28, - "column": 29 - } } - }, + ], "loc": { "start": { "line": 28, "column": 23 }, "end": { - "line": 28, - "column": 29 + "line": 30, + "column": 3 } } }, @@ -611,8 +716,8 @@ "column": 1 }, "end": { - "line": 28, - "column": 29 + "line": 30, + "column": 3 } } }, @@ -633,7 +738,22 @@ } }, "consequent": { - "type": "EmptyStatement", + "type": "BlockStatement", + "statements": [ + { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 30, + "column": 7 + }, + "end": { + "line": 30, + "column": 8 + } + } + } + ], "loc": { "start": { "line": 30, @@ -641,48 +761,78 @@ }, "end": { "line": 30, - "column": 8 + "column": 12 } } }, "alternate": { - "type": "IfStatement", - "test": { - "type": "StringLiteral", - "value": "alma", - "loc": { - "start": { - "line": 32, - "column": 4 + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "StringLiteral", + "value": "alma", + "loc": { + "start": { + "line": 32, + "column": 4 + }, + "end": { + "line": 32, + "column": 10 + } + } }, - "end": { - "line": 32, - "column": 10 - } - } - }, - "consequent": { - "type": "EmptyStatement", - "loc": { - "start": { - "line": 32, - "column": 11 + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 32, + "column": 11 + }, + "end": { + "line": 32, + "column": 12 + } + } + } + ], + "loc": { + "start": { + "line": 32, + "column": 11 + }, + "end": { + "line": 34, + "column": 3 + } + } }, - "end": { - "line": 32, - "column": 12 + "alternate": null, + "loc": { + "start": { + "line": 32, + "column": 1 + }, + "end": { + "line": 34, + "column": 3 + } } } - }, - "alternate": null, + ], "loc": { "start": { "line": 32, "column": 1 }, "end": { - "line": 32, - "column": 12 + "line": 34, + "column": 3 } } }, @@ -692,8 +842,8 @@ "column": 1 }, "end": { - "line": 32, - "column": 12 + "line": 34, + "column": 3 } } }, @@ -714,7 +864,22 @@ } }, "consequent": { - "type": "EmptyStatement", + "type": "BlockStatement", + "statements": [ + { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 34, + "column": 6 + }, + "end": { + "line": 34, + "column": 7 + } + } + } + ], "loc": { "start": { "line": 34, @@ -722,135 +887,210 @@ }, "end": { "line": 34, - "column": 7 + "column": 12 } } }, "alternate": { - "type": "IfStatement", - "test": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 34, - "column": 16 - }, - "end": { - "line": 34, - "column": 17 - } - } - }, - "consequent": { - "type": "EmptyStatement", - "loc": { - "start": { - "line": 34, - "column": 19 - }, - "end": { - "line": 34, - "column": 20 - } - } - }, - "alternate": { - "type": "IfStatement", - "test": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 34, - "column": 28 - }, - "end": { - "line": 34, - "column": 29 + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 34, + "column": 16 + }, + "end": { + "line": 34, + "column": 17 + } } - } - }, - "consequent": { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "alma", - "decorators": [], - "loc": { - "start": { - "line": 34, - "column": 31 - }, - "end": { - "line": 34, - "column": 35 + }, + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 34, + "column": 19 + }, + "end": { + "line": 34, + "column": 20 + } } } - }, - "right": { - "type": "StringLiteral", - "value": "fa", - "loc": { - "start": { - "line": 34, - "column": 38 + ], + "loc": { + "start": { + "line": 34, + "column": 19 + }, + "end": { + "line": 34, + "column": 24 + } + } + }, + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 34, + "column": 28 + }, + "end": { + "line": 34, + "column": 29 + } + } }, - "end": { - "line": 34, - "column": 42 + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "alma", + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 31 + }, + "end": { + "line": 34, + "column": 35 + } + } + }, + "right": { + "type": "StringLiteral", + "value": "fa", + "loc": { + "start": { + "line": 34, + "column": 38 + }, + "end": { + "line": 34, + "column": 42 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 31 + }, + "end": { + "line": 34, + "column": 42 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 31 + }, + "end": { + "line": 34, + "column": 43 + } + } + } + ], + "loc": { + "start": { + "line": 34, + "column": 31 + }, + "end": { + "line": 34, + "column": 48 + } + } + }, + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 34, + "column": 48 + }, + "end": { + "line": 34, + "column": 49 + } + } + } + ], + "loc": { + "start": { + "line": 34, + "column": 48 + }, + "end": { + "line": 34, + "column": 49 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 25 + }, + "end": { + "line": 34, + "column": 49 + } } } - }, + ], "loc": { "start": { "line": 34, - "column": 31 + "column": 25 }, "end": { "line": 34, - "column": 42 + "column": 49 } } }, "loc": { "start": { "line": 34, - "column": 31 - }, - "end": { - "line": 34, - "column": 43 - } - } - }, - "alternate": { - "type": "EmptyStatement", - "loc": { - "start": { - "line": 34, - "column": 48 + "column": 13 }, "end": { "line": 34, "column": 49 } } - }, - "loc": { - "start": { - "line": 34, - "column": 25 - }, - "end": { - "line": 34, - "column": 49 - } } - }, + ], "loc": { "start": { "line": 34, diff --git a/ets2panda/test/parser/js/test-labelled-statement-expected.txt b/ets2panda/test/parser/js/test-labelled-statement-expected.txt index 4b1b04dd4d..a4b2e75439 100644 --- a/ets2panda/test/parser/js/test-labelled-statement-expected.txt +++ b/ets2panda/test/parser/js/test-labelled-statement-expected.txt @@ -245,7 +245,22 @@ }, "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 23, + "column": 14 + }, + "end": { + "line": 23, + "column": 16 + } + } + } + ], "loc": { "start": { "line": 23, @@ -253,7 +268,7 @@ }, "end": { "line": 23, - "column": 16 + "column": 17 } } }, @@ -264,7 +279,7 @@ }, "end": { "line": 23, - "column": 16 + "column": 17 } } }, @@ -275,7 +290,7 @@ }, "end": { "line": 23, - "column": 16 + "column": 17 } } }, @@ -313,7 +328,22 @@ "type": "DoWhileStatement", "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 25, + "column": 7 + }, + "end": { + "line": 25, + "column": 9 + } + } + } + ], "loc": { "start": { "line": 25, @@ -321,7 +351,7 @@ }, "end": { "line": 25, - "column": 9 + "column": 15 } } }, @@ -613,30 +643,45 @@ "type": "BlockStatement", "statements": [ { - "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 38, - "column": 13 + "type": "BlockStatement", + "statements": [ + { + "type": "BreakStatement", + "label": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 13 + }, + "end": { + "line": 38, + "column": 14 + } + } }, - "end": { - "line": 38, - "column": 14 + "loc": { + "start": { + "line": 38, + "column": 7 + }, + "end": { + "line": 38, + "column": 15 + } } } - }, + ], "loc": { "start": { - "line": 38, - "column": 7 + "line": 37, + "column": 5 }, "end": { - "line": 38, - "column": 15 + "line": 39, + "column": 6 } } } @@ -647,8 +692,8 @@ "column": 5 }, "end": { - "line": 39, - "column": 6 + "line": 40, + "column": 4 } } }, @@ -658,8 +703,8 @@ "column": 5 }, "end": { - "line": 39, - "column": 6 + "line": 40, + "column": 4 } } }, @@ -669,8 +714,8 @@ "column": 5 }, "end": { - "line": 39, - "column": 6 + "line": 40, + "column": 4 } } } @@ -831,30 +876,45 @@ "type": "BlockStatement", "statements": [ { - "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "b", - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 13 + "type": "BlockStatement", + "statements": [ + { + "type": "BreakStatement", + "label": { + "type": "Identifier", + "name": "b", + "decorators": [], + "loc": { + "start": { + "line": 52, + "column": 13 + }, + "end": { + "line": 52, + "column": 14 + } + } }, - "end": { - "line": 52, - "column": 14 + "loc": { + "start": { + "line": 52, + "column": 7 + }, + "end": { + "line": 52, + "column": 15 + } } } - }, + ], "loc": { "start": { - "line": 52, - "column": 7 + "line": 51, + "column": 5 }, "end": { - "line": 52, - "column": 15 + "line": 53, + "column": 6 } } } @@ -865,8 +925,8 @@ "column": 5 }, "end": { - "line": 53, - "column": 6 + "line": 54, + "column": 4 } } }, @@ -876,8 +936,8 @@ "column": 5 }, "end": { - "line": 53, - "column": 6 + "line": 54, + "column": 4 } } }, @@ -887,8 +947,8 @@ "column": 5 }, "end": { - "line": 53, - "column": 6 + "line": 54, + "column": 4 } } }, @@ -898,8 +958,8 @@ "column": 5 }, "end": { - "line": 53, - "column": 6 + "line": 54, + "column": 4 } } } diff --git a/ets2panda/test/parser/ts/test-if-expected.txt b/ets2panda/test/parser/ts/test-if-expected.txt index d0ae5c613e..b87915eab6 100644 --- a/ets2panda/test/parser/ts/test-if-expected.txt +++ b/ets2panda/test/parser/ts/test-if-expected.txt @@ -18,119 +18,179 @@ } }, "consequent": { - "type": "TSEnumDeclaration", - "id": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 16 + "type": "BlockStatement", + "statements": [ + { + "type": "TSEnumDeclaration", + "id": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 16 + }, + "end": { + "line": 18, + "column": 17 + } + } }, - "end": { - "line": 18, - "column": 17 + "members": [], + "const": true, + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 18, + "column": 21 + } } } - }, - "members": [], - "const": true, + ], "loc": { "start": { "line": 18, - "column": 11 + "column": 5 }, "end": { - "line": 18, - "column": 21 + "line": 19, + "column": 5 } } }, "alternate": { - "type": "IfStatement", - "test": { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 19, - "column": 10 + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 19, + "column": 11 + } + } }, - "end": { - "line": 19, - "column": 11 - } - } - }, - "consequent": { - "type": "TSEnumDeclaration", - "id": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 16 - }, - "end": { - "line": 20, - "column": 17 + "consequent": { + "type": "BlockStatement", + "statements": [ + { + "type": "TSEnumDeclaration", + "id": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 17 + } + } + }, + "members": [], + "const": true, + "loc": { + "start": { + "line": 20, + "column": 11 + }, + "end": { + "line": 20, + "column": 21 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 21, + "column": 5 + } + } + }, + "alternate": { + "type": "BlockStatement", + "statements": [ + { + "type": "TSEnumDeclaration", + "id": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 17 + } + } + }, + "members": [], + "const": true, + "loc": { + "start": { + "line": 22, + "column": 11 + }, + "end": { + "line": 22, + "column": 21 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 5 + }, + "end": { + "line": 23, + "column": 1 + } } - } - }, - "members": [], - "const": true, - "loc": { - "start": { - "line": 20, - "column": 11 }, - "end": { - "line": 20, - "column": 21 - } - } - }, - "alternate": { - "type": "TSEnumDeclaration", - "id": { - "type": "Identifier", - "name": "C", - "decorators": [], "loc": { "start": { - "line": 22, - "column": 16 + "line": 19, + "column": 6 }, "end": { - "line": 22, - "column": 17 + "line": 23, + "column": 1 } } - }, - "members": [], - "const": true, - "loc": { - "start": { - "line": 22, - "column": 11 - }, - "end": { - "line": 22, - "column": 21 - } } - }, + ], "loc": { "start": { "line": 19, "column": 6 }, "end": { - "line": 22, - "column": 21 + "line": 23, + "column": 1 } } }, @@ -140,8 +200,8 @@ "column": 1 }, "end": { - "line": 22, - "column": 21 + "line": 23, + "column": 1 } } } diff --git a/ets2panda/test/runtime/ets/BlockStatements.ets b/ets2panda/test/runtime/ets/BlockStatements.ets new file mode 100644 index 0000000000..b3ca1b07b5 --- /dev/null +++ b/ets2panda/test/runtime/ets/BlockStatements.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let a = 0; + +function test1(): int { + return 1; +} + +function test2(arg: int): int { + return 0; +} + +function test3(): int { + a += 1 + return a; +} + +function test_if() { + if (test1() == 1) + let x = 10; //if body + let x = 11; + return test2(x); +} +function test_else() { + if (test1() != 1) return 1 + else + let x = 10; // else body + let x = 11; + return test2(x); +} +function test_while() { + while (test3() != 3) + let x = 10; //while body + let x = 11; + return test2(x); +} +function test_do() { + do + let x = 10; //do body + while (test3() != 5) + let x = 11; + return test2(x); +} +function test_for() { + for (let i = 0; i < test1(); i++) + let x = 10; //for body + let x = 11; + return test2(x); +} + +function main(): int { + return test_if() + test_else() + test_while() + test_do() + test_for(); +} \ No newline at end of file -- Gitee