Skip to content

Commit 06a5237

Browse files
committed
Replace dynamic with additional node
**Problem** 350 introduced a dynamic precedence to resolve the conflict of Scala 2 and Scala 3 grammar for if-then. **Solution** This removes the dynamic precedence and replaces it with prec.right around `then` side. **Note** There's a report of parser getting stuck #392 and and I was hoping that removing dynamic precedence would fix that, but it didn't seem to.
1 parent de465b0 commit 06a5237

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

grammar.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -1133,17 +1133,16 @@ module.exports = grammar({
11331133
),
11341134
),
11351135

1136-
// NOTE(susliko): _if_condition and its magic dynamic precedence were introduced as a fix to
1137-
// https://github.com/tree-sitter/tree-sitter-scala/issues/263 and
1138-
// https://github.com/tree-sitter/tree-sitter-scala/issues/342
1139-
// Neither do I understand why this works, nor have I found a better solution
11401136
_if_condition: $ =>
1141-
prec.dynamic(
1142-
4,
1143-
choice(
1144-
$.parenthesized_expression,
1145-
seq($._indentable_expression, "then"),
1146-
),
1137+
choice(
1138+
$.parenthesized_expression,
1139+
$._then_condition,
1140+
),
1141+
1142+
_then_condition: $ =>
1143+
prec.right(
1144+
PREC.control,
1145+
seq($._indentable_expression, "then"),
11471146
),
11481147

11491148
/*

script/smoke_test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
SCALA_SCALA_LIBRARY_EXPECTED=100
66
SCALA_SCALA_COMPILER_EXPECTED=96
7-
DOTTY_COMPILER_EXPECTED=83
7+
DOTTY_COMPILER_EXPECTED=85
88
LILA_MODULES_EXPECTED=84
99
SYNTAX_COMPLEXITY_CEILING=1400
1010

0 commit comments

Comments
 (0)