unified: Get rid of some "." bleed

Adds a new type `nested_type_identifier`, which contains the
choice-branch that previously allowed those tokens to bleed through into
the closest parent field.
This commit is contained in:
Taus
2026-05-08 16:07:12 +00:00
parent caa9b04ad8
commit 8b977ef8e1
2 changed files with 9 additions and 9 deletions

View File

@@ -1592,13 +1592,11 @@ module.exports = grammar({
choice($._equal_sign, $._eq_eq),
field("must_equal", $._type)
),
_constrained_type: ($) =>
choice(
$.identifier,
seq(
$.unannotated_type,
optional(seq(".", sep1($.simple_identifier, ".")))
)
_constrained_type: ($) => choice($.identifier, $.nested_type_identifier),
nested_type_identifier: ($) =>
seq(
$.unannotated_type,
optional(seq(".", sep1($.simple_identifier, ".")))
),
_class_member_separator: ($) => choice($._semi, $.multiline_comment),
_class_member_declarations: ($) =>

View File

@@ -203,7 +203,7 @@ named:
name*: unannotated_type
equality_constraint:
$children*: attribute
constrained_type+: [".", identifier, simple_identifier, unannotated_type]
constrained_type: [identifier, nested_type_identifier]
must_equal+: [type_modifiers, unannotated_type]
name: unannotated_type
equality_expression:
@@ -259,7 +259,7 @@ named:
rhs: expression
inheritance_constraint:
$children*: attribute
constrained_type+: [".", identifier, simple_identifier, unannotated_type]
constrained_type: [identifier, nested_type_identifier]
inherits_from+: [implicitly_unwrapped_type, type_modifiers, unannotated_type]
name?: unannotated_type
inheritance_modifier:
@@ -330,6 +330,8 @@ named:
target+: ["(", ")", array_type, dictionary_type, existential_type, expression, opaque_type, user_type]
navigation_suffix:
suffix: [integer_literal, simple_identifier]
nested_type_identifier:
$children+: [simple_identifier, unannotated_type]
nil_coalescing_expression:
if_nil: expression
value: expression