diff options
author | robot-piglet <[email protected]> | 2025-04-07 20:58:57 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-04-07 21:09:44 +0300 |
commit | 25675750186a875635ae4bc00d2433a3b4633e51 (patch) | |
tree | b1c35c1e68ec744977b95ff5b6331bb8ee10876a /yql/essentials/sql/v1/lexer/regex | |
parent | 2ec92416296dc1af11b6b60cc53e18cca4933487 (diff) |
Intermediate changes
commit_hash:6768768ea3a3962231d3fabdffb2ce0db44e9347
Diffstat (limited to 'yql/essentials/sql/v1/lexer/regex')
-rw-r--r-- | yql/essentials/sql/v1/lexer/regex/lexer_ut.cpp | 8 | ||||
-rw-r--r-- | yql/essentials/sql/v1/lexer/regex/regex_ut.cpp | 18 | ||||
-rw-r--r-- | yql/essentials/sql/v1/lexer/regex/ut/ya.make | 2 |
3 files changed, 17 insertions, 11 deletions
diff --git a/yql/essentials/sql/v1/lexer/regex/lexer_ut.cpp b/yql/essentials/sql/v1/lexer/regex/lexer_ut.cpp index ae0d018e42d..03c84bcffe3 100644 --- a/yql/essentials/sql/v1/lexer/regex/lexer_ut.cpp +++ b/yql/essentials/sql/v1/lexer/regex/lexer_ut.cpp @@ -197,10 +197,10 @@ Y_UNIT_TEST_SUITE(RegexLexerTests) { TString expected = "SELECT WS(\n) " - "WS( ) WS( ) INTEGER_VALUE(123467) COMMA(,) WS(\n) " + "WS( ) WS( ) DIGITS(123467) COMMA(,) WS(\n) " "WS( ) WS( ) STRING_VALUE(\"Hello, {name}!\") COMMA(,) WS(\n) " - "WS( ) WS( ) LPAREN(() INTEGER_VALUE(1) WS( ) PLUS(+) WS( ) LPAREN(() INTEGER_VALUE(5) WS( ) " - "ASTERISK(*) WS( ) INTEGER_VALUE(1) WS( ) SLASH(/) WS( ) INTEGER_VALUE(0) RPAREN()) " + "WS( ) WS( ) LPAREN(() DIGITS(1) WS( ) PLUS(+) WS( ) LPAREN(() DIGITS(5) WS( ) " + "ASTERISK(*) WS( ) DIGITS(1) WS( ) SLASH(/) WS( ) DIGITS(0) RPAREN()) " "RPAREN()) COMMA(,) WS(\n) " "WS( ) WS( ) ID_PLAIN(MIN) LPAREN(() ID_PLAIN(identifier) RPAREN()) COMMA(,) WS(\n) " "WS( ) WS( ) ID_PLAIN(Bool) LPAREN(() ID_PLAIN(field) RPAREN()) COMMA(,) WS(\n) " @@ -216,4 +216,4 @@ Y_UNIT_TEST_SUITE(RegexLexerTests) { Check("\" SELECT", "[INVALID] WS( ) SELECT EOF"); } -} // Y_UNIT_TEST_SUITE(RegexLexerTests) +} // Y_UNIT_TEST_SUITE(RegexLexerTests)
\ No newline at end of file diff --git a/yql/essentials/sql/v1/lexer/regex/regex_ut.cpp b/yql/essentials/sql/v1/lexer/regex/regex_ut.cpp index 47a94f53ed0..dad0b2ebd2d 100644 --- a/yql/essentials/sql/v1/lexer/regex/regex_ut.cpp +++ b/yql/essentials/sql/v1/lexer/regex/regex_ut.cpp @@ -8,12 +8,18 @@ using namespace NSQLTranslationV1; namespace { auto grammar = NSQLReflect::LoadLexerGrammar(); - auto defaultRegexes = MakeRegexByOtherNameMap(grammar, /* ansi = */ false); - auto ansiRegexes = MakeRegexByOtherNameMap(grammar, /* ansi = */ true); + auto defaultRegexes = MakeRegexByOtherName(grammar, /* ansi = */ false); + auto ansiRegexes = MakeRegexByOtherName(grammar, /* ansi = */ true); + + TString Get(const TVector<std::tuple<TString, TString>>& regexes, const TStringBuf name) { + return std::get<1>(*FindIf(regexes, [&](const auto& pair) { + return std::get<0>(pair) == name; + })); + } void CheckRegex(bool ansi, const TStringBuf name, const TStringBuf expected) { const auto& regexes = ansi ? ansiRegexes : defaultRegexes; - const TString regex = regexes.at(name); + const TString regex = Get(regexes, name); const RE2 re2(regex); Y_ENSURE(re2.ok(), re2.error()); @@ -83,8 +89,8 @@ Y_UNIT_TEST_SUITE(SqlRegexTests) { Y_UNIT_TEST(AnsiCommentSameAsDefault) { // Because of recursive definition UNIT_ASSERT_VALUES_EQUAL( - ansiRegexes.at("COMMENT"), - defaultRegexes.at("COMMENT")); + Get(ansiRegexes, "COMMENT"), + Get(defaultRegexes, "COMMENT")); } -} // Y_UNIT_TEST_SUITE(SqlRegexTests) +} // Y_UNIT_TEST_SUITE(SqlRegexTests)
\ No newline at end of file diff --git a/yql/essentials/sql/v1/lexer/regex/ut/ya.make b/yql/essentials/sql/v1/lexer/regex/ut/ya.make index 09eb74a3f68..7123f50c70c 100644 --- a/yql/essentials/sql/v1/lexer/regex/ut/ya.make +++ b/yql/essentials/sql/v1/lexer/regex/ut/ya.make @@ -10,4 +10,4 @@ SRCS( regex_ut.cpp ) -END() +END()
\ No newline at end of file |