Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ static bool scan_multiline_comment(TSLexer *lexer) {
}
break;
case '\0':
// Accept unterminated block comments at EOF rather than rejecting them.
// This matches JetBrains PSI behavior which recognizes unclosed /* as a
// BLOCK_COMMENT token (plus an error element). Without this, the scanner
// returns false and tree-sitter tries to parse the comment delimiters
// as operators/expressions.
if (lexer->eof(lexer)) {
lexer->result_symbol = MULTILINE_COMMENT;
lexer->mark_end(lexer);
return true;
}
return false;
default:
advance(lexer);
Expand Down
12 changes: 12 additions & 0 deletions test/corpus/jetbrains/BlockCommentAtBeginningOfFile1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
==================
BlockCommentAtBeginningOfFile1
==================

// COMPILATION_ERRORS

/*
---

(source_file
(line_comment)
(multiline_comment))
13 changes: 13 additions & 0 deletions test/corpus/jetbrains/BlockCommentAtBeginningOfFile2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
==================
BlockCommentAtBeginningOfFile2
==================

// COMPILATION_ERRORS

/*
/*
---

(source_file
(line_comment)
(multiline_comment))
14 changes: 14 additions & 0 deletions test/corpus/jetbrains/BlockCommentAtBeginningOfFile3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
==================
BlockCommentAtBeginningOfFile3
==================

// COMPILATION_ERRORS

/*

fooo
---

(source_file
(line_comment)
(multiline_comment))
16 changes: 16 additions & 0 deletions test/corpus/jetbrains/BlockCommentAtBeginningOfFile4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
==================
BlockCommentAtBeginningOfFile4
==================

// COMPILATION_ERRORS

/*

/*foo*/

asdfas
---

(source_file
(line_comment)
(multiline_comment))
8 changes: 1 addition & 7 deletions tools/cross-validation/excluded.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@
# 3. Run: npm test (to verify the new corpus test passes)

# =============================================================================
# MISMATCH: Grammar produces wrong AST structure (26 files)
# MISMATCH: Grammar produces wrong AST structure (24 files)
# =============================================================================

# --- unterminated_block_comment (tree-sitter limitation) ---
BlockCommentAtBeginningOfFile3
BlockCommentAtBeginningOfFile4

# --- duplicate_accessor (error recovery difference) ---
DuplicateAccessor

Expand Down Expand Up @@ -88,8 +84,6 @@ AbsentInnerType
AnnotatedIntersections
AssertNotNull
BackslashInString
BlockCommentAtBeginningOfFile1
BlockCommentAtBeginningOfFile2
CallsInWhen
CollectionLiterals
CommentsBinding
Expand Down