Skip to content

Commit

Permalink
fix!: fix method_types tree structure
Browse files Browse the repository at this point in the history
  • Loading branch information
joker1007 committed Dec 4, 2023
1 parent f32d372 commit 4962c56
Show file tree
Hide file tree
Showing 8 changed files with 5,386 additions and 5,665 deletions.
7 changes: 5 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = grammar({
inline: $ => [
$._no_parantheses_type,
$._parantheses_type,
$._nestable_decls,
],

conflicts: $ => [
Expand Down Expand Up @@ -272,7 +273,7 @@ module.exports = grammar({

generics_variance: $ => choice("out", "in"),

method_type: $ => seq(optional($.parameters), optional($.block), "->", $.type),
method_type_body: $ => seq(optional($.parameters), optional($.block), "->", $.type),

proc: $ => seq("^", optional($.parameters), optional($.self_type_binding), optional($.block), "->", $.type),

Expand Down Expand Up @@ -355,8 +356,10 @@ module.exports = grammar({
seq("def", $.self, "?.", $.method_name, ":", $.method_types),
),

method_type: $ => seq(optional($.method_type_parameters), alias(repeat($.annotation), $.annotations), $.method_type_body),

method_types: $ => choice(
sep1(seq(optional($.method_type_parameters), alias(repeat($.annotation), $.annotations), $.method_type), "|"),
sep1($.method_type, "|"),
"..."
),

Expand Down
104 changes: 40 additions & 64 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1905,7 +1905,7 @@
}
]
},
"method_type": {
"method_type_body": {
"type": "SEQ",
"members": [
{
Expand Down Expand Up @@ -3074,44 +3074,48 @@
}
]
},
"method_type": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "method_type_parameters"
},
{
"type": "BLANK"
}
]
},
{
"type": "ALIAS",
"content": {
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "annotation"
}
},
"named": true,
"value": "annotations"
},
{
"type": "SYMBOL",
"name": "method_type_body"
}
]
},
"method_types": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "method_type_parameters"
},
{
"type": "BLANK"
}
]
},
{
"type": "ALIAS",
"content": {
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "annotation"
}
},
"named": true,
"value": "annotations"
},
{
"type": "SYMBOL",
"name": "method_type"
}
]
"type": "SYMBOL",
"name": "method_type"
},
{
"type": "REPEAT",
Expand All @@ -3123,37 +3127,8 @@
"value": "|"
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "method_type_parameters"
},
{
"type": "BLANK"
}
]
},
{
"type": "ALIAS",
"content": {
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "annotation"
}
},
"named": true,
"value": "annotations"
},
{
"type": "SYMBOL",
"name": "method_type"
}
]
"type": "SYMBOL",
"name": "method_type"
}
]
}
Expand Down Expand Up @@ -3950,7 +3925,8 @@
"externals": [],
"inline": [
"_no_parantheses_type",
"_parantheses_type"
"_parantheses_type",
"_nestable_decls"
],
"supertypes": []
}
Expand Down
31 changes: 23 additions & 8 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,29 @@
"type": "method_type",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "annotations",
"named": true
},
{
"type": "method_type_body",
"named": true
},
{
"type": "method_type_parameters",
"named": true
}
]
}
},
{
"type": "method_type_body",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
Expand Down Expand Up @@ -842,17 +865,9 @@
"multiple": true,
"required": false,
"types": [
{
"type": "annotations",
"named": true
},
{
"type": "method_type",
"named": true
},
{
"type": "method_type_parameters",
"named": true
}
]
}
Expand Down
Loading

0 comments on commit 4962c56

Please sign in to comment.