Skip to content

Commit f452031

Browse files
committed
refactor: better handling of token tree characters
Queries to capture these symbols now works
1 parent 72a14b7 commit f452031

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

grammar.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ const numeric_types = [
3434
'f64'
3535
]
3636

37+
const TOKEN_TREE_NON_SPECIAL_TOKENS = [
38+
'/', '_', '\\', '-',
39+
'=', '->', ',', ';',
40+
':', '::', '!', '?',
41+
'.', '@', '*', '&',
42+
'#', '%', '^', '+',
43+
'<', '>', '|', '~',
44+
];
45+
3746
const primitive_types = numeric_types.concat(['bool', 'str', 'char'])
3847

3948
module.exports = grammar({
@@ -202,7 +211,7 @@ module.exports = grammar({
202211
_non_special_token: $ => choice(
203212
$._literal, $.identifier, $.mutable_specifier, $.self, $.super, $.crate,
204213
alias(choice(...primitive_types), $.primitive_type),
205-
/[/_\-=->,;:::!=?.@*&#%^+<>|~]+/,
214+
prec.right(repeat1(choice(...TOKEN_TREE_NON_SPECIAL_TOKENS))),
206215
'\'',
207216
'as', 'async', 'await', 'break', 'const', 'continue', 'default', 'enum', 'fn', 'for', 'if', 'impl',
208217
'let', 'loop', 'match', 'mod', 'pub', 'return', 'static', 'struct', 'trait', 'type',

0 commit comments

Comments
 (0)