Skip to content

Commit 9d1cc45

Browse files
committed
1 parent ce1ee84 commit 9d1cc45

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

mode/sql/sql.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
8080
} else if (ch == "/" && stream.eat("*")) {
8181
// multi-line comments
8282
// ref: https://kb.askmonty.org/en/comment-syntax/
83-
state.tokenize = tokenComment;
83+
state.tokenize = tokenComment(1);
8484
return state.tokenize(stream, state);
8585
} else if (ch == ".") {
8686
// .1 for 0.1
@@ -130,20 +130,15 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
130130
return "string";
131131
};
132132
}
133-
function tokenComment(stream, state) {
134-
while (true) {
135-
if (stream.skipTo("*")) {
136-
stream.next();
137-
if (stream.eat("/")) {
138-
state.tokenize = tokenBase;
139-
break;
140-
}
141-
} else {
142-
stream.skipToEnd();
143-
break;
144-
}
133+
function tokenComment(depth) {
134+
return function(stream, state) {
135+
var m = stream.match(/^.*?(\/\*|\*\/)/)
136+
if (!m) stream.skipToEnd()
137+
else if (m[1] == "/*") state.tokenize = tokenComment(depth + 1)
138+
else if (depth > 1) state.tokenize = tokenComment(depth - 1)
139+
else state.tokenize = tokenBase
140+
return "comment"
145141
}
146-
return "comment";
147142
}
148143

149144
function pushContext(stream, state, type) {

0 commit comments

Comments
 (0)