Skip to content

Commit

Permalink
Merge pull request #176 from yoff/patch-1
Browse files Browse the repository at this point in the history
Update grammar to accept `except*`
  • Loading branch information
tausbn authored Oct 24, 2022
2 parents de221ec + 87c3f4c commit b14614e
Show file tree
Hide file tree
Showing 5 changed files with 52,969 additions and 45,563 deletions.
20 changes: 19 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ module.exports = grammar({
optional($.else_clause),
optional($.finally_clause)
),
seq(
repeat1($.except_group_clause),
optional($.else_clause),
optional($.finally_clause)
),
$.finally_clause
)
),
Expand All @@ -341,7 +346,20 @@ module.exports = grammar({
$._suite
),

finally_clause: $ => seq(
except_group_clause: $ => seq(
'except*',
seq(
$.expression,
optional(seq(
'as',
$.expression
))
),
':',
$._suite
),

finally_clause: $ => seq(
'finally',
':',
$._suite
Expand Down
83 changes: 83 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,42 @@
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "except_group_clause"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "else_clause"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "finally_clause"
},
{
"type": "BLANK"
}
]
}
]
},
{
"type": "SYMBOL",
"name": "finally_clause"
Expand Down Expand Up @@ -1326,6 +1362,53 @@
}
]
},
"except_group_clause": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "except*"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "as"
},
{
"type": "SYMBOL",
"name": "expression"
}
]
},
{
"type": "BLANK"
}
]
}
]
},
{
"type": "STRING",
"value": ":"
},
{
"type": "SYMBOL",
"name": "_suite"
}
]
},
"finally_clause": {
"type": "SEQ",
"members": [
Expand Down
27 changes: 27 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,25 @@
]
}
},
{
"type": "except_group_clause",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "block",
"named": true
},
{
"type": "expression",
"named": true
}
]
}
},
{
"type": "exec_statement",
"named": true,
Expand Down Expand Up @@ -2353,6 +2372,10 @@
"type": "except_clause",
"named": true
},
{
"type": "except_group_clause",
"named": true
},
{
"type": "finally_clause",
"named": true
Expand Down Expand Up @@ -2882,6 +2905,10 @@
"type": "except",
"named": false
},
{
"type": "except*",
"named": false
},
{
"type": "exec",
"named": false
Expand Down
Loading

0 comments on commit b14614e

Please sign in to comment.