Skip to content

Commit a411a29

Browse files
committed
feat: support labeled blocks
1 parent 25dfe48 commit a411a29

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

grammar.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,11 @@ module.exports = grammar({
459459
$.extern_modifier,
460460
)),
461461

462-
where_clause: $ => seq(
462+
where_clause: $ => prec.right(seq(
463463
'where',
464464
sepBy1(',', $.where_predicate),
465465
optional(','),
466-
),
466+
)),
467467

468468
where_predicate: $ => seq(
469469
field('left', choice(
@@ -1206,20 +1206,20 @@ module.exports = grammar({
12061206
),
12071207

12081208
while_expression: $ => seq(
1209-
optional(seq($.loop_label, ':')),
1209+
optional(seq($.label, ':')),
12101210
'while',
12111211
field('condition', $._condition),
12121212
field('body', $.block),
12131213
),
12141214

12151215
loop_expression: $ => seq(
1216-
optional(seq($.loop_label, ':')),
1216+
optional(seq($.label, ':')),
12171217
'loop',
12181218
field('body', $.block),
12191219
),
12201220

12211221
for_expression: $ => seq(
1222-
optional(seq($.loop_label, ':')),
1222+
optional(seq($.label, ':')),
12231223
'for',
12241224
field('pattern', $._pattern),
12251225
'in',
@@ -1254,11 +1254,11 @@ module.exports = grammar({
12541254
'|',
12551255
),
12561256

1257-
loop_label: $ => seq('\'', $.identifier),
1257+
label: $ => seq('\'', $.identifier),
12581258

1259-
break_expression: $ => prec.left(seq('break', optional($.loop_label), optional($._expression))),
1259+
break_expression: $ => prec.left(seq('break', optional($.label), optional($._expression))),
12601260

1261-
continue_expression: $ => prec.left(seq('continue', optional($.loop_label))),
1261+
continue_expression: $ => prec.left(seq('continue', optional($.label))),
12621262

12631263
index_expression: $ => prec(PREC.call, seq($._expression, '[', $._expression, ']')),
12641264

@@ -1289,6 +1289,7 @@ module.exports = grammar({
12891289
),
12901290

12911291
block: $ => seq(
1292+
optional(seq($.label, ':')),
12921293
'{',
12931294
repeat($._statement),
12941295
optional($._expression),

0 commit comments

Comments
 (0)