Skip to content

Commit ba3d506

Browse files
author
Roland Leißa
committed
proper SQL single-line comments
1 parent c451bdf commit ba3d506

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/sql/lexer.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,23 @@ Tok Lexer::lex() {
5555
if (accept('.')) return {loc_, Tok::Tag::T_dot};
5656
if (accept(';')) return {loc_, Tok::Tag::T_semicolon};
5757
if (accept('+')) return {loc_, Tok::Tag::T_add};
58-
if (accept('-')) return {loc_, Tok::Tag::T_sub};
5958
if (accept('*')) return {loc_, Tok::Tag::T_mul};
59+
60+
// sub or single-line comment
61+
if (accept('-')) {
62+
if (accept('-')) {
63+
while (ahead() != utf8::EoF && ahead() != '\n') next();
64+
continue;
65+
}
66+
return {loc_, Tok::Tag::T_sub};
67+
}
68+
69+
// div or multi-line comment
6070
if (accept('/')) {
6171
if (accept('*')) {
6272
eat_comments();
6373
continue;
6474
}
65-
if (accept('/')) {
66-
while (ahead() != utf8::EoF && ahead() != '\n') next();
67-
continue;
68-
}
69-
7075
return {loc_, Tok::Tag::T_div};
7176
}
7277

0 commit comments

Comments
 (0)