Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Lin Zhihao <[email protected]>
  • Loading branch information
gibber9809 and LinZhihao-723 authored Oct 22, 2024
1 parent d09e6c4 commit 991ca73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions components/core/src/clp_s/search/sql/sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ auto parse_sql_expression(std::istream& in) -> std::shared_ptr<Expression> {
ErrorListener parser_error_listener;

ANTLRInputStream input{in};
SqlLexer lexer(&input);
SqlLexer lexer{&input};
lexer.removeErrorListeners();
lexer.addErrorListener(&lexer_error_listener);
CommonTokenStream tokens(&lexer);
CommonTokenStream tokens{&lexer};
SqlParser parser(&tokens);
parser.removeErrorListeners();
parser.addErrorListener(&parser_error_listener);
SqlParser::StartContext* tree = parser.start();
SqlParser::StartContext* tree{parser.start()};

if (lexer_error_listener.error()) {
SPDLOG_ERROR("Lexer error: {}", lexer_error_listener.message());
return nullptr;
}
if (parser_error_listener.error()) {
SPDLOG_ERROR("Parser error: {}", parser_error_listener.message());
return {};
return nullptr;
}

ParseTreeVisitor visitor;
Expand Down
5 changes: 2 additions & 3 deletions components/core/tests/test-sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <sstream>

#include <Catch2/single_include/catch2/catch.hpp>
#include <spdlog/spdlog.h>

#include "../src/clp_s/search/EmptyExpr.hpp"
#include "../src/clp_s/search/sql/sql.hpp"
Expand All @@ -14,11 +13,11 @@ using std::stringstream;

TEST_CASE("Test parsing SQL", "[SQL]") {
// Suppress logging
LogSuppressor suppressor{};
LogSuppressor const suppressor;

SECTION("Stub accepts empty string") {
stringstream empty_string{""};
auto filter = std::dynamic_pointer_cast<EmptyExpr>(parse_sql_expression(empty_string));
REQUIRE(nullptr != filter);
REQUIRE((nullptr != filter));
}
}

0 comments on commit 991ca73

Please sign in to comment.