Skip to content

Commit

Permalink
Extract "..." into a named node called variadic_parameter. Fixes #73
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrouhard committed Sep 18, 2021
1 parent 9bee345 commit f71e80b
Show file tree
Hide file tree
Showing 5 changed files with 19,825 additions and 19,784 deletions.
6 changes: 5 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,13 @@ module.exports = grammar({
optional(seq('=', field('value', $._expression)))
),

variadic_parameter: $ => seq(
'...',
),

parameter_list: $ => seq(
'(',
commaSep(choice($.parameter_declaration, '...')),
commaSep(choice($.parameter_declaration, $.variadic_parameter)),
')'
),

Expand Down
17 changes: 13 additions & 4 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3672,6 +3672,15 @@
}
]
},
"variadic_parameter": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "..."
}
]
},
"parameter_list": {
"type": "SEQ",
"members": [
Expand All @@ -3693,8 +3702,8 @@
"name": "parameter_declaration"
},
{
"type": "STRING",
"value": "..."
"type": "SYMBOL",
"name": "variadic_parameter"
}
]
},
Expand All @@ -3715,8 +3724,8 @@
"name": "parameter_declaration"
},
{
"type": "STRING",
"value": "..."
"type": "SYMBOL",
"name": "variadic_parameter"
}
]
}
Expand Down
9 changes: 9 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,10 @@
{
"type": "parameter_declaration",
"named": true
},
{
"type": "variadic_parameter",
"named": true
}
]
}
Expand Down Expand Up @@ -3138,6 +3142,11 @@
}
}
},
{
"type": "variadic_parameter",
"named": true,
"fields": {}
},
{
"type": "while_statement",
"named": true,
Expand Down
Loading

0 comments on commit f71e80b

Please sign in to comment.