comptime expandable match statements
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user