Skip to content

Commit 3c8e186

Browse files
authored
tolk: fix match grammar (#2)
1 parent 305b04b commit 3c8e186

File tree

6 files changed

+6025
-5799
lines changed

6 files changed

+6025
-5799
lines changed

server/src/e2e/tolk/testcases/completion/local.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,20 @@ fun foo(someParameter: int) {
9090
}
9191
------------------------------------------------------------------------
9292
5 someParameter int
93+
94+
========================================================================
95+
Variable completion in match arm
96+
========================================================================
97+
fun foo() {
98+
val some = 10;
99+
val someOther = "hello";
100+
101+
match (some) {
102+
10 => {
103+
some<caret>
104+
}
105+
}
106+
}
107+
------------------------------------------------------------------------
108+
5 some int
109+
5 someOther slice

server/src/languages/tolk/tree-sitter-tolk/grammar.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ const TOLK_GRAMMAR = {
246246
choice($.tuple_vars_declaration, $.tensor_vars_declaration, $.var_declaration),
247247

248248
block_statement: $ =>
249-
prec(
249+
prec.dynamic(
250250
100,
251251
seq(
252252
"{",
@@ -541,7 +541,7 @@ const TOLK_GRAMMAR = {
541541
),
542542

543543
object_literal: $ =>
544-
prec(
544+
prec.dynamic(
545545
99,
546546
seq(optional(field("type", $._type_hint)), field("arguments", $.object_literal_body)),
547547
),
@@ -635,6 +635,7 @@ module.exports = grammar({
635635
[$._expression, $.type_instantiatedTs],
636636
[$.tensor_type, $.tensor_expression],
637637
[$.union_type],
638+
[$.block_statement, $.object_literal_body],
638639
],
639640

640641
extras: $ => [/\s/, $.comment],

server/src/languages/tolk/tree-sitter-tolk/src/grammar.json

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)