@@ -46,6 +46,7 @@ module.exports = grammar({
46
46
conflicts : $ => [
47
47
[ $ . _simple_name , $ . generic_name ] ,
48
48
[ $ . _simple_name , $ . type_parameter ] ,
49
+ [ $ . _simple_name , $ . subpattern ] ,
49
50
50
51
[ $ . tuple_element , $ . type_pattern ] ,
51
52
[ $ . tuple_element , $ . using_variable_declarator ] ,
@@ -1174,14 +1175,15 @@ module.exports = grammar({
1174
1175
1175
1176
type_pattern : $ => prec . right ( field ( 'type' , $ . type ) ) ,
1176
1177
1177
- list_pattern : $ => seq (
1178
+ list_pattern : $ => prec . right ( seq (
1178
1179
'[' ,
1179
1180
optional ( seq (
1180
1181
commaSep1 ( choice ( $ . pattern , '..' ) ) ,
1181
1182
optional ( ',' ) ,
1182
1183
) ) ,
1183
1184
']' ,
1184
- ) ,
1185
+ optional ( $ . _variable_designation ) ,
1186
+ ) ) ,
1185
1187
1186
1188
recursive_pattern : $ => prec . left ( seq (
1187
1189
optional ( field ( 'type' , $ . type ) ) ,
@@ -1197,7 +1199,7 @@ module.exports = grammar({
1197
1199
1198
1200
positional_pattern_clause : $ => prec ( 1 , seq (
1199
1201
'(' ,
1200
- optional ( commaSep2 ( $ . subpattern ) ) ,
1202
+ optional ( commaSep ( $ . subpattern ) ) ,
1201
1203
')' ,
1202
1204
) ) ,
1203
1205
@@ -1208,10 +1210,15 @@ module.exports = grammar({
1208
1210
'}' ,
1209
1211
) ) ,
1210
1212
1211
- subpattern : $ => seq (
1212
- optional ( seq ( $ . expression , ':' ) ) ,
1213
+ subpattern : $ => prec . right ( seq (
1214
+ optional (
1215
+ choice (
1216
+ seq ( $ . expression , ':' ) ,
1217
+ seq ( $ . identifier , ':' ) ,
1218
+ ) ,
1219
+ ) ,
1213
1220
$ . pattern ,
1214
- ) ,
1221
+ ) ) ,
1215
1222
1216
1223
relational_pattern : $ => choice (
1217
1224
seq ( '<' , $ . expression ) ,
@@ -1720,6 +1727,7 @@ module.exports = grammar({
1720
1727
_with_body : $ => seq (
1721
1728
'{' ,
1722
1729
commaSep ( $ . with_initializer ) ,
1730
+ optional ( ',' ) ,
1723
1731
'}' ,
1724
1732
) ,
1725
1733
0 commit comments