summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/proto_parser
diff options
context:
space:
mode:
authorvitya-smirnov <[email protected]>2025-10-07 09:34:39 +0300
committervitya-smirnov <[email protected]>2025-10-07 09:52:14 +0300
commitbabe7533f18c11be1f8a195ed2324d2d9a89436a (patch)
tree45b7627141bf5a52b45a3d61fd1fbdd564bb8dd9 /yql/essentials/sql/v1/proto_parser
parent8fe7cfe254fde2772477a8933a163b5f303716b4 (diff)
YQL-20086 sql/v1
commit_hash:55bc611cdaa0d8a0fc3c4c7708ed9f17cc4976cf
Diffstat (limited to 'yql/essentials/sql/v1/proto_parser')
-rw-r--r--yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.cpp8
-rw-r--r--yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.h2
-rw-r--r--yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.cpp8
-rw-r--r--yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.h2
-rw-r--r--yql/essentials/sql/v1/proto_parser/antlr4/proto_parser.cpp10
-rw-r--r--yql/essentials/sql/v1/proto_parser/antlr4/proto_parser.h2
-rw-r--r--yql/essentials/sql/v1/proto_parser/antlr4_ansi/proto_parser.cpp10
-rw-r--r--yql/essentials/sql/v1/proto_parser/antlr4_ansi/proto_parser.h2
-rw-r--r--yql/essentials/sql/v1/proto_parser/parse_tree.cpp176
-rw-r--r--yql/essentials/sql/v1/proto_parser/parse_tree.h10
-rw-r--r--yql/essentials/sql/v1/proto_parser/proto_parser.cpp12
-rw-r--r--yql/essentials/sql/v1/proto_parser/proto_parser.h26
-rw-r--r--yql/essentials/sql/v1/proto_parser/ya.make2
13 files changed, 135 insertions, 135 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
index 2490ca449d1..10f9892d31c 100644
--- a/yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.cpp
+++ b/yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.cpp
@@ -8,10 +8,10 @@ namespace NSQLTranslationV1 {
namespace {
-class TParser : public NSQLTranslation::IParser {
+class TParser: public NSQLTranslation::IParser {
public:
google::protobuf::Message* Parse(
- const TString& query, const TString& queryName, NProtoAST::IErrorCollector& err,
+ 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);
@@ -26,10 +26,10 @@ public:
}
};
-}
+} // namespace
NSQLTranslation::TParserFactoryPtr MakeAntlr3ParserFactory() {
return MakeIntrusive<TFactory>();
}
-}
+} // namespace NSQLTranslationV1
diff --git a/yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.h b/yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.h
index 5d40c2f1700..c72b0bb531f 100644
--- a/yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.h
+++ b/yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.h
@@ -5,4 +5,4 @@ namespace NSQLTranslationV1 {
NSQLTranslation::TParserFactoryPtr MakeAntlr3ParserFactory();
-}
+} // namespace NSQLTranslationV1
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
index 102f5e187e1..50f8a676edf 100644
--- a/yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.cpp
+++ b/yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.cpp
@@ -8,10 +8,10 @@ namespace NSQLTranslationV1 {
namespace {
-class TParser : public NSQLTranslation::IParser {
+class TParser: public NSQLTranslation::IParser {
public:
google::protobuf::Message* Parse(
- const TString& query, const TString& queryName, NProtoAST::IErrorCollector& err,
+ 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);
@@ -26,10 +26,10 @@ public:
}
};
-}
+} // namespace
NSQLTranslation::TParserFactoryPtr MakeAntlr3AnsiParserFactory() {
return MakeIntrusive<TFactory>();
}
-}
+} // namespace NSQLTranslationV1
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
index f03f1ea0a72..f852e003ee9 100644
--- a/yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.h
+++ b/yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.h
@@ -5,4 +5,4 @@ namespace NSQLTranslationV1 {
NSQLTranslation::TParserFactoryPtr MakeAntlr3AnsiParserFactory();
-}
+} // namespace NSQLTranslationV1
diff --git a/yql/essentials/sql/v1/proto_parser/antlr4/proto_parser.cpp b/yql/essentials/sql/v1/proto_parser/antlr4/proto_parser.cpp
index 6cdf0c6d2fb..2d29d0a6ffd 100644
--- a/yql/essentials/sql/v1/proto_parser/antlr4/proto_parser.cpp
+++ b/yql/essentials/sql/v1/proto_parser/antlr4/proto_parser.cpp
@@ -8,7 +8,7 @@ namespace NSQLTranslationV1 {
namespace {
-class TParser : public NSQLTranslation::IParser {
+class TParser: public NSQLTranslation::IParser {
public:
explicit TParser(bool isAmbuguityError, bool isAmbiguityDebugging)
: IsAmbiguityError_(isAmbuguityError)
@@ -17,13 +17,13 @@ public:
}
google::protobuf::Message* Parse(
- const TString& query, const TString& queryName, NProtoAST::IErrorCollector& err,
+ const TString& query, const TString& queryName, NProtoAST::IErrorCollector& err,
google::protobuf::Arena* arena) final {
YQL_ENSURE(arena);
NProtoAST::TProtoASTBuilder4<
NALPDefaultAntlr4::SQLv1Antlr4Parser,
NALPDefaultAntlr4::SQLv1Antlr4Lexer>
- builder(query, queryName, arena, IsAmbiguityError_, IsAmbiguityDebugging_);
+ builder(query, queryName, arena, IsAmbiguityError_, IsAmbiguityDebugging_);
return builder.BuildAST(err);
}
@@ -49,7 +49,7 @@ private:
bool IsAmbiguityDebugging_;
};
-}
+} // namespace
NSQLTranslation::TParserFactoryPtr MakeAntlr4ParserFactory(
bool isAmbiguityError,
@@ -58,4 +58,4 @@ NSQLTranslation::TParserFactoryPtr MakeAntlr4ParserFactory(
return MakeIntrusive<TFactory>(isAmbiguityError, isAmbiguityDebugging);
}
-}
+} // namespace NSQLTranslationV1
diff --git a/yql/essentials/sql/v1/proto_parser/antlr4/proto_parser.h b/yql/essentials/sql/v1/proto_parser/antlr4/proto_parser.h
index 5b33b43c0d3..146dcfff7aa 100644
--- a/yql/essentials/sql/v1/proto_parser/antlr4/proto_parser.h
+++ b/yql/essentials/sql/v1/proto_parser/antlr4/proto_parser.h
@@ -7,4 +7,4 @@ NSQLTranslation::TParserFactoryPtr MakeAntlr4ParserFactory(
bool isAmbiguityError = false,
bool isAmbiguityDebugging = false);
-}
+} // namespace NSQLTranslationV1
diff --git a/yql/essentials/sql/v1/proto_parser/antlr4_ansi/proto_parser.cpp b/yql/essentials/sql/v1/proto_parser/antlr4_ansi/proto_parser.cpp
index bf0160ade02..89eb7c5aa1a 100644
--- a/yql/essentials/sql/v1/proto_parser/antlr4_ansi/proto_parser.cpp
+++ b/yql/essentials/sql/v1/proto_parser/antlr4_ansi/proto_parser.cpp
@@ -8,7 +8,7 @@ namespace NSQLTranslationV1 {
namespace {
-class TParser : public NSQLTranslation::IParser {
+class TParser: public NSQLTranslation::IParser {
public:
explicit TParser(bool isAmbuguityError, bool isAmbiguityDebugging)
: IsAmbiguityError_(isAmbuguityError)
@@ -17,13 +17,13 @@ public:
}
google::protobuf::Message* Parse(
- const TString& query, const TString& queryName, NProtoAST::IErrorCollector& err,
+ 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, IsAmbiguityError_, IsAmbiguityDebugging_);
+ builder(query, queryName, arena, IsAmbiguityError_, IsAmbiguityDebugging_);
return builder.BuildAST(err);
}
@@ -49,7 +49,7 @@ private:
bool IsAmbiguityDebugging_;
};
-}
+} // namespace
NSQLTranslation::TParserFactoryPtr MakeAntlr4AnsiParserFactory(
bool isAmbiguityError,
@@ -58,4 +58,4 @@ NSQLTranslation::TParserFactoryPtr MakeAntlr4AnsiParserFactory(
return MakeIntrusive<TFactory>(isAmbiguityError, isAmbiguityDebugging);
}
-}
+} // namespace NSQLTranslationV1
diff --git a/yql/essentials/sql/v1/proto_parser/antlr4_ansi/proto_parser.h b/yql/essentials/sql/v1/proto_parser/antlr4_ansi/proto_parser.h
index 395d89674d6..39ff5d6eba2 100644
--- a/yql/essentials/sql/v1/proto_parser/antlr4_ansi/proto_parser.h
+++ b/yql/essentials/sql/v1/proto_parser/antlr4_ansi/proto_parser.h
@@ -7,4 +7,4 @@ NSQLTranslation::TParserFactoryPtr MakeAntlr4AnsiParserFactory(
bool isAmbiguityError = false,
bool isAmbiguityDebugging = false);
-}
+} // namespace NSQLTranslationV1
diff --git a/yql/essentials/sql/v1/proto_parser/parse_tree.cpp b/yql/essentials/sql/v1/proto_parser/parse_tree.cpp
index a9318368436..17fca6359d6 100644
--- a/yql/essentials/sql/v1/proto_parser/parse_tree.cpp
+++ b/yql/essentials/sql/v1/proto_parser/parse_tree.cpp
@@ -2,109 +2,109 @@
namespace NSQLTranslationV1 {
- const TRule_select_or_expr* GetSelectOrExpr(const TRule_smart_parenthesis& msg) {
- if (!msg.GetBlock2().HasAlt1()) {
- return nullptr;
- }
-
- return &msg.GetBlock2()
- .GetAlt1()
- .GetRule_select_subexpr1()
- .GetRule_select_subexpr_intersect1()
- .GetRule_select_or_expr1();
+const TRule_select_or_expr* GetSelectOrExpr(const TRule_smart_parenthesis& msg) {
+ if (!msg.GetBlock2().HasAlt1()) {
+ return nullptr;
}
- const TRule_tuple_or_expr* GetTupleOrExpr(const TRule_smart_parenthesis& msg) {
- const auto* select_or_expr = GetSelectOrExpr(msg);
- if (!select_or_expr) {
- return nullptr;
- }
+ return &msg.GetBlock2()
+ .GetAlt1()
+ .GetRule_select_subexpr1()
+ .GetRule_select_subexpr_intersect1()
+ .GetRule_select_or_expr1();
+}
+
+const TRule_tuple_or_expr* GetTupleOrExpr(const TRule_smart_parenthesis& msg) {
+ const auto* select_or_expr = GetSelectOrExpr(msg);
+ if (!select_or_expr) {
+ return nullptr;
+ }
+
+ if (!select_or_expr->HasAlt_select_or_expr2()) {
+ return nullptr;
+ }
- if (!select_or_expr->HasAlt_select_or_expr2()) {
- return nullptr;
- }
+ return &select_or_expr
+ ->GetAlt_select_or_expr2()
+ .GetRule_tuple_or_expr1();
+}
- return &select_or_expr
- ->GetAlt_select_or_expr2()
- .GetRule_tuple_or_expr1();
+const TRule_smart_parenthesis* GetParenthesis(const TRule_expr& msg) {
+ if (!msg.HasAlt_expr1()) {
+ return nullptr;
}
- const TRule_smart_parenthesis* GetParenthesis(const TRule_expr& msg) {
- if (!msg.HasAlt_expr1()) {
- return nullptr;
- }
-
- const auto& con = msg.GetAlt_expr1()
- .GetRule_or_subexpr1()
- .GetRule_and_subexpr1()
- .GetRule_xor_subexpr1()
- .GetRule_eq_subexpr1()
- .GetRule_neq_subexpr1()
- .GetRule_bit_subexpr1()
- .GetRule_add_subexpr1()
- .GetRule_mul_subexpr1()
- .GetRule_con_subexpr1();
-
- if (!con.HasAlt_con_subexpr1()) {
- return nullptr;
- }
-
- const auto& unary_subexpr = con.GetAlt_con_subexpr1()
- .GetRule_unary_subexpr1();
-
- if (!unary_subexpr.HasAlt_unary_subexpr1()) {
- return nullptr;
- }
-
- const auto& block = unary_subexpr.GetAlt_unary_subexpr1()
- .GetRule_unary_casual_subexpr1()
- .GetBlock1();
-
- if (!block.HasAlt2()) {
- return nullptr;
- }
-
- const auto& atom = block.GetAlt2()
- .GetRule_atom_expr1();
-
- if (!atom.HasAlt_atom_expr3()) {
- return nullptr;
- }
-
- return &atom.GetAlt_atom_expr3()
- .GetRule_lambda1()
- .GetRule_smart_parenthesis1();
+ const auto& con = msg.GetAlt_expr1()
+ .GetRule_or_subexpr1()
+ .GetRule_and_subexpr1()
+ .GetRule_xor_subexpr1()
+ .GetRule_eq_subexpr1()
+ .GetRule_neq_subexpr1()
+ .GetRule_bit_subexpr1()
+ .GetRule_add_subexpr1()
+ .GetRule_mul_subexpr1()
+ .GetRule_con_subexpr1();
+
+ if (!con.HasAlt_con_subexpr1()) {
+ return nullptr;
}
- bool IsSelect(const TRule_smart_parenthesis& msg) {
- const auto* select_or_expr = GetSelectOrExpr(msg);
- if (!select_or_expr) {
- return false;
- }
+ const auto& unary_subexpr = con.GetAlt_con_subexpr1()
+ .GetRule_unary_subexpr1();
- if (select_or_expr->HasAlt_select_or_expr1()) {
- return true;
- }
+ if (!unary_subexpr.HasAlt_unary_subexpr1()) {
+ return nullptr;
+ }
- return IsSelect(
- select_or_expr
- ->GetAlt_select_or_expr2()
- .GetRule_tuple_or_expr1()
- .GetRule_expr1());
+ const auto& block = unary_subexpr.GetAlt_unary_subexpr1()
+ .GetRule_unary_casual_subexpr1()
+ .GetBlock1();
+
+ if (!block.HasAlt2()) {
+ return nullptr;
}
- bool IsSelect(const TRule_expr& msg) {
- const auto* parenthesis = GetParenthesis(msg);
- if (!parenthesis) {
- return false;
- }
+ const auto& atom = block.GetAlt2()
+ .GetRule_atom_expr1();
- return IsSelect(*parenthesis);
+ if (!atom.HasAlt_atom_expr3()) {
+ return nullptr;
}
- bool IsOnlySubExpr(const TRule_select_subexpr& node) {
- return node.GetBlock2().size() == 0 &&
- node.GetRule_select_subexpr_intersect1().GetBlock2().size() == 0;
+ return &atom.GetAlt_atom_expr3()
+ .GetRule_lambda1()
+ .GetRule_smart_parenthesis1();
+}
+
+bool IsSelect(const TRule_smart_parenthesis& msg) {
+ const auto* select_or_expr = GetSelectOrExpr(msg);
+ if (!select_or_expr) {
+ return false;
+ }
+
+ if (select_or_expr->HasAlt_select_or_expr1()) {
+ return true;
}
+ return IsSelect(
+ select_or_expr
+ ->GetAlt_select_or_expr2()
+ .GetRule_tuple_or_expr1()
+ .GetRule_expr1());
+}
+
+bool IsSelect(const TRule_expr& msg) {
+ const auto* parenthesis = GetParenthesis(msg);
+ if (!parenthesis) {
+ return false;
+ }
+
+ return IsSelect(*parenthesis);
+}
+
+bool IsOnlySubExpr(const TRule_select_subexpr& node) {
+ return node.GetBlock2().size() == 0 &&
+ node.GetRule_select_subexpr_intersect1().GetBlock2().size() == 0;
+}
+
} // namespace NSQLTranslationV1
diff --git a/yql/essentials/sql/v1/proto_parser/parse_tree.h b/yql/essentials/sql/v1/proto_parser/parse_tree.h
index 74936d90466..40ecdea8623 100644
--- a/yql/essentials/sql/v1/proto_parser/parse_tree.h
+++ b/yql/essentials/sql/v1/proto_parser/parse_tree.h
@@ -4,14 +4,14 @@
namespace NSQLTranslationV1 {
- using namespace NSQLv1Generated;
+using namespace NSQLv1Generated;
- const TRule_tuple_or_expr* GetTupleOrExpr(const TRule_smart_parenthesis& msg);
+const TRule_tuple_or_expr* GetTupleOrExpr(const TRule_smart_parenthesis& msg);
- bool IsSelect(const TRule_smart_parenthesis& msg);
+bool IsSelect(const TRule_smart_parenthesis& msg);
- bool IsSelect(const TRule_expr& msg);
+bool IsSelect(const TRule_expr& msg);
- bool IsOnlySubExpr(const TRule_select_subexpr& msg);
+bool IsOnlySubExpr(const TRule_select_subexpr& msg);
} // namespace NSQLTranslationV1
diff --git a/yql/essentials/sql/v1/proto_parser/proto_parser.cpp b/yql/essentials/sql/v1/proto_parser/proto_parser.cpp
index 5fbef92ca52..bba5e729635 100644
--- a/yql/essentials/sql/v1/proto_parser/proto_parser.cpp
+++ b/yql/essentials/sql/v1/proto_parser/proto_parser.cpp
@@ -4,7 +4,6 @@
#include <yql/essentials/parser/proto_ast/collect_issues/collect_issues.h>
-
#include <yql/essentials/sql/v1/proto_parser/antlr3/proto_parser.h>
#include <yql/essentials/sql/v1/proto_parser/antlr3_ansi/proto_parser.h>
#include <yql/essentials/sql/v1/proto_parser/antlr4/proto_parser.h>
@@ -13,16 +12,15 @@
#include <util/generic/algorithm.h>
#if defined(_tsan_enabled_)
-#include <util/system/mutex.h>
+ #include <util/system/mutex.h>
#endif
using namespace NYql;
namespace NSQLTranslationV1 {
-
#if defined(_tsan_enabled_)
- TMutex SanitizerSQLTranslationMutex;
+TMutex SanitizerSQLTranslationMutex;
#endif
namespace {
@@ -31,16 +29,16 @@ void ReportError(NAST::IErrorCollector& err, const TString& name) {
err.Error(0, 0, TStringBuilder() << "Parser " << name << " is not supported");
}
-}
+} // namespace
google::protobuf::Message* SqlAST(const TParsers& parsers, const TString& query, const TString& queryName, TIssues& err,
- size_t maxErrors, bool ansiLexer, bool anlr4Parser, google::protobuf::Arena* arena) {
+ size_t maxErrors, bool ansiLexer, bool anlr4Parser, google::protobuf::Arena* arena) {
NSQLTranslation::TErrorCollectorOverIssues collector(err, maxErrors, queryName);
return SqlAST(parsers, query, queryName, collector, ansiLexer, anlr4Parser, arena);
}
google::protobuf::Message* SqlAST(const TParsers& parsers, const TString& query, const TString& queryName, NAST::IErrorCollector& err,
- bool ansiLexer, bool anlr4Parser, google::protobuf::Arena* arena) {
+ bool ansiLexer, bool anlr4Parser, google::protobuf::Arena* arena) {
YQL_ENSURE(arena);
#if defined(_tsan_enabled_)
TGuard<TMutex> grd(SanitizerSQLTranslationMutex);
diff --git a/yql/essentials/sql/v1/proto_parser/proto_parser.h b/yql/essentials/sql/v1/proto_parser/proto_parser.h
index 39c41771410..c4a3c663207 100644
--- a/yql/essentials/sql/v1/proto_parser/proto_parser.h
+++ b/yql/essentials/sql/v1/proto_parser/proto_parser.h
@@ -8,20 +8,20 @@
#include <google/protobuf/message.h>
namespace NSQLTranslation {
- struct TTranslationSettings;
-}
+struct TTranslationSettings;
+} // namespace NSQLTranslation
namespace NSQLTranslationV1 {
- struct TParsers {
- NSQLTranslation::TParserFactoryPtr Antlr3;
- NSQLTranslation::TParserFactoryPtr Antlr3Ansi;
- NSQLTranslation::TParserFactoryPtr Antlr4;
- NSQLTranslation::TParserFactoryPtr Antlr4Ansi;
- };
+struct TParsers {
+ NSQLTranslation::TParserFactoryPtr Antlr3;
+ NSQLTranslation::TParserFactoryPtr Antlr3Ansi;
+ NSQLTranslation::TParserFactoryPtr Antlr4;
+ NSQLTranslation::TParserFactoryPtr Antlr4Ansi;
+};
- google::protobuf::Message* SqlAST(const TParsers& parsers, const TString& query, const TString& queryName,
- NYql::TIssues& err, size_t maxErrors, bool ansiLexer, bool antlr4Parser, google::protobuf::Arena* arena);
- google::protobuf::Message* SqlAST(const TParsers& parsers, const TString& query, const TString& queryName,
- NAST::IErrorCollector& err, bool ansiLexer, bool antlr4Parser, google::protobuf::Arena* arena);
-} // namespace NSQLTranslationV1
+google::protobuf::Message* SqlAST(const TParsers& parsers, const TString& query, const TString& queryName,
+ NYql::TIssues& err, size_t maxErrors, bool ansiLexer, bool antlr4Parser, google::protobuf::Arena* arena);
+google::protobuf::Message* SqlAST(const TParsers& parsers, const TString& query, const TString& queryName,
+ NAST::IErrorCollector& err, bool ansiLexer, bool antlr4Parser, google::protobuf::Arena* arena);
+} // namespace NSQLTranslationV1
diff --git a/yql/essentials/sql/v1/proto_parser/ya.make b/yql/essentials/sql/v1/proto_parser/ya.make
index 0fbe9f45469..256a3091aec 100644
--- a/yql/essentials/sql/v1/proto_parser/ya.make
+++ b/yql/essentials/sql/v1/proto_parser/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
PEERDIR(
yql/essentials/utils
yql/essentials/parser/proto_ast/collect_issues