diff --git a/ets2panda/parser/ETSparser.h b/ets2panda/parser/ETSparser.h index 0e36c5bafa5afcb1d39e1eb3a0f35cddf4bcbd07..559aeef5418a32ee28f915e2fab9148a35d437b2 100644 --- a/ets2panda/parser/ETSparser.h +++ b/ets2panda/parser/ETSparser.h @@ -441,6 +441,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 *ParseClassElement(const ArenaVector &properties, ir::ClassDefinitionModifiers modifiers, ir::ModifierFlags flags) override; std::tuple HandleClassElementModifiers(ir::ModifierFlags &memberModifiers); diff --git a/ets2panda/parser/ETSparserStatements.cpp b/ets2panda/parser/ETSparserStatements.cpp index 88b69326d7f6b91dd320b9f3dc404a132464f454..d2176847855e307a98f2a30c1087c4e81efc735e 100644 --- a/ets2panda/parser/ETSparserStatements.cpp +++ b/ets2panda/parser/ETSparserStatements.cpp @@ -364,4 +364,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 f8744249a90433db4689456f36e24ad5e7b30b14..955a4a093a0164a2cbf8cfa4d10093803751adbf 100644 --- a/ets2panda/parser/parserImpl.h +++ b/ets2panda/parser/parserImpl.h @@ -292,6 +292,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 dbedb6bf25066a86bd3591187aef97e37ffc32ca..6f6d1559bbf1e78f0887956fab8dd2d2b897308d 100644 --- a/ets2panda/parser/statementParser.cpp +++ b/ets2panda/parser/statementParser.cpp @@ -196,7 +196,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); @@ -313,6 +313,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 5084f17fba70a2eb73de596c44680565ed44938c..49ecd93b2ef933c98958991afb7294524def5a35 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 d18aff410856f2183deefcae726070359e924d78..1de6fd1a681f636dec326946f514533468285ca9 100644 --- a/ets2panda/test/ast/parser/ets/interface_parser_error_1.ets +++ b/ets2panda/test/ast/parser/ets/interface_parser_error_1.ets @@ -42,6 +42,7 @@ function mdin() { let a = new A(); /* @@? 18:15 Error SyntaxError: Unexpected token ':'. */ /* @@? 18:15 Error SyntaxError: Unexpected token ':'. */ /* @@? 18:15 Error SyntaxError: Unexpected token ':'. */ +/* @@? 20:9 Error SyntaxError: Illegal start of INTERFACE expression. */ /* @@? 21:13 Error SyntaxError: Identifier expected. */ /* @@? 21:21 Error SyntaxError: Unexpected token, expected ','. */ /* @@? 21:21 Error SyntaxError: Unexpected token, expected 'private' or identifier. */ @@ -56,7 +57,7 @@ function mdin() { let a = new A(); /* @@? 25:17 Error SyntaxError: Unexpected token 'implements'. */ /* @@? 25:17 Error SyntaxError: Unexpected token 'implements'. */ /* @@? 25:17 Error SyntaxError: Unexpected token 'implements'. */ -/* @@? 25:28 Error TypeError: Interface name 'I' used in the wrong context */ +/* @@? 25:28 Error TypeError: Unresolved reference I */ /* @@? 25:30 Error SyntaxError: Unexpected token '{'. */ /* @@? 26:13 Error TypeError: Unresolved reference reanstructor */ /* @@? 27:27 Error SyntaxError: Unexpected token, expected an identifier. */ @@ -71,8 +72,8 @@ function mdin() { let a = new A(); /* @@? 32:2 Error SyntaxError: Unexpected token '*'. */ /* @@? 33:1 Error SyntaxError: Nested functions are not allowed. */ /* @@? 33:1 Error SyntaxError: Unexpected token 'function'. */ -/* @@? 78:60 Error SyntaxError: Expected '}', got 'eos'. */ -/* @@? 78:60 Error SyntaxError: Expected '}', got 'eos'. */ -/* @@? 78:60 Error SyntaxError: Expected '}', got 'eos'. */ -/* @@? 78:60 Error SyntaxError: Expected '}', got 'eos'. */ -/* @@? 78:60 Error SyntaxError: Expected '}', got 'eos'. */ \ No newline at end of file +/* @@? 80:1 Error SyntaxError: Expected '}', got 'eos'. */ +/* @@? 80:1 Error SyntaxError: Expected '}', got 'eos'. */ +/* @@? 80:1 Error SyntaxError: Expected '}', got 'eos'. */ +/* @@? 80:1 Error SyntaxError: Expected '}', got 'eos'. */ +/* @@? 80:1 Error SyntaxError: Expected '}', got 'eos'. */ 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/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 083186cec9a393b1b2f2bbc4a3a991a683e9ac00..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,4 +22,5 @@ function bar(): void { } } -/* @@? 20:3 Error TypeError: Variable 'BC' has already been declared. */ +/* @@? 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 9b0f2ecae990c592dabbb14b3bfb47873bb31520..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,4 +20,4 @@ function bar(): void { } } -/* @@? 18:3 Error TypeError: Variable 'BC' has already been declared. */ +/* @@? 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 877b11b3cbdcb1e67bb071b190dba94e75cd4b0e..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": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "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/class_interface_enum_only_top_level_4.ets b/ets2panda/test/parser/ets/class_interface_enum_only_top_level_4.ets deleted file mode 100644 index 75d8981a525476173a26d6c839d300e63dd58e06..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/class_interface_enum_only_top_level_4.ets +++ /dev/null @@ -1,21 +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() : void -{ - interface C { - foo(a: int): int; - } -} 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 064455264662cae3ec82439cea99991aea405d90..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": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "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