Skip to content

Commit

Permalink
Add _call_operator
Browse files Browse the repository at this point in the history
  • Loading branch information
aibaars committed Apr 22, 2022
1 parent 7a9aaf6 commit 0fdbd41
Show file tree
Hide file tree
Showing 6 changed files with 289,071 additions and 314,279 deletions.
8 changes: 5 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = grammar({
supertypes: $ => [
$._statement,
$._arg,
$._call_operator,
$._method_name,
$._expression,
$._variable,
Expand Down Expand Up @@ -711,9 +712,10 @@ module.exports = grammar({
field('name', $.constant)
)),

_call_operator: $ => choice('.', '&.', token.immediate('::')),
_call: $ => prec.left(PREC.CALL, seq(
field('receiver', $._primary),
field('operator', choice('.', '&.', token.immediate('::'))),
field('operator', $._call_operator),
field('method', choice($.identifier, $.operator, $.constant, $._function_identifier)),
)),

Expand Down Expand Up @@ -745,7 +747,7 @@ module.exports = grammar({

_chained_command_call: $ => seq(
field('receiver', alias($.command_call_with_block, $.call)),
field('operator', choice('.', '&.', token.immediate('::'))),
field('operator', $._call_operator),
field('method', choice($.identifier, $._function_identifier, $.operator, $.constant)),
),

Expand All @@ -764,7 +766,7 @@ module.exports = grammar({
receiver,
prec.left(PREC.CALL, seq(
field('receiver', $._primary),
field('operator', choice('.', '&.', token.immediate('::')))
field('operator', $._call_operator)
))
),
arguments
Expand Down
121 changes: 31 additions & 90 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3855,6 +3855,26 @@
]
}
},
"_call_operator": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "STRING",
"value": "&."
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "::"
}
}
]
},
"_call": {
"type": "PREC_LEFT",
"value": 56,
Expand All @@ -3873,24 +3893,8 @@
"type": "FIELD",
"name": "operator",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "STRING",
"value": "&."
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "::"
}
}
]
"type": "SYMBOL",
"name": "_call_operator"
}
},
{
Expand Down Expand Up @@ -4116,24 +4120,8 @@
"type": "FIELD",
"name": "operator",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "STRING",
"value": "&."
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "::"
}
}
]
"type": "SYMBOL",
"name": "_call_operator"
}
},
{
Expand Down Expand Up @@ -4216,24 +4204,8 @@
"type": "FIELD",
"name": "operator",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "STRING",
"value": "&."
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "::"
}
}
]
"type": "SYMBOL",
"name": "_call_operator"
}
}
]
Expand Down Expand Up @@ -4307,24 +4279,8 @@
"type": "FIELD",
"name": "operator",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "STRING",
"value": "&."
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "::"
}
}
]
"type": "SYMBOL",
"name": "_call_operator"
}
}
]
Expand Down Expand Up @@ -4409,24 +4365,8 @@
"type": "FIELD",
"name": "operator",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "STRING",
"value": "&."
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "::"
}
}
]
"type": "SYMBOL",
"name": "_call_operator"
}
}
]
Expand Down Expand Up @@ -7972,6 +7912,7 @@
"supertypes": [
"_statement",
"_arg",
"_call_operator",
"_method_name",
"_expression",
"_variable",
Expand Down
30 changes: 20 additions & 10 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@
}
]
},
{
"type": "_call_operator",
"named": true,
"subtypes": [
{
"type": "&.",
"named": false
},
{
"type": ".",
"named": false
},
{
"type": "::",
"named": false
}
]
},
{
"type": "_expression",
"named": true,
Expand Down Expand Up @@ -1214,16 +1232,8 @@
"required": false,
"types": [
{
"type": "&.",
"named": false
},
{
"type": ".",
"named": false
},
{
"type": "::",
"named": false
"type": "_call_operator",
"named": true
}
]
},
Expand Down
Loading

0 comments on commit 0fdbd41

Please sign in to comment.