unified: Make parenthesized_type named

I'm not entirely happy about this solution, but it seemed to be the most
straightforward way of avoiding various kinds of token bleeding.
This commit is contained in:
Taus
2026-05-12 15:38:29 +00:00
parent 2eee2e50dc
commit eb480d1de4
2 changed files with 10 additions and 8 deletions

View File

@@ -452,7 +452,7 @@ module.exports = grammar({
optional(sep1Opt(field("element", $.tuple_type_item), ",")),
")"
),
field("element", alias($._parenthesized_type, $.tuple_type_item))
field("element", alias($.parenthesized_type, $.tuple_type_item))
),
tuple_type_item: ($) =>
prec(
@@ -467,7 +467,7 @@ module.exports = grammar({
prec(
PRECS.expr,
seq(
optional($.wildcard_pattern),
optional(field("external_name", $.wildcard_pattern)),
field("name", $.simple_identifier),
":"
)
@@ -571,10 +571,10 @@ module.exports = grammar({
field("suffix", $.constructor_suffix)
)
),
_parenthesized_type: ($) =>
parenthesized_type: ($) =>
seq(
"(",
choice($.opaque_type, $.existential_type, $.dictionary_type),
field("type", choice($.opaque_type, $.existential_type, $.dictionary_type)),
")"
),
navigation_expression: ($) =>
@@ -586,7 +586,7 @@ module.exports = grammar({
choice(
$._navigable_type_expression,
$.expression,
$._parenthesized_type
$.parenthesized_type
)
),
field("suffix", $.navigation_suffix)

View File

@@ -445,7 +445,7 @@ named:
mutation_modifier:
navigation_expression:
suffix: navigation_suffix
target+: ["(", ")", array_type, dictionary_type, existential_type, expression, opaque_type, user_type]
target: [array_type, dictionary_type, expression, parenthesized_type, user_type]
navigation_suffix:
suffix: [integer_literal, simple_identifier]
nested_type_identifier:
@@ -479,6 +479,8 @@ named:
parameter_modifier:
parameter_modifiers:
modifier+: parameter_modifier
parenthesized_type:
type: [dictionary_type, existential_type, opaque_type]
pattern:
binding?: value_binding_pattern
bound_identifier?: simple_identifier
@@ -630,10 +632,10 @@ named:
tuple_type:
element*: tuple_type_item
tuple_type_item:
$children?: [dictionary_type, existential_type, opaque_type, wildcard_pattern]
external_name?: wildcard_pattern
modifiers?: parameter_modifiers
name?: simple_identifier
type?: type
type: [dictionary_type, existential_type, opaque_type, type]
type:
modifiers?: type_modifiers
name: unannotated_type