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

89 lines
2.1 KiB
C++
Raw Normal View History

2011-10-31 06:37:12 +00:00
#pragma once
2010-06-24 19:12:10 +00:00
#include <DB/Parsers/IParserBase.h>
namespace DB
{
2010-06-25 16:36:13 +00:00
/** Если прямо сейчас не s, то ошибка.
* Если word_boundary установлен в true, и последний символ строки - словарный (\w),
* то проверяется, что последующий символ строки не словарный.
2010-06-24 19:12:10 +00:00
*/
class ParserString : public IParserBase
{
private:
const char * s;
size_t s_size;
2010-06-25 16:36:13 +00:00
bool word_boundary;
2011-08-15 01:05:18 +00:00
bool case_insensitive;
2010-06-25 16:36:13 +00:00
2010-06-24 19:12:10 +00:00
public:
2016-11-12 17:55:40 +00:00
ParserString(const char * s_, bool word_boundary_ = false, bool case_insensitive_ = false);
2010-06-24 19:12:10 +00:00
protected:
2016-11-12 17:55:40 +00:00
const char * getName() const override;
bool parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) override;
2010-06-24 19:12:10 +00:00
};
2010-06-24 19:12:10 +00:00
/** пробельные символы
*/
class ParserWhiteSpace : public IParserBase
{
2011-10-31 06:37:12 +00:00
public:
2016-11-12 17:55:40 +00:00
ParserWhiteSpace(bool allow_newlines_ = true);
2011-10-31 06:37:12 +00:00
2010-06-24 19:12:10 +00:00
protected:
2011-10-31 06:37:12 +00:00
bool allow_newlines;
2016-11-12 17:55:40 +00:00
const char * getName() const override;
2010-06-24 19:12:10 +00:00
2016-11-12 17:55:40 +00:00
bool parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) override;
2010-06-24 19:12:10 +00:00
};
class ParserCStyleComment : public IParserBase
{
protected:
2016-11-12 17:55:40 +00:00
const char * getName() const override;
bool parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) override;
2010-06-24 19:12:10 +00:00
};
class ParserSQLStyleComment : public IParserBase
{
protected:
2016-11-12 17:55:40 +00:00
const char * getName() const override;
bool parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) override;
2010-06-24 19:12:10 +00:00
};
/** комментарии '--' или c-style
*/
class ParserComment : public IParserBase
{
protected:
2016-11-12 17:55:40 +00:00
const char * getName() const override;
2010-06-24 19:12:10 +00:00
2016-11-12 17:55:40 +00:00
bool parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) override;
2010-06-24 19:12:10 +00:00
};
class ParserWhiteSpaceOrComments : public IParserBase
{
2011-10-31 06:37:12 +00:00
public:
2016-11-12 17:55:40 +00:00
ParserWhiteSpaceOrComments(bool allow_newlines_outside_comments_ = true);
2010-06-24 19:12:10 +00:00
protected:
2011-10-31 06:37:12 +00:00
bool allow_newlines_outside_comments;
2016-11-12 17:55:40 +00:00
const char * getName() const override;
2016-11-12 17:55:40 +00:00
bool parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) override;
2010-06-24 19:12:10 +00:00
};
}