diff --git a/ets2panda/lexer/ETSLexer.cpp b/ets2panda/lexer/ETSLexer.cpp index 607ae7b55267ec60d8cb60524810ca71cad61de4..1cbb947551fbb91544f29e6638bd085ad7ce0a6f 100644 --- a/ets2panda/lexer/ETSLexer.cpp +++ b/ets2panda/lexer/ETSLexer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 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 @@ -94,56 +94,6 @@ void ETSLexer::CheckUtf16Compatible(char32_t cp) const } } -void ETSLexer::SkipMultiLineComment() -{ - uint32_t depth = 1U; - - // Just to reduce extra nested level(s) - auto const checkAsterisk = [this, &depth]() -> bool { - if (Iterator().Peek() == LEX_CHAR_SLASH) { - Iterator().Forward(1); - - if (--depth == 0U) { - return false; - } - } - return true; - }; - - while (true) { - switch (Iterator().Next()) { - case util::StringView::Iterator::INVALID_CP: { - ThrowError("Unterminated multi-line comment"); - break; - } - case LEX_CHAR_LF: - case LEX_CHAR_CR: - case LEX_CHAR_LS: - case LEX_CHAR_PS: { - Pos().NextTokenLine()++; - continue; - } - case LEX_CHAR_ASTERISK: { - if (!checkAsterisk()) { - return; - } - break; - } - case LEX_CHAR_SLASH: { - if (Iterator().Peek() == LEX_CHAR_ASTERISK) { - Iterator().Forward(1); - depth++; - } - break; - } - - default: { - break; - } - } - } -} - void ETSLexer::ScanAsteriskPunctuator() { GetToken().type_ = TokenType::PUNCTUATOR_MULTIPLY; diff --git a/ets2panda/lexer/ETSLexer.h b/ets2panda/lexer/ETSLexer.h index 341c800aca7873dbb459351ac763f7a333cc22fa..71f734e3490dbffc29994a371998c089aed1c384 100644 --- a/ets2panda/lexer/ETSLexer.h +++ b/ets2panda/lexer/ETSLexer.h @@ -35,7 +35,6 @@ public: void NextToken(NextTokenFlags flags = NextTokenFlags::NONE) override; void ScanHashMark() override; bool ScanCharLiteral() override; - void SkipMultiLineComment() override; void ScanAsteriskPunctuator() override; void ScanNumberLeadingZero() override diff --git a/ets2panda/test/parser/ets/comment_block-expected.txt b/ets2panda/test/parser/ets/comment_block-expected.txt index 89446062c95d59b86c9c1cd91595cf208db080e4..34161da49dc21c4d072054fe661094090db3d94c 100644 --- a/ets2panda/test/parser/ets/comment_block-expected.txt +++ b/ets2panda/test/parser/ets/comment_block-expected.txt @@ -146,7 +146,7 @@ "column": 1 }, "end": { - "line": 34, + "line": 33, "column": 6 } } diff --git a/ets2panda/test/parser/ets/comment_block.ets b/ets2panda/test/parser/ets/comment_block.ets index 875515bd1971e5b0c287c0742e5cf66f87f478da..68dfeaa95b1bf4834b178d0e37a5e7ff0a64db74 100644 --- a/ets2panda/test/parser/ets/comment_block.ets +++ b/ets2panda/test/parser/ets/comment_block.ets @@ -21,8 +21,7 @@ /* /* - nested block - */ + block */ /*