mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Added tests
This commit is contained in:
parent
63f67f7997
commit
49983883cc
@ -422,7 +422,7 @@ private:
|
||||
{TokenType::Semicolon, Replxx::Color::INTENSE},
|
||||
{TokenType::Dot, Replxx::Color::INTENSE},
|
||||
{TokenType::Asterisk, Replxx::Color::INTENSE},
|
||||
{TokenType::HereDoc, Replxx::Color::BLUE},
|
||||
{TokenType::HereDoc, Replxx::Color::CYAN},
|
||||
{TokenType::Plus, Replxx::Color::INTENSE},
|
||||
{TokenType::Minus, Replxx::Color::INTENSE},
|
||||
{TokenType::Slash, Replxx::Color::INTENSE},
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <Parsers/Lexer.h>
|
||||
#include <Common/StringUtils/StringUtils.h>
|
||||
#include <common/find_symbols.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -340,22 +339,16 @@ Token Lexer::nextTokenImpl()
|
||||
default:
|
||||
if (*pos == '$')
|
||||
{
|
||||
if (((pos + 1 < end && !isWordCharASCII(pos[1])) || pos + 1 == end))
|
||||
{
|
||||
/// Capture standalone dollar sign
|
||||
return Token(TokenType::DollarSign, token_begin, ++pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string_view token_stream(pos, end - pos);
|
||||
/// Try to capture dollar sign as start of here doc
|
||||
|
||||
std::string_view token_stream(pos, end - pos);
|
||||
auto heredoc_name_end_position = token_stream.find('$', 1);
|
||||
if (heredoc_name_end_position != std::string::npos)
|
||||
{
|
||||
size_t heredoc_size = heredoc_name_end_position + 1;
|
||||
std::string_view heredoc = {token_stream.data(), heredoc_size};
|
||||
|
||||
size_t heredoc_end_position = token_stream.find(heredoc, heredoc_size + 1);
|
||||
size_t heredoc_end_position = token_stream.find(heredoc, heredoc_size);
|
||||
if (heredoc_end_position != std::string::npos)
|
||||
{
|
||||
|
||||
@ -365,6 +358,11 @@ Token Lexer::nextTokenImpl()
|
||||
return Token(TokenType::HereDoc, token_begin, pos);
|
||||
}
|
||||
}
|
||||
|
||||
if (((pos + 1 < end && !isWordCharASCII(pos[1])) || pos + 1 == end))
|
||||
{
|
||||
/// Capture standalone dollar sign
|
||||
return Token(TokenType::DollarSign, token_begin, ++pos);
|
||||
}
|
||||
}
|
||||
if (isWordCharASCII(*pos) || *pos == '$')
|
||||
|
4
tests/queries/0_stateless/01948_heredoc.reference
Normal file
4
tests/queries/0_stateless/01948_heredoc.reference
Normal file
@ -0,0 +1,4 @@
|
||||
VALUE
|
||||
|
||||
VALUE
|
||||
\'VALUE\'
|
4
tests/queries/0_stateless/01948_heredoc.sql
Normal file
4
tests/queries/0_stateless/01948_heredoc.sql
Normal file
@ -0,0 +1,4 @@
|
||||
SELECT $$VALUE$$;
|
||||
SELECT $doc$$doc$;
|
||||
SELECT $doc$VALUE$doc$;
|
||||
SELECT $doc$'VALUE'$doc$;
|
Loading…
Reference in New Issue
Block a user