Skip to content

Commit e30933e

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 e30933e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
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}]/,

0 commit comments

Comments
 (0)