Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ dist/
*.tar.gz
*.tgz
*.zip

# scala-cli
.scala-build
.bsp
7 changes: 6 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const PREC = {

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, scala_scala/src/library/: 100.00%, expected at least 100%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, scala_scala/src/compiler/: 96.65%, expected at least 96%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, dotty/compiler/: 83.62%, expected at least 83%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, lila/modules/: 84.88%, expected at least 84%
comment: 1,
using_directive: 2,
control: 1,
Expand Down Expand Up @@ -95,6 +95,8 @@
[$._if_condition, $._simple_expression],
// _postfix_expression_choice ':' '(' wildcard • ':' …
[$.binding, $._simple_type],
// expression 'match' 'case' _case_pattern ';' _automatic_semicolon expression • 'match' …
[$.match_expression, $._block],
],

word: $ => $._alpha_identifier,
Expand Down Expand Up @@ -806,6 +808,9 @@
indented_cases: $ =>
prec.left(seq($._indent, repeat1($.case_clause), $._outdent)),

non_indented_cases: $ =>
prec.right(sep1($._automatic_semicolon, $.case_clause)),

_indented_type_cases: $ =>
prec.left(seq($._indent, repeat1($.type_case_clause), $._outdent)),

Expand Down Expand Up @@ -891,7 +896,7 @@
),
),

tuple_type: $ => seq("(", trailingCommaSep1($._type), ")"),

Check failure on line 899 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

complexity of the most complex definition tuple_type: 1857, higher than the allowed ceiling 1400

singleton_type: $ =>
prec.left(
Expand Down Expand Up @@ -1157,7 +1162,7 @@
optional($.inline_modifier),
field("value", $.expression),
"match",
field("body", choice($.case_block, $.indented_cases)),
field("body", choice($.case_block, $.indented_cases, $.non_indented_cases)),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should non_indented_cases be aliased to indented_cases here to preserve compatibility for any queries that may not expect nodes other than case_block/indented_cases, wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to this.

),

try_expression: $ =>
Expand Down
36 changes: 26 additions & 10 deletions test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +689,12 @@ def matchTest(x: Int): String = x match {
case 3 => {
"3"
}
case 4 =>
case 4 =>
;
case A if a == 1 =>
case A if a == 2 => 2
case ((i, _)) => i
case s"$l1 -- $l2" =>
case s"$l1 -- $l2" =>
l1 + l2
case _ =>
val x = "many"
Expand Down Expand Up @@ -791,6 +791,10 @@ def matchTest(x: Int): String =
case _ =>
val x = "many"
"more"
y match
case 0 => "zero"
case 1 => "one"
case _ => "idk"

--------------------------------------------------------------------------------

Expand Down Expand Up @@ -837,6 +841,18 @@ def matchTest(x: Int): String =
(val_definition
(identifier)
(string))
(string))))
(match_expression
(identifier)
(non_indented_cases
(case_clause
(integer_literal)
(string))
(case_clause
(integer_literal)
(string))
(case_clause
(wildcard)
(string)))))))

================================================================================
Expand All @@ -850,8 +866,8 @@ class C {
a
.b
// comment1
/*
comment2
/*
Copy link
Collaborator Author

@susliko susliko Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes here and below are caused by changes in the behavior of tree-sitter test -u, which now removes trailing spaces

comment2
*/
.c
}
Expand Down Expand Up @@ -1105,11 +1121,11 @@ object O {
val l = a => a + 1
val b = (x: Int, y: Int) => { x * y }
val f = _ => 2
foo { i =>
val x = 2 + i
foo { i =>
val x = 2 + i
x
}
{ x =>
{ x =>
val y = 2 * x
y * y
}
Expand Down Expand Up @@ -1223,7 +1239,7 @@ Unit expressions
================================================================================

val x = ()
def f(): Unit = { (
def f(): Unit = { (
); }

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -1649,9 +1665,9 @@ class A:
Inline matches (Scala 3)
================================================================================

def hello =
def hello =
inline c match {
case 1 =>
case 1 =>
}

--------------------------------------------------------------------------------
Expand Down
Loading