diff --git a/ets2panda/parser/ETSparser.h b/ets2panda/parser/ETSparser.h index 8bbfeecf694dc10ae08b6d088c63f2ba02987d40..f87cc4f1c7fdc88e9f39321c0c60a8291469d1b0 100644 --- a/ets2panda/parser/ETSparser.h +++ b/ets2panda/parser/ETSparser.h @@ -355,6 +355,8 @@ private: // NOLINTNEXTLINE(google-default-arguments) ir::Statement *ParseStructStatement(StatementParsingFlags flags, ir::ClassDefinitionModifiers modifiers, ir::ModifierFlags modFlags = ir::ModifierFlags::NONE) override; + // NOLINTNEXTLINE(google-default-arguments) + ir::Statement *ParseInterfaceStatement(StatementParsingFlags flags) override; ir::AstNode *ParseClassElementHelper( const ArenaVector &properties, std::tuple modifierInfo, diff --git a/ets2panda/parser/ETSparserStatements.cpp b/ets2panda/parser/ETSparserStatements.cpp index 68ffc5fa04d8627209a21b3bf27c8725f0ced526..acefc7db3c0432b1761f7ed92b89f5c08dcba6bb 100644 --- a/ets2panda/parser/ETSparserStatements.cpp +++ b/ets2panda/parser/ETSparserStatements.cpp @@ -405,4 +405,13 @@ ir::Statement *ETSParser::ParseStructStatement([[maybe_unused]] StatementParsing return AllocBrokenStatement(rangeStruct); } +// NOLINTNEXTLINE(google-default-arguments) +ir::Statement *ETSParser::ParseInterfaceStatement([[maybe_unused]] StatementParsingFlags flags) +{ + auto &rangeClass = Lexer()->GetToken().Loc(); + LogError(diagnostic::ILLEGAL_START_STRUCT_CLASS, {"INTERFACE"}, Lexer()->GetToken().Start()); + ParseInterfaceDeclaration(false); + return AllocBrokenStatement(rangeClass); +} + } // namespace ark::es2panda::parser diff --git a/ets2panda/parser/parserImpl.h b/ets2panda/parser/parserImpl.h index 4f134e6a2ab3df30c418f76ab28e0e50d9a6c4e4..fb801a552d89254b2ee18420d17d532163d72a03 100644 --- a/ets2panda/parser/parserImpl.h +++ b/ets2panda/parser/parserImpl.h @@ -309,6 +309,8 @@ protected: // NOLINTNEXTLINE(google-default-arguments) virtual ir::Statement *ParseStructStatement(StatementParsingFlags flags, ir::ClassDefinitionModifiers modifiers, ir::ModifierFlags modFlags = ir::ModifierFlags::NONE); + // NOLINTNEXTLINE(google-default-arguments) + virtual ir::Statement *ParseInterfaceStatement(StatementParsingFlags flags); ir::Statement *ParseStatementBasedOnTokenType(StatementParsingFlags flags); ir::Statement *ParseVarStatement(); ir::Statement *ParseLetStatement(StatementParsingFlags flags); diff --git a/ets2panda/parser/statementParser.cpp b/ets2panda/parser/statementParser.cpp index cb374f95f30f2c7070288955b7fe0eab03734e7d..0dea119b34fabd82358b77f2b6c3e5153b2a13fe 100644 --- a/ets2panda/parser/statementParser.cpp +++ b/ets2panda/parser/statementParser.cpp @@ -195,7 +195,7 @@ ir::Statement *ParserImpl::ParseStatementBasedOnTokenType(StatementParsingFlags case lexer::TokenType::KEYW_ENUM: return ParseEnumDeclaration(); case lexer::TokenType::KEYW_INTERFACE: - return ParseInterfaceDeclaration(false); + return ParseInterfaceStatement(flags); case lexer::TokenType::PUNCTUATOR_AT: if (IsETSParser()) { return ParseAnnotationsInStatement(flags); @@ -322,6 +322,15 @@ ir::Statement *ParserImpl::ParseClassStatement(StatementParsingFlags flags, ir:: return ParseClassDeclaration(modifiers, modFlags); } +ir::Statement *ParserImpl::ParseInterfaceStatement(StatementParsingFlags flags) +{ + if ((flags & StatementParsingFlags::ALLOW_LEXICAL) == 0) { + LogError(diagnostic::LEXICAL_DEC_NOT_ALLOWED_IN_SINGLE_STATEMENT_CONTEXT); + } + + return ParseInterfaceDeclaration(false); +} + ir::Statement *ParserImpl::ParseStructDeclaration(ir::ClassDefinitionModifiers modifiers, ir::ModifierFlags flags) { const lexer::SourcePosition startLoc = lexer_->GetToken().Start(); diff --git a/ets2panda/test/ast/parser/ets/InvalidClasses.ets b/ets2panda/test/ast/parser/ets/InvalidClasses.ets index b73dc9af4c14bebae42fa2cc529e95e6ee810222..44236605f8b537db60d09db885cf76b9519e228b 100644 --- a/ets2panda/test/ast/parser/ets/InvalidClasses.ets +++ b/ets2panda/test/ast/parser/ets/InvalidClasses.ets @@ -114,11 +114,12 @@ interface I1 { /* @@? 58:25 Error SyntaxError: Unexpected token '}'. */ /* @@? 61:5 Error SyntaxError: Illegal start of CLASS expression. */ /* @@? 62:9 Error SyntaxError: Local class or interface declaration members can not have access modifies. */ +/* @@? 65:5 Error SyntaxError: Illegal start of INTERFACE expression. */ /* @@? 66:9 Error SyntaxError: Local class or interface declaration members can not have access modifies. */ /* @@? 66:18 Error SyntaxError: Private interface methods must have body. */ /* @@? 67:9 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ -/* @@? 67:16 Error SyntaxError: Unexpected token, expected ','. */ /* @@? 67:16 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@? 67:16 Error SyntaxError: Unexpected token, expected ','. */ /* @@? 67:16 Error SyntaxError: Identifier expected. */ /* @@? 67:24 Error SyntaxError: Private interface methods must have body. */ /* @@? 72:5 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_with_access_modifier03.ets b/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_with_access_modifier03.ets index c6d1285bf8ac75f6673ba770e7e0c0105e76c263..5d02e269821f8baa9efce346ee33ae994d51afa2 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_with_access_modifier03.ets +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_with_access_modifier03.ets @@ -20,3 +20,4 @@ /* @@@ label Error SyntaxError: Unexpected token 'static'. */ /* @@@ label1 Error SyntaxError: Unexpected token '@'. */ /* @@? 15:38 Error SyntaxError: Annotations can only be declared at the top level. */ +/* @@? 15:38 Error SyntaxError: Illegal start of INTERFACE expression. */ diff --git a/ets2panda/test/ast/parser/ets/interface_parser_error_1.ets b/ets2panda/test/ast/parser/ets/interface_parser_error_1.ets index 05540be90decdb67f05112134428cda9dd1abc45..dd2ff48238fb25654e5401cdefef85d5819a63a2 100644 --- a/ets2panda/test/ast/parser/ets/interface_parser_error_1.ets +++ b/ets2panda/test/ast/parser/ets/interface_parser_error_1.ets @@ -39,6 +39,7 @@ function mdin() { let a = new A(); /* @@? 17:4 Error SyntaxError: Unexpected token '{'. */ /* @@? 17:5 Error TypeError: Unresolved reference name */ /* @@? 17:11 Error SyntaxError: Unexpected token ':'. */ +/* @@? 19:1 Error SyntaxError: Illegal start of INTERFACE expression. */ /* @@? 20:5 Error SyntaxError: Identifier expected. */ /* @@? 20:14 Error SyntaxError: Unexpected token, expected ','. */ /* @@? 20:14 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ @@ -52,11 +53,11 @@ function mdin() { let a = new A(); /* @@? 24:7 Error TypeError: Unresolved reference A */ /* @@? 24:9 Error SyntaxError: Unexpected token 'implements'. */ /* @@? 24:20 Error SyntaxError: Unexpected token 'I'. */ -/* @@? 24:20 Error TypeError: Interface name 'I' used in the wrong context */ +/* @@? 24:20 Error TypeError: Unresolved reference I */ /* @@? 24:22 Error SyntaxError: Unexpected token '{'. */ /* @@? 25:4 Error TypeError: Unresolved reference reanstructor */ -/* @@? 26:19 Error SyntaxError: Unexpected token '�ls'. */ /* @@? 26:19 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 26:19 Error SyntaxError: Unexpected token '�ls'. */ /* @@? 27:5 Error SyntaxError: Unexpected token 'A'. */ /* @@? 27:7 Error SyntaxError: Unexpected token '{'. */ /* @@? 28:5 Error SyntaxError: Hard keyword 'constructor' cannot be used as identifier */ @@ -65,4 +66,4 @@ function mdin() { let a = new A(); /* @@? 29:18 Error SyntaxError: Unexpected token, expected an identifier. */ /* @@? 31:2 Error SyntaxError: Unexpected token '*'. */ /* @@? 32:1 Error SyntaxError: Nested functions are not allowed. */ -/* @@? 69:1 Error SyntaxError: Expected '}', got 'end of stream'. */ +/* @@? 70:1 Error SyntaxError: Expected '}', got 'end of stream'. */ diff --git a/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-private1.ets b/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-private1.ets index 6a6186266b252947f343039e587b450c7a5fd198..490354a6199008db14aa92835199ca3b07a7e537 100644 --- a/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-private1.ets +++ b/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-private1.ets @@ -15,10 +15,11 @@ function foo() { - interface LocalInterface + /* @@ label1 */interface LocalInterface { - /* @@ label */private property : int; + /* @@ label2 */private property : int; } } -/* @@@ label Error SyntaxError: Local class or interface declaration members can not have access modifies. */ +/* @@@ label1 Error SyntaxError: Illegal start of INTERFACE expression. */ +/* @@@ label2 Error SyntaxError: Local class or interface declaration members can not have access modifies. */ diff --git a/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-private2.ets b/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-private2.ets index 1083684e90c401c4f02826620138ba1bdee9c1ad..7f76e7b9909c883eb60e5618fdb2761c6edf2a5b 100644 --- a/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-private2.ets +++ b/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-private2.ets @@ -15,10 +15,12 @@ function foo() { - interface LocalInterface + /* @@ label1 */interface LocalInterface { - /* @@ label */private method/* @@ label1 */() : void; + /* @@ label2 */private method/* @@ label3 */() : void; } } -/* @@@ label Error SyntaxError: Local class or interface declaration members can not have access modifies. */ -/* @@@ label1 Error SyntaxError: Private interface methods must have body. */ + +/* @@@ label1 Error SyntaxError: Illegal start of INTERFACE expression. */ +/* @@@ label2 Error SyntaxError: Local class or interface declaration members can not have access modifies. */ +/* @@@ label3 Error SyntaxError: Private interface methods must have body. */ diff --git a/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-protected1.ets b/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-protected1.ets index 915df139ae7012d300941e4659766ef54fc6ec63..af6da8fe3b1d6a352b72da013ebc13ff4dfa389d 100644 --- a/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-protected1.ets +++ b/ets2panda/test/ast/parser/ets/local-interface-member-access-modifier-protected1.ets @@ -15,10 +15,11 @@ function foo() { - interface LocalInterface + /* @@ label1 */interface LocalInterface { - /* @@ label */protected property : int; + /* @@ label2 */protected property : int; } } -/* @@@ label Error SyntaxError: Unexpected token, expected 'private' or identifier. */ +/* @@@ label1 Error SyntaxError: Illegal start of INTERFACE expression. */ +/* @@@ label2 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ diff --git a/ets2panda/test/ast/parser/ets/local_class_already_interface.ets b/ets2panda/test/ast/parser/ets/local_class_already_interface.ets index e9fea16e5276852d2e268c15cb1f2c51075ca1fc..64e86ea35fe8bc56389b747d4ac8285a438e4797 100644 --- a/ets2panda/test/ast/parser/ets/local_class_already_interface.ets +++ b/ets2panda/test/ast/parser/ets/local_class_already_interface.ets @@ -22,4 +22,5 @@ function bar(): void { } } +/* @@? 17:3 Error SyntaxError: Illegal start of INTERFACE expression. */ /* @@? 20:3 Error SyntaxError: Illegal start of CLASS expression. */ diff --git a/ets2panda/test/parser/ets/class_interface_enum_only_top_level_4.ets b/ets2panda/test/ast/parser/ets/local_interface.ets similarity index 68% rename from ets2panda/test/parser/ets/class_interface_enum_only_top_level_4.ets rename to ets2panda/test/ast/parser/ets/local_interface.ets index 75d8981a525476173a26d6c839d300e63dd58e06..df40da65613d41717e4abda567f03447e1d03aad 100644 --- a/ets2panda/test/parser/ets/class_interface_enum_only_top_level_4.ets +++ b/ets2panda/test/ast/parser/ets/local_interface.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024-2025 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -13,9 +13,11 @@ * limitations under the License. */ -function main() : void -{ - interface C { - foo(a: int): int; +let myAssertEqual = (actualValue: boolean, expectValue: boolean) => { + /* @@ label */interface R { + pass: boolean, + message: string } } + +/* @@@ label Error SyntaxError: Illegal start of INTERFACE expression. */ diff --git a/ets2panda/test/ast/parser/ets/local_interface_already_class.ets b/ets2panda/test/ast/parser/ets/local_interface_already_class.ets index a1458dd7714a8573a654f57cb1afe10d621ea107..df8b96452f5280fe3a0fff4b26417033aeac07a9 100644 --- a/ets2panda/test/ast/parser/ets/local_interface_already_class.ets +++ b/ets2panda/test/ast/parser/ets/local_interface_already_class.ets @@ -23,3 +23,4 @@ function bar(): void { } /* @@? 17:3 Error SyntaxError: Illegal start of CLASS expression. */ +/* @@? 20:3 Error SyntaxError: Illegal start of INTERFACE expression. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/local_interface_already_interface.ets b/ets2panda/test/ast/parser/ets/local_interface_already_interface.ets index ad3bd01bac821f3845b1be1536d951e67f75518d..67952a2acfbbc7d4cddad6651e69ba25b4ffd959 100644 --- a/ets2panda/test/ast/parser/ets/local_interface_already_interface.ets +++ b/ets2panda/test/ast/parser/ets/local_interface_already_interface.ets @@ -22,5 +22,5 @@ function bar(): void { } } -/* @@? 20:3 Error TypeError: Variable 'BC' has already been declared. */ -/* @@? 20:3 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 17:3 Error SyntaxError: Illegal start of INTERFACE expression. */ +/* @@? 20:3 Error SyntaxError: Illegal start of INTERFACE expression. */ diff --git a/ets2panda/test/ast/parser/ets/local_interface_already_variable..ets b/ets2panda/test/ast/parser/ets/local_interface_already_variable..ets index 0c4c33dce661aa1e9764c957f768cc1f5af07636..0660c505d4bda4e94018cb0e8e5c690c1d5458d8 100644 --- a/ets2panda/test/ast/parser/ets/local_interface_already_variable..ets +++ b/ets2panda/test/ast/parser/ets/local_interface_already_variable..ets @@ -20,5 +20,4 @@ function bar(): void { } } -/* @@? 18:3 Error TypeError: Variable 'BC' has already been declared. */ -/* @@? 18:3 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 18:3 Error SyntaxError: Illegal start of INTERFACE expression. */ diff --git a/ets2panda/test/parser/ets/class_interface_enum_only_top_level_4-expected.txt b/ets2panda/test/parser/ets/class_interface_enum_only_top_level_4-expected.txt deleted file mode 100644 index 57a2f46f998202e3ed35106bb02e6eb84f3eb7a1..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/class_interface_enum_only_top_level_4-expected.txt +++ /dev/null @@ -1,498 +0,0 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "_$init$_", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "_$init$_", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "main", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 16, - "column": 14, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "main", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 16, - "column": 14, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 16, - "column": 19, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 16, - "column": 23, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "TSInterfaceDeclaration", - "body": { - "type": "TSInterfaceBody", - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 19, - "column": 8, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 19, - "column": 8, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 19, - "column": 12, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 19, - "column": 15, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 9, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 19, - "column": 15, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 9, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 19, - "column": 15, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 19, - "column": 18, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 19, - "column": 21, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 8, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 19, - "column": 21, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 8, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 19, - "column": 21, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 19, - "column": 22, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - } - ], - "loc": { - "start": { - "line": 18, - "column": 15, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 20, - "column": 4, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "id": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 13, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 18, - "column": 14, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "extends": [], - "loc": { - "start": { - "line": 18, - "column": 3, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 21, - "column": 2, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - } - ], - "loc": { - "start": { - "line": 17, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 21, - "column": 2, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 21, - "column": 2, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 21, - "column": 2, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 21, - "column": 2, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - }, - "end": { - "line": 22, - "column": 1, - "program": "class_interface_enum_only_top_level_4.ets" - } - } -} diff --git a/ets2panda/test/parser/ets/local-interface-expected.txt b/ets2panda/test/parser/ets/local-interface-expected.txt deleted file mode 100644 index f9c416f770d25deb6f520b764cc9c9d0f990643e..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/local-interface-expected.txt +++ /dev/null @@ -1,375 +0,0 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "_$init$_", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "_$init$_", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "main", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "local-interface.ets" - }, - "end": { - "line": 16, - "column": 14, - "program": "local-interface.ets" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "main", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "local-interface.ets" - }, - "end": { - "line": 16, - "column": 14, - "program": "local-interface.ets" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 16, - "column": 19, - "program": "local-interface.ets" - }, - "end": { - "line": 16, - "column": 22, - "program": "local-interface.ets" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "TSInterfaceDeclaration", - "body": { - "type": "TSInterfaceBody", - "body": [], - "loc": { - "start": { - "line": 18, - "column": 30, - "program": "local-interface.ets" - }, - "end": { - "line": 18, - "column": 33, - "program": "local-interface.ets" - } - } - }, - "id": { - "type": "Identifier", - "name": "LocalInterface", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 15, - "program": "local-interface.ets" - }, - "end": { - "line": 18, - "column": 29, - "program": "local-interface.ets" - } - } - }, - "extends": [], - "loc": { - "start": { - "line": 18, - "column": 5, - "program": "local-interface.ets" - }, - "end": { - "line": 19, - "column": 11, - "program": "local-interface.ets" - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 19, - "column": 12, - "program": "local-interface.ets" - }, - "end": { - "line": 19, - "column": 13, - "program": "local-interface.ets" - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5, - "program": "local-interface.ets" - }, - "end": { - "line": 19, - "column": 14, - "program": "local-interface.ets" - } - } - } - ], - "loc": { - "start": { - "line": 17, - "column": 1, - "program": "local-interface.ets" - }, - "end": { - "line": 20, - "column": 2, - "program": "local-interface.ets" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "local-interface.ets" - }, - "end": { - "line": 20, - "column": 2, - "program": "local-interface.ets" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 10, - "program": "local-interface.ets" - }, - "end": { - "line": 20, - "column": 2, - "program": "local-interface.ets" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 1, - "program": "local-interface.ets" - }, - "end": { - "line": 20, - "column": 2, - "program": "local-interface.ets" - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - }, - "end": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "local-interface.ets" - }, - "end": { - "line": 20, - "column": 2, - "program": "local-interface.ets" - } - } -} diff --git a/ets2panda/test/parser/ets/local-interface.ets b/ets2panda/test/parser/ets/local-interface.ets deleted file mode 100644 index 9aeed4261a9a51f7be4b28e97614845772b40842..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/local-interface.ets +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2024-2025 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. - */ - -function main() : int -{ - interface LocalInterface { } - return 0; -} \ No newline at end of file