@@ -69,7 +69,9 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
6969 && ( stream . peek ( ) == "'" || ( stream . peek ( ) == '"' && support . doubleQuote ) ) ) {
7070 // escape constant: E'str', e'str'
7171 // ref: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE
72- state . tokenize = tokenLiteral ( stream . peek ( ) , true ) ;
72+ state . tokenize = function ( stream , state ) {
73+ return ( state . tokenize = tokenLiteral ( stream . next ( ) , true ) ) ( stream , state ) ;
74+ }
7375 return "keyword" ;
7476 } else if ( support . commentSlashSlash && ch == "/" && stream . eat ( "/" ) ) {
7577 // 1-line comment
@@ -128,19 +130,15 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
128130 }
129131
130132 // 'string', with char specified in quote escaped by '\'
131- function tokenLiteral ( quote , withEscapeConst ) {
133+ function tokenLiteral ( quote , backslashEscapes ) {
132134 return function ( stream , state ) {
133135 var escaped = false , ch ;
134- /* eat the first quote in case of escape constant */
135- if ( withEscapeConst ) {
136- ch = stream . eat ( quote )
137- }
138136 while ( ( ch = stream . next ( ) ) != null ) {
139137 if ( ch == quote && ! escaped ) {
140138 state . tokenize = tokenBase ;
141139 break ;
142140 }
143- escaped = ( backslashStringEscapes || withEscapeConst ) && ! escaped && ch == "\\" ;
141+ escaped = ( backslashStringEscapes || backslashEscapes ) && ! escaped && ch == "\\" ;
144142 }
145143 return "string" ;
146144 } ;
0 commit comments