Skip to content

Commit

Permalink
Add another test case for match
Browse files Browse the repository at this point in the history
  • Loading branch information
theHamsta committed Dec 14, 2021
1 parent 0881390 commit 41267b4
Show file tree
Hide file tree
Showing 5 changed files with 24,244 additions and 23,041 deletions.
5 changes: 2 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,15 @@ module.exports = grammar({

match_statement: $ => seq(
'match',
field('subject', $.expression),
commaSep1(field('subject', $.expression)),
optional(','),
':',
repeat(field('alternative', $.case_clause))),

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

0 comments on commit 41267b4

Please sign in to comment.