diff options
author | vvvv <[email protected]> | 2025-02-18 14:49:48 +0300 |
---|---|---|
committer | vvvv <[email protected]> | 2025-02-18 16:08:18 +0300 |
commit | 1213d16b7fd20d4255d2ebb709a1745efbfeb91b (patch) | |
tree | a1cd11d96b5abf0a0ec287c76c4f3cfe9b32a86e /yql/essentials/sql/v1/proto_parser/antlr3_ansi | |
parent | 408888e6801333da2d97af0b27a1c4da4448b9e0 (diff) |
Introduced lexer & parser interfaces
commit_hash:fee365c90a176dd33a967cee20994b21d530080c
Diffstat (limited to 'yql/essentials/sql/v1/proto_parser/antlr3_ansi')
3 files changed, 56 insertions, 0 deletions
diff --git a/yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.cpp b/yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.cpp new file mode 100644 index 00000000000..102f5e187e1 --- /dev/null +++ b/yql/essentials/sql/v1/proto_parser/antlr3_ansi/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_ansi/SQLv1Lexer.h> +#include <yql/essentials/parser/proto_ast/gen/v1_ansi/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<NALPAnsi::SQLv1Parser, NALPAnsi::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 MakeAntlr3AnsiParserFactory() { + return MakeIntrusive<TFactory>(); +} + +} diff --git a/yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.h b/yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.h new file mode 100644 index 00000000000..f03f1ea0a72 --- /dev/null +++ b/yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.h @@ -0,0 +1,8 @@ +#pragma once +#include <yql/essentials/parser/proto_ast/common.h> + +namespace NSQLTranslationV1 { + +NSQLTranslation::TParserFactoryPtr MakeAntlr3AnsiParserFactory(); + +} diff --git a/yql/essentials/sql/v1/proto_parser/antlr3_ansi/ya.make b/yql/essentials/sql/v1/proto_parser/antlr3_ansi/ya.make new file mode 100644 index 00000000000..ce8b3f7917a --- /dev/null +++ b/yql/essentials/sql/v1/proto_parser/antlr3_ansi/ya.make @@ -0,0 +1,13 @@ +LIBRARY() + +PEERDIR( + yql/essentials/utils + yql/essentials/parser/proto_ast/antlr3 + yql/essentials/parser/proto_ast/gen/v1_ansi +) + +SRCS( + proto_parser.cpp +) + +END() |