From 50f3ffbe52144c71ccd7e855bbe8d119c05d97dd Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Tue, 18 Jun 2024 17:48:05 +0300 Subject: [PATCH] chore(search): improve parser error reporting (#3184) Signed-off-by: Roman Gershman --- src/core/search/parser.y | 2 +- src/core/search/query_driver.cc | 4 ++++ src/core/search/query_driver.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/search/parser.y b/src/core/search/parser.y index 906312ab8d98..961fc76fed16 100644 --- a/src/core/search/parser.y +++ b/src/core/search/parser.y @@ -174,5 +174,5 @@ tag_list: void dfly::search::Parser::error(const location_type& l, const string& m) { - cerr << l << ": " << m << '\n'; + driver->Error(l, m); } diff --git a/src/core/search/query_driver.cc b/src/core/search/query_driver.cc index 03904e2bd5ad..2422be10e3b1 100644 --- a/src/core/search/query_driver.cc +++ b/src/core/search/query_driver.cc @@ -18,6 +18,10 @@ void QueryDriver::ResetScanner() { scanner_->SetParams(params_); } +void QueryDriver::Error(const Parser::location_type& loc, std::string_view msg) { + LOG(ERROR) << "Parse error " << loc << ": " << msg; +} + } // namespace search } // namespace dfly diff --git a/src/core/search/query_driver.h b/src/core/search/query_driver.h index bef9ded96d7c..ca5401868a42 100644 --- a/src/core/search/query_driver.h +++ b/src/core/search/query_driver.h @@ -52,6 +52,8 @@ class QueryDriver { return scanner_.get(); } + void Error(const Parser::location_type& loc, std::string_view msg); + public: Parser::location_type location;