unified: Add lambda and arguments fields

This commit is contained in:
Taus
2026-05-12 14:29:23 +00:00
parent 15d84b3e53
commit bc96ae6e47
2 changed files with 10 additions and 8 deletions

View File

@@ -760,19 +760,19 @@ module.exports = grammar({
prec(
PRECS.call_suffix,
choice(
$.value_arguments,
field("arguments", $.value_arguments),
prec.dynamic(-1, $._fn_call_lambda_arguments), // Prefer to treat `foo() { }` as one call not two
seq($.value_arguments, $._fn_call_lambda_arguments)
seq(field("arguments", $.value_arguments), $._fn_call_lambda_arguments)
)
),
constructor_suffix: ($) =>
prec(
PRECS.call_suffix,
choice(
alias($._constructor_value_arguments, $.value_arguments),
field("arguments", alias($._constructor_value_arguments, $.value_arguments)),
prec.dynamic(-1, $._fn_call_lambda_arguments), // As above
seq(
alias($._constructor_value_arguments, $.value_arguments),
field("arguments", alias($._constructor_value_arguments, $.value_arguments)),
$._fn_call_lambda_arguments
)
)
@@ -780,7 +780,7 @@ module.exports = grammar({
_constructor_value_arguments: ($) =>
seq("(", optional(sep1Opt(field("argument", $.value_argument), ",")), ")"),
_fn_call_lambda_arguments: ($) =>
sep1($.lambda_literal, seq(field("name", $.simple_identifier), ":")),
sep1(field("lambda", $.lambda_literal), seq(field("name", $.simple_identifier), ":")),
type_arguments: ($) => prec.left(seq("<", sep1Opt(field("argument", $.type), ","), ">")),
value_arguments: ($) =>
seq(
@@ -881,7 +881,7 @@ module.exports = grammar({
field("suffix", alias($.expr_hack_at_ternary_binary_call_suffix, $.call_suffix))
),
expr_hack_at_ternary_binary_call_suffix: ($) =>
prec(PRECS.call_suffix, $.value_arguments),
prec(PRECS.call_suffix, field("arguments", $.value_arguments)),
call_expression: ($) =>
prec(
PRECS.call,

View File

@@ -156,7 +156,8 @@ named:
function: expression
suffix: call_suffix
call_suffix:
$children+: [lambda_literal, value_arguments]
arguments?: value_arguments
lambda*: lambda_literal
name*: simple_identifier
capture_list:
item+: capture_list_item
@@ -215,7 +216,8 @@ named:
constructed_type: [array_type, dictionary_type, user_type]
suffix: constructor_suffix
constructor_suffix:
$children+: [lambda_literal, value_arguments]
arguments?: value_arguments
lambda*: lambda_literal
name*: simple_identifier
control_transfer_statement:
$children*: [expression, throw_keyword]