adding # as a recognized start of single line comment

This commit is contained in:
Aaron Katz 2022-02-01 09:40:17 -08:00 committed by GitHub
parent c523544463
commit 0cac4b4a6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -280,6 +280,18 @@ Token Lexer::nextTokenImpl()
} }
return Token(TokenType::Slash, token_begin, pos); return Token(TokenType::Slash, token_begin, pos);
} }
case '#': /// start of single line comment, MySQL style
{ /// PostgreSQL has some operators using '#' character.
/// For less ambiguity, we will recognize a comment only if # is followed by whitespace.
/// or #! as a special case for "shebang".
/// #hello - not a comment
/// # hello - a comment
/// #!/usr/bin/clickhouse-local --queries-file - a comment
++pos;
if (pos < end && (*pos == ' ' || *pos == '!'))
return comment_until_end_of_line();
return Token(TokenType::Error, token_begin, pos);
}
case '%': case '%':
return Token(TokenType::Percent, token_begin, ++pos); return Token(TokenType::Percent, token_begin, ++pos);
case '=': /// =, == case '=': /// =, ==