Skip to content

Commit e4420a8

Browse files
authored
Merge pull request #176 from keynmol/string-interpolation-case
String interpolation case pattern
2 parents 067ee61 + 0ca3020 commit e4420a8

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

corpus/expressions.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ def matchTest(x: Int): String = x match {
420420
case A if a == 1 =>
421421
case A if a == 2 => 2
422422
case ((i, _)) => i
423+
case s"$l1 -- $l2" =>
424+
l1 + l2
423425
case _ =>
424426
val x = "many"
425427
"more"
@@ -440,6 +442,18 @@ def matchTest(x: Int): String = x match {
440442
(case_clause (identifier) (guard (infix_expression (identifier) (operator_identifier) (integer_literal))))
441443
(case_clause (identifier) (guard (infix_expression (identifier) (operator_identifier) (integer_literal))) (integer_literal))
442444
(case_clause (tuple_pattern (tuple_pattern (identifier) (wildcard))) (identifier))
445+
(case_clause
446+
(interpolated_string_expression
447+
(identifier)
448+
(interpolated_string
449+
(interpolation
450+
(identifier))
451+
(interpolation
452+
(identifier))))
453+
(infix_expression
454+
(identifier)
455+
(operator_identifier)
456+
(identifier)))
443457
(case_clause (wildcard) (val_definition (identifier) (string)) (string))))))
444458

445459
===============================

grammar.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ module.exports = grammar({
777777
_pattern: $ => choice(
778778
$._identifier,
779779
$.stable_identifier,
780+
$.interpolated_string_expression,
780781
$.capture_pattern,
781782
$.tuple_pattern,
782783
$.case_class_pattern,
@@ -1317,7 +1318,7 @@ module.exports = grammar({
13171318
)
13181319
),
13191320

1320-
string :$ =>
1321+
string: $ =>
13211322
choice(
13221323
$._simple_string,
13231324
$._simple_multiline_string

script/smoke_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This is an integration test to generally check the quality of parsing.
44

55
SCALA_SCALA_LIBRARY_EXPECTED=100
6-
SCALA_SCALA_COMPILER_EXPECTED=66
6+
SCALA_SCALA_COMPILER_EXPECTED=67
77
DOTTY_COMPILER_EXPECTED=65
88

99
if [ ! -d "$SCALA_SCALA_DIR" ]; then

0 commit comments

Comments
 (0)