Skip to content

Commit

Permalink
improve grammar.js for receiver types
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzojive committed Oct 9, 2024
1 parent 5e4857f commit 081c770
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module.exports = grammar({
// ambiguity between multiple user types and class property/function declarations
[$.user_type],
[$.user_type, $.anonymous_function],
[$.user_type, $.function_type],
//[$.user_type, $.function_type],

// ambiguity between annotated_lambda with modifiers and modifiers from var declarations
[$.annotated_lambda, $.modifiers],
Expand All @@ -110,6 +110,9 @@ module.exports = grammar({
[$.type_modifiers],
// ambiguity between associating type modifiers
[$.not_nullable_type],

[$._receiver_type],
[$._receiver_type, $._type],
],

externals: $ => [
Expand Down Expand Up @@ -340,9 +343,9 @@ module.exports = grammar({
_receiver_type: $ => seq(
optional($.type_modifiers),
choice (
$._type_reference,
$.parenthesized_type,
$.nullable_type
$.nullable_type,
$._type_reference,
)
),

Expand Down Expand Up @@ -464,10 +467,10 @@ module.exports = grammar({
_type: $ => seq(
optional($.type_modifiers),
choice(
$.function_type,
$.parenthesized_type,
$.nullable_type,
$._type_reference,
$.function_type,
$.not_nullable_type
)
),
Expand Down Expand Up @@ -513,7 +516,8 @@ module.exports = grammar({
_type_projection_modifier: $ => $.variance_modifier,

function_type: $ => seq(
optional(seq($._simple_user_type, ".")), // TODO: Support "real" types
// TODO: [receiverType {NL} '.' {NL}] functionTypeParameters {NL} '->' {NL} type
optional(seq($._receiver_type, ".")), // TODO: Support "real" types
$.function_type_parameters,
"->",
$._type
Expand Down

0 comments on commit 081c770

Please sign in to comment.