2014-03-10 12:25:37 +00:00
|
|
|
#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:
|
2014-06-12 00:48:56 +00:00
|
|
|
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
|
|
|
|
2014-06-12 00:48:56 +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:
|
2014-06-12 00:48:56 +00:00
|
|
|
virtual bool parseImpl(Pos & pos, Pos end, ASTPtr & node, Expected & expected) = 0;
|
2010-06-24 19:12:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|