Merge pull request #354 from susliko/wildcard-bindings

Wildcards in tuple bindings
pull/659/head
eugene yokota 2023-09-18 23:04:02 +07:00 committed by GitHub
commit 0692d044bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

@ -1067,6 +1067,7 @@ object O {
if (c) d.e }
{ a => implicit b => b }
{ (a: Int) ?=> (b: Int) => b }
{ (_, a) => a }
}
--------------------------------------------------------------------------------
@ -1157,7 +1158,15 @@ object O {
(binding
(identifier)
(type_identifier)))
(identifier)))))))
(identifier))))
(block
(lambda_expression
(bindings
(binding
(wildcard))
(binding
(identifier)))
(identifier))))))
================================================================================
Unit expressions

@ -92,6 +92,8 @@ module.exports = grammar({
// 'for' operator_identifier ':' _annotated_type • ':' …
[$._type, $.compound_type],
[$.lambda_expression, $.modifiers],
// _postfix_expression_choice ':' '(' wildcard • ':' …
[$.binding, $._simple_type],
],
word: $ => $._alpha_identifier,
@ -1159,11 +1161,14 @@ module.exports = grammar({
finally_clause: $ => prec.right(seq("finally", $._indentable_expression)),
/*
* Binding ::= (id | _) [: Type]
*/
binding: $ =>
prec.dynamic(
PREC.binding,
seq(
field("name", $._identifier),
choice(field("name", $._identifier), $.wildcard),
optional(seq(":", field("type", $._param_type))),
),
),