mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Support for nested multiline comments
This commit is contained in:
parent
9acb8fe196
commit
7304bad56f
@ -253,15 +253,27 @@ Token Lexer::nextTokenImpl()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
|
/// Nested multiline comments are supported according to the SQL standard.
|
||||||
|
size_t nesting_level = 1;
|
||||||
|
|
||||||
while (pos + 2 <= end)
|
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;
|
pos += 2;
|
||||||
return Token(TokenType::Comment, token_begin, pos);
|
++nesting_level;
|
||||||
}
|
}
|
||||||
++pos;
|
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);
|
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