comptime expandable match statements

This commit is contained in:
2026-07-17 14:29:50 +02:00
parent 1f25e6cd1d
commit 97f1c06057
22 changed files with 120821 additions and 119318 deletions
+17 -3
View File
@@ -339,7 +339,7 @@ module.exports = grammar({
),
for_statement: $ => seq(
optional('inline'),
optional('expand'),
'for',
repeat($._newline),
field('iterable', $.expression),
@@ -364,16 +364,30 @@ module.exports = grammar({
'}',
),
match_arm: $ => seq(
match_arm: $ => choice(seq(
field('pattern', choice('else', commaSep1($, $.expression))),
optional($.match_capture),
':',
repeat($._newline),
field('body', $._branch_body),
),
), seq(
'expand',
$.expand_match_capture,
':',
repeat($._newline),
field('body', $._branch_body),
)),
match_capture: $ => seq('|', optional('@'), field('name', choice($.identifier, $.sink)), '|'),
expand_match_capture: $ => seq(
'|',
optional('@'),
field('value', choice($.identifier, $.sink)),
optional(seq(',', field('tag', choice($.identifier, $.sink)))),
'|',
),
_branch_body: $ => $.statement,
_value: $ => choice(