Merge pull request #281 from eed3si9n/wip/repeat_pattern

text_sliders
eugene yokota 2023-06-06 09:57:11 +07:00 committed by GitHub
commit e714736a88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 5 deletions

@ -141,6 +141,7 @@ val x = y match {
case a @ B(1) => a
case b @ C(d @ (e @ X, _: Y)) => e
case req @ (POST | GET) -> Root / "test" => 5
case Array(a: Type, _@_*) => y
}
---
@ -168,7 +169,18 @@ val x = y match {
(capture_pattern (identifier)
(tuple_pattern (alternative_pattern (identifier) (identifier))))
(operator_identifier) (identifier)) (operator_identifier) (string))
(integer_literal))))))
(integer_literal))
(case_clause
(case_class_pattern
(type_identifier)
(typed_pattern
(identifier)
(type_identifier))
(repeat_pattern
(capture_pattern
(wildcard)
(wildcard))))
(identifier))))))
============================
Quoted patterns (Scala 3 syntax)

@ -913,7 +913,8 @@ module.exports = grammar({
$.typed_pattern,
$.quote_expression,
$.literal,
$.wildcard
$.wildcard,
$.repeat_pattern,
),
case_class_pattern: $ => seq(
@ -929,10 +930,15 @@ module.exports = grammar({
field('right', $._pattern),
)),
capture_pattern: $ => prec(PREC.field, seq(
field('name', $._identifier),
capture_pattern: $ => prec.right(PREC.field, seq(
field('name', choice($._identifier, $.wildcard)),
'@',
field('pattern', $._pattern)
field('pattern', $._pattern),
)),
repeat_pattern: $ => prec.right(seq(
field('pattern', $._pattern),
'*',
)),
typed_pattern: $ => prec.right(seq(