Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonspark committed Aug 17, 2023
1 parent 0b3f9cf commit 0d0b834
Show file tree
Hide file tree
Showing 5 changed files with 28,214 additions and 27,547 deletions.
10 changes: 9 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,13 @@ module.exports = grammar({
),

switch_label: $ => choice(
seq('case', choice($.pattern, commaSep1($.expression))),
seq('case',
choice(
$.pattern,
commaSep1($.expression)
),
optional($.guard)
),
'default'
),

Expand All @@ -498,6 +504,8 @@ module.exports = grammar({
choice($.identifier, $._reserved_identifier)
),

guard: $ => seq('when', $.expression),

// Statements

statement: $ => choice(
Expand Down
25 changes: 25 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3684,6 +3684,18 @@
]
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "guard"
},
{
"type": "BLANK"
}
]
}
]
},
Expand Down Expand Up @@ -3840,6 +3852,19 @@
}
]
},
"guard": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "when"
},
{
"type": "SYMBOL",
"name": "expression"
}
]
},
"statement": {
"type": "CHOICE",
"members": [
Expand Down
23 changes: 23 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2143,6 +2143,21 @@
]
}
},
{
"type": "guard",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "expression",
"named": true
}
]
}
},
{
"type": "if_statement",
"named": true,
Expand Down Expand Up @@ -3503,6 +3518,10 @@
"type": "expression",
"named": true
},
{
"type": "guard",
"named": true
},
{
"type": "pattern",
"named": true
Expand Down Expand Up @@ -4512,6 +4531,10 @@
"type": "volatile",
"named": false
},
{
"type": "when",
"named": false
},
{
"type": "while",
"named": false
Expand Down
Loading

0 comments on commit 0d0b834

Please sign in to comment.