diff options
author | vvvv <vvvv@yandex-team.com> | 2025-02-18 14:49:48 +0300 |
---|---|---|
committer | vvvv <vvvv@yandex-team.com> | 2025-02-18 16:08:18 +0300 |
commit | 1213d16b7fd20d4255d2ebb709a1745efbfeb91b (patch) | |
tree | a1cd11d96b5abf0a0ec287c76c4f3cfe9b32a86e /yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.cpp | |
parent | 408888e6801333da2d97af0b27a1c4da4448b9e0 (diff) | |
download | ydb-1213d16b7fd20d4255d2ebb709a1745efbfeb91b.tar.gz |
Introduced lexer & parser interfaces
commit_hash:fee365c90a176dd33a967cee20994b21d530080c
Diffstat (limited to 'yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.cpp')
-rw-r--r-- | yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.cpp b/yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.cpp new file mode 100644 index 00000000000..2490ca449d1 --- /dev/null +++ b/yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.cpp @@ -0,0 +1,35 @@ +#include "proto_parser.h" +#include <yql/essentials/parser/proto_ast/antlr3/proto_ast_antlr3.h> +#include <yql/essentials/parser/proto_ast/gen/v1/SQLv1Lexer.h> +#include <yql/essentials/parser/proto_ast/gen/v1/SQLv1Parser.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::TProtoASTBuilder3<NALPDefault::SQLv1Parser, NALPDefault::SQLv1Lexer> 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 MakeAntlr3ParserFactory() { + return MakeIntrusive<TFactory>(); +} + +} |