mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Support for nested multiline comments
This commit is contained in:
parent
9acb8fe196
commit
7304bad56f
@ -253,14 +253,26 @@ Token Lexer::nextTokenImpl()
|
||||
else
|
||||
{
|
||||
++pos;
|
||||
|
||||
/// Nested multiline comments are supported according to the SQL standard.
|
||||
size_t nesting_level = 1;
|
||||
|
||||
while (pos + 2 <= end)
|
||||
{
|
||||
/// This means that nested multiline comments are not supported.
|
||||
if (pos[0] == '*' && pos[1] == '/')
|
||||
if (pos[0] == '/' && pos[1] == '*')
|
||||
{
|
||||
pos += 2;
|
||||
++nesting_level;
|
||||
}
|
||||
else if (pos[0] == '*' && pos[1] == '/')
|
||||
{
|
||||
pos += 2;
|
||||
--nesting_level;
|
||||
|
||||
if (nesting_level == 0)
|
||||
return Token(TokenType::Comment, token_begin, pos);
|
||||
}
|
||||
else
|
||||
++pos;
|
||||
}
|
||||
return Token(TokenType::ErrorMultilineCommentIsNotClosed, token_begin, end);
|
||||
|
@ -0,0 +1,3 @@
|
||||
1
|
||||
1
|
||||
1
|
@ -0,0 +1,3 @@
|
||||
SELECT /*/**/*/ 1;
|
||||
SELECT /*a/*b*/c*/ 1;
|
||||
SELECT /*ab/*cd*/ef*/ 1;
|
Loading…
Reference in New Issue
Block a user