Merge pull request #369 from susliko/infix-inline

pull/659/head
eugene yokota 2023-12-26 17:02:41 +07:00 committed by GitHub
commit 2b79741be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 29 deletions

@ -1661,8 +1661,7 @@ Infix methods (Scala 3)
================================================================================ ================================================================================
object Test: object Test:
infix private def hello = 25 inline infix private def hello = 25
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(compilation_unit (compilation_unit
@ -1671,6 +1670,7 @@ object Test:
(template_body (template_body
(function_definition (function_definition
(modifiers (modifiers
(inline_modifier)
(infix_modifier) (infix_modifier)
(access_modifier)) (access_modifier))
(identifier) (identifier)

@ -327,6 +327,12 @@ def other() {
else c() else c()
} }
def another() {
if (a) b match {
case _ => c
} else d
}
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
(compilation_unit (compilation_unit
@ -375,7 +381,21 @@ def other() {
(identifier)) (identifier))
(call_expression (call_expression
(identifier) (identifier)
(arguments)))))) (arguments)))))
(function_definition
(identifier)
(parameters)
(block
(if_expression
(parenthesized_expression
(identifier))
(match_expression
(identifier)
(case_block
(case_clause
(wildcard)
(identifier))))
(identifier)))))
================================================================================ ================================================================================
If expressions (Scala 3 syntax) If expressions (Scala 3 syntax)

@ -660,9 +660,8 @@ module.exports = grammar({
), ),
modifiers: $ => modifiers: $ =>
prec.left( prec.left(repeat1(
repeat1( prec.left(choice(
choice(
"abstract", "abstract",
"final", "final",
"sealed", "sealed",
@ -674,9 +673,8 @@ module.exports = grammar({
$.infix_modifier, $.infix_modifier,
$.open_modifier, $.open_modifier,
$.transparent_modifier, $.transparent_modifier,
), )),
), )),
),
access_modifier: $ => access_modifier: $ =>
prec.left( prec.left(
@ -790,7 +788,7 @@ module.exports = grammar({
), ),
_indentable_expression: $ => _indentable_expression: $ =>
choice($.indented_block, $.indented_cases, $.expression), prec.right(choice($.indented_block, $.indented_cases, $.expression)),
block: $ => seq("{", optional($._block), "}"), block: $ => seq("{", optional($._block), "}"),
@ -1145,15 +1143,12 @@ module.exports = grammar({
* MatchClause ::= 'match' <<< CaseClauses >>> * MatchClause ::= 'match' <<< CaseClauses >>>
*/ */
match_expression: $ => match_expression: $ =>
prec.left(
PREC.postfix,
seq( seq(
optional($.inline_modifier), optional($.inline_modifier),
field("value", $.expression), field("value", $.expression),
"match", "match",
field("body", choice($.case_block, $.indented_cases)), field("body", choice($.case_block, $.indented_cases)),
), ),
),
try_expression: $ => try_expression: $ =>
prec.right( prec.right(