blob: fdc0cf647049de6d6c14322ea83ddd6c911be08b (
plain) (
blame)
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
|
#include "proto_parser.h"
#include <yql/essentials/parser/proto_ast/antlr4/proto_ast_antlr4.h>
#include <yql/essentials/parser/proto_ast/gen/v1_ansi_antlr4/SQLv1Antlr4Lexer.h>
#include <yql/essentials/parser/proto_ast/gen/v1_ansi_antlr4/SQLv1Antlr4Parser.h>
#include <yql/essentials/utils/yql_panic.h>
namespace NSQLTranslationV1 {
namespace {
class TParser : public NSQLTranslation::IParser {
public:
google::protobuf::Message* Parse(
const TString& query, const TString& queryName, NProtoAST::IErrorCollector& err,
google::protobuf::Arena* arena) final {
YQL_ENSURE(arena);
NProtoAST::TProtoASTBuilder4<NALPAnsiAntlr4::SQLv1Antlr4Parser, NALPAnsiAntlr4::SQLv1Antlr4Lexer> builder(query, queryName, arena);
return builder.BuildAST(err);
}
};
class TFactory: public NSQLTranslation::IParserFactory {
public:
std::unique_ptr<NSQLTranslation::IParser> MakeParser() const final {
return std::make_unique<TParser>();
}
};
}
NSQLTranslation::TParserFactoryPtr MakeAntlr4AnsiParserFactory() {
return MakeIntrusive<TFactory>();
}
}
|