Skip to content

Commit

Permalink
Merge pull request #193 from tree-sitter/tausbn/allow-match-in-more-p…
Browse files Browse the repository at this point in the history
…laces

Allow the identifier `match` in more places
  • Loading branch information
tausbn committed Feb 28, 2023
2 parents c6cfa75 + 4f25ce7 commit 6282715
Show file tree
Hide file tree
Showing 4 changed files with 48,022 additions and 49,139 deletions.
11 changes: 5 additions & 6 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,14 @@ module.exports = grammar({
),

named_expression: $ => seq(
field('name', $._named_expresssion_lhs),
field('name', $._named_expression_lhs),
':=',
field('value', $.expression)
),

_named_expresssion_lhs: $ => choice(
_named_expression_lhs: $ => choice(
$.identifier,
alias('match', $.identifier), // ambiguity with match statement: only ":" at end of line decides if "match" keyword
$.keyword_identifier
),

return_statement: $ => seq(
Expand Down Expand Up @@ -535,7 +535,6 @@ module.exports = grammar({

pattern: $ => choice(
$.identifier,
alias('match', $.identifier), // ambiguity with match statement: only ":" at end of line decides if "match" keyword
$.keyword_identifier,
$.subscript,
$.attribute,
Expand Down Expand Up @@ -610,7 +609,6 @@ module.exports = grammar({
primary_expression: $ => choice(
$.binary_operator,
$.identifier,
alias("match", $.identifier),
$.keyword_identifier,
$.string,
$.concatenated_string,
Expand Down Expand Up @@ -817,7 +815,7 @@ module.exports = grammar({
type: $ => $.expression,

keyword_argument: $ => seq(
field('name', choice($.identifier, $.keyword_identifier, alias("match", $.identifier))),
field('name', choice($.identifier, $.keyword_identifier)),
'=',
field('value', $.expression)
),
Expand Down Expand Up @@ -1036,6 +1034,7 @@ module.exports = grammar({
'exec',
'async',
'await',
'match'
),
$.identifier
)),
Expand Down
44 changes: 8 additions & 36 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@
"name": "name",
"content": {
"type": "SYMBOL",
"name": "_named_expresssion_lhs"
"name": "_named_expression_lhs"
}
},
{
Expand All @@ -621,21 +621,16 @@
}
]
},
"_named_expresssion_lhs": {
"_named_expression_lhs": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "ALIAS",
"content": {
"type": "STRING",
"value": "match"
},
"named": true,
"value": "identifier"
"type": "SYMBOL",
"name": "keyword_identifier"
}
]
},
Expand Down Expand Up @@ -2333,15 +2328,6 @@
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "ALIAS",
"content": {
"type": "STRING",
"value": "match"
},
"named": true,
"value": "identifier"
},
{
"type": "SYMBOL",
"name": "keyword_identifier"
Expand Down Expand Up @@ -2644,15 +2630,6 @@
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "ALIAS",
"content": {
"type": "STRING",
"value": "match"
},
"named": true,
"value": "identifier"
},
{
"type": "SYMBOL",
"name": "keyword_identifier"
Expand Down Expand Up @@ -4061,15 +4038,6 @@
{
"type": "SYMBOL",
"name": "keyword_identifier"
},
{
"type": "ALIAS",
"content": {
"type": "STRING",
"value": "match"
},
"named": true,
"value": "identifier"
}
]
}
Expand Down Expand Up @@ -5259,6 +5227,10 @@
{
"type": "STRING",
"value": "await"
},
{
"type": "STRING",
"value": "match"
}
]
},
Expand Down
Loading

0 comments on commit 6282715

Please sign in to comment.