Using lexer (incomplete) [#CLICKHOUSE-2].

This commit is contained in:
Alexey Milovidov 2017-07-12 06:43:50 +03:00 committed by alexey-milovidov
parent d5c9301776
commit e4d410fe13
3 changed files with 8 additions and 1 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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>;