Skip to content

Commit 4a997ab

Browse files
committed
fix: typo in unknown segments
Rearrange regexps so special category catches everything not caught by other categories. Eliminates the "unknown" category I added in an earlier PR. Fixes #178
1 parent 353542a commit 4a997ab

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,15 @@ const highlighters = [
3333

3434
/(?<bracket>[()])/,
3535

36-
// Arithmetic, bitwise, comparison, and compound operators as listed in
37-
// https://www.w3schools.com/sql/sql_operators.asp, https://www.tutorialspoint.com/sql/sql-operators.htm,
38-
// https://data-flair.training/blogs/sql-operators/.
39-
// Plus a few other symbols used in SQL statements: ,;:.
40-
// Operators are arranged so that multi-character operators (ex: ">=") are parsed as one operator rather than two.
41-
/(?<special>\^-=|\|\*=|\+=|-=|\*=|\/=|%=|&=|>=|<=|<>|!=|!<|!>|>>|<<|[+\-*/%&|^=><]|[,;:.])/,
42-
4336
/(?<identifier>\b\w+\b|`(?:[^`\\]|\\.)*`)/,
4437

4538
/(?<whitespace>\s+)/,
4639

47-
/(?<unknown>\.+?)/
40+
// Multi-character arithmetic, bitwise, comparison, and compound operators as listed in
41+
// https://www.w3schools.com/sql/sql_operators.asp, https://www.tutorialspoint.com/sql/sql-operators.htm,
42+
// https://data-flair.training/blogs/sql-operators/, plus any single character (in particular ,::.) not matched by
43+
// the above regexps.
44+
/(?<special>\^-=|\|\*=|\+=|-=|\*=|\/=|%=|&=|>=|<=|<>|!=|!<|!>|>>|<<|.)/
4845
]
4946

5047
// Regex of the shape /(?<token1>...)|(?<token2>...)|.../g

0 commit comments

Comments
 (0)