1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#pragma once
#include <Parsers/IAST.h>
#include <Parsers/IParserBase.h>
#include <Parsers/CommonParsers.h>
#include <unordered_map>
namespace DB
{
namespace ErrorCodes
{
extern const int NOT_IMPLEMENTED;
}
namespace MySQLParser
{
struct OptionDescribe
{
const char * usage_name;
String option_name;
std::shared_ptr<IParser> value_parser;
OptionDescribe(const char * usage_name_, const String & option_name_, const std::shared_ptr<IParser> & value_parser_)
:usage_name(usage_name_), option_name(option_name_), value_parser(value_parser_)
{
}
};
class ASTDeclareOptions : public IAST
{
public:
std::unordered_map<String, ASTPtr> changes;
ASTPtr clone() const override;
String getID(char /*delimiter*/) const override { return "options declaration"; }
protected:
void formatImpl(const FormatSettings & /*settings*/, FormatState & /*state*/, FormatStateStacked /*frame*/) const override
{
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Method formatImpl is not supported by MySQLParser::ASTDeclareOptions.");
}
};
class ParserAlwaysTrue : public IParserBase
{
public:
const char * getName() const override { return "always true"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};
class ParserAlwaysFalse : public IParserBase
{
public:
const char * getName() const override { return "always false"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};
/// identifier, string literal, binary keyword
struct ParserCharsetOrCollateName : public IParserBase
{
protected:
const char * getName() const override { return "charset or collate name"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected &) override;
};
template <bool recursive>
class ParserDeclareOptionImpl : public IParserBase
{
protected:
std::vector<OptionDescribe> options_collection;
const char * getName() const override { return "option declaration"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
public:
ParserDeclareOptionImpl(const std::vector<OptionDescribe> & options_collection_) : options_collection(options_collection_) {}
};
using ParserDeclareOption = ParserDeclareOptionImpl<false>;
using ParserDeclareOptions = ParserDeclareOptionImpl<true>;
}
}
|