diff -r d039fbf92297 libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Mon May 22 16:22:42 2023 -0700 +++ b/libinterp/parse-tree/lex.ll Wed May 24 13:47:32 2023 +0200 @@ -81,6 +81,7 @@ %x BLOCK_COMMENT_START %x LINE_COMMENT_START +%x END_OF_LINE_COMMENT_START %x DQ_STRING_START %x SQ_STRING_START @@ -857,8 +858,16 @@ // End of line comment. if (have_space) - curr_lexer->mark_previous_token_trailing_space (); - + { + curr_lexer->mark_previous_token_trailing_space (); + } + + int currrent_start_state = curr_lexer->start_state (); + if (currrent_start_state == LINE_COMMENT_START) + { + curr_lexer->pop_start_state (); + curr_lexer->push_start_state (END_OF_LINE_COMMENT_START); + } curr_lexer->finish_comment (octave::comment_elt::end_of_line); curr_lexer->pop_start_state (); @@ -3319,8 +3328,11 @@ { bool copyright = looks_like_copyright (m_comment_text); + int comment_start_state = start_state (); + if (m_nesting_level.none () && m_help_text.empty () && ! m_comment_text.empty () - && ! copyright && ! looks_like_shebang (m_comment_text)) + && ! copyright && ! looks_like_shebang (m_comment_text) + && (comment_start_state == BLOCK_COMMENT_START || comment_start_state == LINE_COMMENT_START)) m_help_text = m_comment_text; if (copyright)