Skip to content

Commit 21483d0

Browse files
committed
fix: rework token tree punctuation
1 parent 58188b6 commit 21483d0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

grammar.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@ const numericTypes = [
4747
'f64',
4848
];
4949

50-
const TOKEN_TREE_NON_SPECIAL_TOKENS = [
51-
'/', '_', '\\', '-',
52-
'=', '->', ',', ';',
53-
':', '::', '!', '?',
54-
'.', '@', '*', '&',
55-
'#', '%', '^', '+',
56-
'<', '>', '|', '~',
50+
// https://doc.rust-lang.org/reference/tokens.html#punctuation
51+
const TOKEN_TREE_NON_SPECIAL_PUNCTUATION = [
52+
'+', '-', '*', '/', '%', '^', '!', '&', '|', '&&', '||', '<<',
53+
'>>', '+=', '-=', '*=', '/=', '%=', '^=', '&=', '|=', '<<=',
54+
'>>=', '=', '==', '!=', '>', '<', '>=', '<=', '@', '_', '.',
55+
'..', '...', '..=', ',', ';', ':', '::', '->', '=>', '#', '?',
5756
];
5857

5958
const primitiveTypes = numericTypes.concat(['bool', 'str', 'char']);
@@ -238,7 +237,7 @@ module.exports = grammar({
238237
_non_special_token: $ => choice(
239238
$._literal, $.identifier, $.mutable_specifier, $.self, $.super, $.crate,
240239
alias(choice(...primitiveTypes), $.primitive_type),
241-
prec.right(repeat1(choice(...TOKEN_TREE_NON_SPECIAL_TOKENS))),
240+
prec.right(repeat1(choice(...TOKEN_TREE_NON_SPECIAL_PUNCTUATION))),
242241
'\'',
243242
'as', 'async', 'await', 'break', 'const', 'continue', 'default', 'enum', 'fn', 'for', 'if', 'impl',
244243
'let', 'loop', 'match', 'mod', 'pub', 'return', 'static', 'struct', 'trait', 'type',

0 commit comments

Comments
 (0)