Skip to content

Commit 33be075

Browse files
aspeddroclaude
andcommitted
Fix block comment not recognized inside switch expressions
The NEWLINE handler's peek-ahead used skip_whitespace_and_comments, which consumed block comments as skipped characters. When it decided not to emit NEWLINE (e.g. because } follows the comment), the scanner returned false and all advances rolled back. The internal tokenizer then tokenized the leading / of /* as a standalone slash, leaving the block comment unrecognized. Fix: replace skip_whitespace_and_comments with skip_whitespace_and_line_comments in the NEWLINE peek path. Block comments (/* */) are external tokens and must not be consumed during peek — only line comments (//) are skipped. When the peek now stops at /*, no continuation pattern matches, so NEWLINE is emitted and the next scanner call correctly handles /* as BLOCK_COMMENT. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 14222e3 commit 33be075

5 files changed

Lines changed: 136143 additions & 136705 deletions

File tree

grammar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ module.exports = grammar({
253253
optional("export"),
254254
"type",
255255
optional("rec"),
256-
sep1(seq(repeat($._newline), "and"), $.type_binding),
256+
sep1("and", $.type_binding),
257257
),
258258

259259
type_binding: ($) =>
@@ -418,7 +418,7 @@ module.exports = grammar({
418418
seq(
419419
choice("export", "let"),
420420
optional("rec"),
421-
sep1(seq(repeat($._newline), "and"), $.let_binding),
421+
sep1("and", $.let_binding),
422422
),
423423

424424
let_binding: ($) =>

src/grammar.json

Lines changed: 4 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)