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

37 lines
674 B
C
Raw Normal View History

#pragma once
2010-06-24 19:12:10 +00:00
#include <list>
#include <Poco/SharedPtr.h>
#include <DB/Core/Types.h>
#include <DB/Parsers/IParser.h>
2010-06-24 19:37:23 +00:00
#include <iostream>
2010-06-24 19:12:10 +00:00
namespace DB
{
/** Базовый класс для большинства парсеров
*/
class IParserBase : public IParser
{
public:
bool parse(Pos & pos, Pos end, ASTPtr & node, Expected & expected)
2010-06-24 19:12:10 +00:00
{
expected = getName();
2010-06-24 19:37:23 +00:00
bool res = parseImpl(pos, end, node, expected);
2014-04-06 07:23:42 +00:00
if (!res)
node = nullptr;
2014-04-06 07:23:42 +00:00
if (pos > end)
throw Exception("Logical error: pos > end.", ErrorCodes::LOGICAL_ERROR);
2010-06-24 19:37:23 +00:00
return res;
2010-06-24 19:12:10 +00:00
}
protected:
virtual bool parseImpl(Pos & pos, Pos end, ASTPtr & node, Expected & expected) = 0;
2010-06-24 19:12:10 +00:00
};
}