Skip to content

Commit 70af287

Browse files
wkeesescriptcoded
authored andcommitted
fix: typo in unknown segments
Rearrange regexps so "special" regexp catches everything not caught by other regexps. Eliminates the "unknown" segment I added in #148. In practice, the only time we would hit the "unknown" segment is for a few weird characters that weren't already caught by the "special" segment, for example, the ? and unclosed ` in "a `?> b". I figured that in those rare cases, we might as well just call those characters "special". Fixes #178, refs #148.
1 parent 183a4fb commit 70af287

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/index.js

+5-8
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)