diff --git a/src/Parser/Parsing/Impl/CommentRemovingStreamProxy.cpp b/src/Parser/Parsing/Impl/CommentRemovingStreamProxy.cpp index 36975873..b4bf7694 100644 --- a/src/Parser/Parsing/Impl/CommentRemovingStreamProxy.cpp +++ b/src/Parser/Parsing/Impl/CommentRemovingStreamProxy.cpp @@ -29,6 +29,7 @@ ParserLine CommentRemovingStreamProxy::NextLine() if (c == '*' && i + 1 < line.m_line.size() && line.m_line[i + 1] == '/') { line.m_line.erase(multiLineCommentStart, i + 2 - multiLineCommentStart); + i = multiLineCommentStart - 1; multiLineCommentStart = 0; m_inside_multi_line_comment = false; } diff --git a/test/ParserTests/Parsing/Impl/CommentRemovingStreamProxyTests.cpp b/test/ParserTests/Parsing/Impl/CommentRemovingStreamProxyTests.cpp index 44063a1f..4842a724 100644 --- a/test/ParserTests/Parsing/Impl/CommentRemovingStreamProxyTests.cpp +++ b/test/ParserTests/Parsing/Impl/CommentRemovingStreamProxyTests.cpp @@ -223,4 +223,30 @@ namespace test::parsing::impl::comment_removing_stream_proxy REQUIRE(proxy.Eof()); } + + TEST_CASE("CommentRemovingStreamProxy: Can have multiple comment blocks in one line", "[parsing][parsingstream]") + { + const std::vector lines + { + "Hello/* lovely*/ world and/* beautiful*/ universe", + "Hello/* lovely*/ world// and beautiful universe", + }; + + MockParserLineStream mockStream(lines); + CommentRemovingStreamProxy proxy(&mockStream); + + { + auto line = proxy.NextLine(); + REQUIRE(line.m_line_number == 1); + REQUIRE(line.m_line == "Hello world and universe"); + } + + { + auto line = proxy.NextLine(); + REQUIRE(line.m_line_number == 2); + REQUIRE(line.m_line == "Hello world"); + } + + REQUIRE(proxy.Eof()); + } }