Skip to content

Commit

Permalink
fix: inline anonymous "static" node
Browse files Browse the repository at this point in the history
Problem: The "trick" of wrapping an anonymous node into a single
`choice` or `seq` no longer works as of
tree-sitter/tree-sitter#2577

Solution: Inline `"static"` node at its only use site.
  • Loading branch information
clason committed Jul 8, 2024
1 parent 0a50d31 commit 993dd9c
Show file tree
Hide file tree
Showing 4 changed files with 36,674 additions and 36,794 deletions.
5 changes: 1 addition & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,12 @@ module.exports = grammar({
member_declaration: $ => seq(
optional($.attribute_declaration),
choice(
seq(optional($.qualifier), $.identifier, '=', choice($.expression, $.table), optional(';')),
seq(optional('static'), $.identifier, '=', choice($.expression, $.table), optional(';')),
seq('[', $.expression, ']', '=', $.expression, optional(';')),
$.function_declaration,
seq('constructor', '(', optional($.parameters), ')', $._statement),
),
),
qualifier: _ => choice(
'static',
),

try_statement: $ => seq(
'try',
Expand Down
13 changes: 2 additions & 11 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,8 @@
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "qualifier"
"type": "STRING",
"value": "static"
},
{
"type": "BLANK"
Expand Down Expand Up @@ -1101,15 +1101,6 @@
}
]
},
"qualifier": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "static"
}
]
},
"try_statement": {
"type": "SEQ",
"members": [
Expand Down
9 changes: 0 additions & 9 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -1849,10 +1849,6 @@
"type": "parameters",
"named": true
},
{
"type": "qualifier",
"named": true
},
{
"type": "return",
"named": true
Expand Down Expand Up @@ -1937,11 +1933,6 @@
]
}
},
{
"type": "qualifier",
"named": true,
"fields": {}
},
{
"type": "resume_expression",
"named": true,
Expand Down
Loading

0 comments on commit 993dd9c

Please sign in to comment.