Skip to content

Commit 91529e9

Browse files
committed
Exclude colon, at, and equal from single opchar
**Problem** Currently operator_identifier includes characters like colon at and equal even though they cannot be a legal operator without backticks. Having equal etc pushes tree-sitter into thinking some construct to be an infix operation when they are `=`. Another compilication is Unicode Math symbols, which includes equal sign. **Solution** Remove colon, at, equal sign, and Math symbols from the single-char operator_identifier. This adds back back a few Math symbol unicodes.
1 parent 70b4fe6 commit 91529e9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

grammar.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,8 +1484,11 @@ module.exports = grammar({
14841484
operator_identifier: $ =>
14851485
token(
14861486
choice(
1487-
// single opchar
1488-
/[\-!#%&*+\/\\:<=>?@\u005e\u007c~\p{Sm}\p{So}]/,
1487+
// opchar minus colon, equal, at
1488+
// Technically speaking, Sm (Math symbols https://www.compart.com/en/unicode/category/Sm)
1489+
// should be allowed as a single-characeter opchar, however, it includes `=`,
1490+
// so we should to avoid that to prevent bad parsing of `=` as infix term or type.
1491+
/[\-!#%&*+\/\\<>?\u005e\u007c~\u00ac\u00b1\u00d7\u00f7\u2190-\u2194\p{So}]/,
14891492
seq(
14901493
// opchar minus slash
14911494
/[\-!#%&*+\\:<=>?@\u005e\u007c~\p{Sm}\p{So}]/,

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=96
6+
SCALA_SCALA_COMPILER_EXPECTED=97
77
DOTTY_COMPILER_EXPECTED=85
88
SYNTAX_COMPLEXITY_CEILING=1400
99

0 commit comments

Comments
 (0)