From 73573554efad4be66365750540f05633d293e344 Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes Date: Mon, 30 Dec 2024 10:39:53 -0300 Subject: [PATCH] Better temporary backward compatibility. --- src/isql/FrontendLexer.cpp | 41 +++++++++++++++++++++++-------------- src/isql/FrontendLexer.h | 3 --- src/isql/FrontendParser.cpp | 4 ++-- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/isql/FrontendLexer.cpp b/src/isql/FrontendLexer.cpp index 2a3c3602a0..fe75aad657 100644 --- a/src/isql/FrontendLexer.cpp +++ b/src/isql/FrontendLexer.cpp @@ -187,22 +187,8 @@ FrontendLexer::Token FrontendLexer::getToken() switch (toupper(*pos)) { - case '(': - token.type = Token::TYPE_OPEN_PAREN; - token.processedText = *pos++; - break; - - case ')': - token.type = Token::TYPE_CLOSE_PAREN; - token.processedText = *pos++; - break; - - case ',': - token.type = Token::TYPE_COMMA; - token.processedText = *pos++; - break; - case ';': + case '.': token.type = Token::TYPE_OTHER; token.processedText = *pos++; break; @@ -237,6 +223,7 @@ FrontendLexer::Token FrontendLexer::getNameToken() if (const auto optStringToken = getStringToken(); optStringToken.has_value()) return optStringToken.value(); + /*** Revert to strict parsing with schemas support branch. const auto start = pos; bool first = true; @@ -265,6 +252,30 @@ FrontendLexer::Token FrontendLexer::getNameToken() std::transform(token.processedText.begin(), token.processedText.end(), token.processedText.begin(), toupper); + return token; + ***/ + + const auto start = pos; + + switch (toupper(*pos)) + { + case ';': + token.type = Token::TYPE_OTHER; + token.processedText = *pos++; + break; + + default: + while (pos != end && !fb_utils::isspace(*pos) && *pos != '.') + ++pos; + + token.processedText = std::string(start, pos); + std::transform(token.processedText.begin(), token.processedText.end(), + token.processedText.begin(), toupper); + break; + } + + token.rawText = std::string(start, pos); + return token; } diff --git a/src/isql/FrontendLexer.h b/src/isql/FrontendLexer.h index 1357da7a14..bab64c8de3 100644 --- a/src/isql/FrontendLexer.h +++ b/src/isql/FrontendLexer.h @@ -39,9 +39,6 @@ public: TYPE_EOF, TYPE_STRING, TYPE_META_STRING, - TYPE_OPEN_PAREN, - TYPE_CLOSE_PAREN, - TYPE_COMMA, TYPE_OTHER }; diff --git a/src/isql/FrontendParser.cpp b/src/isql/FrontendParser.cpp index 46735e7350..d5d299fa2e 100644 --- a/src/isql/FrontendParser.cpp +++ b/src/isql/FrontendParser.cpp @@ -529,7 +529,7 @@ FrontendParser::AnyShowNode FrontendParser::parseShow() if (node.name) { - if (const auto token = lexer.getNameToken(); + if (const auto token = lexer.getToken(); token.type == Token::TYPE_OTHER && token.rawText == ".") { node.package = node.name; @@ -565,7 +565,7 @@ FrontendParser::AnyShowNode FrontendParser::parseShow() if (node.name) { - if (const auto token = lexer.getNameToken(); + if (const auto token = lexer.getToken(); token.type == Token::TYPE_OTHER && token.rawText == ".") { node.package = node.name;