mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Using lexer (incomplete) [#CLICKHOUSE-2].
This commit is contained in:
parent
d5c9301776
commit
e4d410fe13
@ -22,6 +22,9 @@ const char * ParserKeyword::getName() const
|
||||
|
||||
bool ParserKeyword::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
{
|
||||
if (pos->type != TokenType::BareWord)
|
||||
return false;
|
||||
|
||||
const char * current_word = s;
|
||||
|
||||
size_t s_length = strlen(s);
|
||||
@ -32,6 +35,9 @@ bool ParserKeyword::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (pos->type != TokenType::BareWord)
|
||||
return false;
|
||||
|
||||
const char * next_whitespace = find_first_symbols<' ', '\0'>(current_word, s_end);
|
||||
size_t word_length = next_whitespace - current_word;
|
||||
|
||||
|
@ -152,7 +152,7 @@ bool ParserIdentifier::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
else if (pos->type == TokenType::BareWord)
|
||||
{
|
||||
++pos;
|
||||
node = std::make_shared<ASTIdentifier>(StringRange(begin, pos), String(begin->begin, begin->end));
|
||||
node = std::make_shared<ASTIdentifier>(StringRange(begin), String(begin->begin, begin->end));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ struct StringRange
|
||||
StringRange() {}
|
||||
StringRange(const char * begin, const char * end) : first(begin), second(end) {}
|
||||
StringRange(TokenIterator token_begin, TokenIterator token_end) : first(token_begin->begin), second(token_end->begin) {}
|
||||
StringRange(TokenIterator token) : first(token->begin), second(token->end) {}
|
||||
};
|
||||
|
||||
using StringPtr = std::shared_ptr<String>;
|
||||
|
Loading…
Reference in New Issue
Block a user