ClickHouse/dbms/include/DB/Parsers/ParserSelectQuery.h

48 lines
960 B
C
Raw Normal View History

2011-08-15 01:12:57 +00:00
#pragma once
2010-06-24 19:12:10 +00:00
#include <DB/Parsers/ASTSelectQuery.h>
#include <DB/Parsers/IParserBase.h>
#include <DB/Parsers/CommonParsers.h>
#include <DB/Parsers/ExpressionListParsers.h>
namespace DB
{
class ParserSelectQuery : public IParserBase
{
protected:
String getName() { return "SELECT query"; }
bool parseImpl(Pos & pos, Pos end, ASTPtr & node, String & expected)
{
Pos begin = pos;
ASTPtr select_expression_list;
ParserWhiteSpaceOrComments ws;
2011-08-15 01:12:57 +00:00
ParserString s("SELECT", true, true);
2010-06-24 19:12:10 +00:00
ParserNotEmptyExpressionList exp_list;
2010-06-24 19:37:23 +00:00
2010-06-24 19:12:10 +00:00
ws.ignore(pos, end);
2010-06-25 16:36:13 +00:00
if (!s.ignore(pos, end, expected))
2010-06-24 19:12:10 +00:00
return false;
ws.ignore(pos, end);
if (!exp_list.parse(pos, end, select_expression_list, expected))
return false;
ASTSelectQuery * select_query = new ASTSelectQuery(StringRange(begin, pos));
node = select_query;
select_query->select = select_expression_list;
2011-08-13 21:05:18 +00:00
select_query->children.push_back(select_query->select);
2010-06-24 19:12:10 +00:00
return true;
}
};
}