Skip to content

Commit

Permalink
Allow comma separated patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
theHamsta committed Dec 14, 2021
1 parent 9dd2ea3 commit e0ab4cd
Show file tree
Hide file tree
Showing 5 changed files with 25,387 additions and 22,064 deletions.
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ module.exports = grammar({

case_clause: $ => seq(
'case',
field('pattern', $.expression),
commaSep1(field('pattern', choice($.expression, $.list_splat_pattern))),
optional($.if_clause),
':',
field('consequence', $._suite)
Expand Down
55 changes: 49 additions & 6 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -925,12 +925,55 @@
"value": "case"
},
{
"type": "FIELD",
"name": "pattern",
"content": {
"type": "SYMBOL",
"name": "expression"
}
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "pattern",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "list_splat_pattern"
}
]
}
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "FIELD",
"name": "pattern",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "list_splat_pattern"
}
]
}
}
]
}
}
]
},
{
"type": "CHOICE",
Expand Down
6 changes: 5 additions & 1 deletion src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -803,12 +803,16 @@
]
},
"pattern": {
"multiple": false,
"multiple": true,
"required": true,
"types": [
{
"type": "expression",
"named": true
},
{
"type": "list_splat_pattern",
"named": true
}
]
}
Expand Down
Loading

0 comments on commit e0ab4cd

Please sign in to comment.