unified: Add fields to switch_entry

Of note: this involved un-inlining where_clause.
This commit is contained in:
Taus
2026-05-12 15:05:27 +00:00
parent 6e5e650b42
commit 406a02fa49
2 changed files with 11 additions and 9 deletions

View File

@@ -1078,20 +1078,18 @@ module.exports = grammar({
),
switch_entry: ($) =>
seq(
optional($.modifiers),
field("modifiers", optional($.modifiers)),
choice(
seq(
"case",
seq(
$.switch_pattern,
optional(seq($.where_keyword, $.expression))
),
repeat(seq(",", $.switch_pattern))
field("pattern", $.switch_pattern),
field("where", optional($.where_clause)),
repeat(seq(",", field("pattern", $.switch_pattern)))
),
$.default_keyword
field("default", $.default_keyword)
),
":",
$.statements,
field("body", $.statements),
optional("fallthrough")
),
switch_pattern: ($) => field("pattern", alias($._binding_pattern_with_expr, $.pattern)),

View File

@@ -586,7 +586,11 @@ named:
suppressed_constraint:
suppressed: type_identifier
switch_entry:
$children+: [default_keyword, expression, modifiers, statements, switch_pattern, where_keyword]
body: statements
default?: default_keyword
modifiers?: modifiers
pattern*: switch_pattern
where?: where_clause
switch_pattern:
pattern: pattern
switch_statement: