@@ -22,7 +22,9 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
2222 support = parserConfig . support || { } ,
2323 hooks = parserConfig . hooks || { } ,
2424 dateSQL = parserConfig . dateSQL || { "date" : true , "time" : true , "timestamp" : true } ,
25- backslashStringEscapes = parserConfig . backslashStringEscapes !== false
25+ backslashStringEscapes = parserConfig . backslashStringEscapes !== false ,
26+ brackets = parserConfig . brackets || / ^ [ \{ } \( \) \[ \] ] / ,
27+ punctuation = parserConfig . punctuation || / ^ [ ; . , : ] /
2628
2729 function tokenBase ( stream , state ) {
2830 var ch = stream . next ( ) ;
@@ -65,9 +67,6 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
6567 // charset casting: _utf8'str', N'str', n'str'
6668 // ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html
6769 return "keyword" ;
68- } else if ( / ^ [ \( \) , \; \[ \] ] / . test ( ch ) ) {
69- // no highlighting
70- return null ;
7170 } else if ( support . commentSlashSlash && ch == "/" && stream . eat ( "/" ) ) {
7271 // 1-line comment
7372 stream . skipToEnd ( ) ;
@@ -96,7 +95,15 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
9695 } else if ( operatorChars . test ( ch ) ) {
9796 // operators
9897 stream . eatWhile ( operatorChars ) ;
99- return null ;
98+ return "operator" ;
99+ } else if ( brackets . test ( ch ) ) {
100+ // brackets
101+ stream . eatWhile ( brackets ) ;
102+ return "bracket" ;
103+ } else if ( punctuation . test ( ch ) ) {
104+ // punctuation
105+ stream . eatWhile ( punctuation ) ;
106+ return "punctuation" ;
100107 } else if ( ch == '{' &&
101108 ( stream . match ( / ^ ( ) * ( d | D | t | T | t s | T S ) ( ) * ' [ ^ ' ] * ' ( ) * } / ) || stream . match ( / ^ ( ) * ( d | D | t | T | t s | T S ) ( ) * " [ ^ " ] * " ( ) * } / ) ) ) {
102109 // dates (weird ODBC syntax)
@@ -289,11 +296,13 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
289296
290297 CodeMirror . defineMIME ( "text/x-mssql" , {
291298 name : "sql" ,
292- client : set ( "charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee " ) ,
293- keywords : set ( sqlKeywords + "begin trigger proc view index for add constraint key primary foreign collate clustered nonclustered declare exec" ) ,
299+ client : set ( "$partition binary_checksum checksum connectionproperty context_info current_request_id error_line error_message error_number error_procedure error_severity error_state formatmessage get_filestream_transaction_context getansinull host_id host_name isnull isnumeric min_active_rowversion newid newsequentialid rowcount_big xact_state object_id " ) ,
300+ keywords : set ( sqlKeywords + "begin trigger proc view index for add constraint key primary foreign collate clustered nonclustered declare exec go if use index holdlock nolock nowait paglock readcommitted readcommittedlock readpast readuncommitted repeatableread rowlock serializable snapshot tablock tablockx updlock with " ) ,
294301 builtin : set ( "bigint numeric bit smallint decimal smallmoney int tinyint money float real char varchar text nchar nvarchar ntext binary varbinary image cursor timestamp hierarchyid uniqueidentifier sql_variant xml table " ) ,
295- atoms : set ( "false true null unknown" ) ,
296- operatorChars : / ^ [ * + \- % < > ! = ] / ,
302+ atoms : set ( "is not null like and or in left right between inner outer join all any some cross unpivot pivot exists" ) ,
303+ operatorChars : / ^ [ * + \- % < > ! = ^ \& | \/ ] / ,
304+ brackets : / ^ [ \{ } \( \) ] / ,
305+ punctuation : / ^ [ ; . , : / ] / ,
297306 backslashStringEscapes : false ,
298307 dateSQL : set ( "date datetimeoffset datetime2 smalldatetime datetime time" ) ,
299308 hooks : {
0 commit comments