diff --git a/include/cql2cpp/cql2_parser.h b/include/cql2cpp/cql2_parser.h deleted file mode 100644 index 61c51ab..0000000 --- a/include/cql2cpp/cql2_parser.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * File Name: cql2_parser.h - * - * Copyright (c) 2024 IndoorSpatial - * - * Author: Kunlin Yu - * Create Date: 2024/12/19 - * - */ - -#pragma once - -#include -#include - -#include - -class Cql2Parser : public cql2cpp::Cql2ParserBase { - private: - cql2cpp::AstNodePtr root_; - - public: - Cql2Parser() : cql2cpp::Cql2ParserBase(&root_) {} - - void error(const std::string& msg) override { - LOG(ERROR) << "Cql2Parser Error: " << msg << std::endl; - } - - cql2cpp::AstNodePtr root() const { return root_; } -}; diff --git a/include/cql2cpp/cql2_parser_json.h b/include/cql2cpp/cql2_parser_json.h new file mode 100644 index 0000000..f990dc1 --- /dev/null +++ b/include/cql2cpp/cql2_parser_json.h @@ -0,0 +1,29 @@ +/* + * File Name: cql2_parser_json.h + * + * Copyright (c) 2024 IndoorSpatial + * + * Author: Kunlin Yu + * Create Date: 2024/12/19 + * + */ + +#pragma once + +#include "ast_node.h" + +namespace cql2cpp { + +class Cql2ParserJson { + private: + AstNodePtr root_; + + public: + Cql2ParserJson() {} + + bool parse() { return true; } + + AstNodePtr root() const { return root_; } +}; + +} // namespace cql2cpp diff --git a/include/cql2cpp/cql2_parser_text.h b/include/cql2cpp/cql2_parser_text.h new file mode 100644 index 0000000..3fc9687 --- /dev/null +++ b/include/cql2cpp/cql2_parser_text.h @@ -0,0 +1,36 @@ +/* + * File Name: cql2_parser_text.h + * + * Copyright (c) 2024 IndoorSpatial + * + * Author: Kunlin Yu + * Create Date: 2024/12/19 + * + */ + +#pragma once + +#include +#include + +#include + +namespace cql2cpp { + +class Cql2ParserText : public Cql2ParserBase { + private: + AstNodePtr root_; + + public: + Cql2ParserText() : Cql2ParserBase(&root_) {} + + void error(const std::string& msg) override { + LOG(ERROR) << "Cql2ParserText Error: " << msg << std::endl; + } + + int parse() override { return Cql2ParserBase::parse(); } + + AstNodePtr root() const { return root_; } +}; + +} // namespace cql2cpp diff --git a/include/cql2cpp/cql2cpp.h b/include/cql2cpp/cql2cpp.h index 3524dd9..fa43703 100644 --- a/include/cql2cpp/cql2cpp.h +++ b/include/cql2cpp/cql2cpp.h @@ -17,7 +17,7 @@ #include "ast_node.h" #include "cql2_lexer.h" -#include "cql2_parser.h" +#include "cql2_parser_text.h" #include "evaluator.h" #include "feature_source.h" #include "global_yylex.h" @@ -60,7 +60,7 @@ class Cql2Cpp { if (not Parse(cql2_query, &root, &error_msg_)) return false; // Prepare evaluator - cql2cpp::ValueT value; + ValueT value; // Loop over all features for (const auto& [fs, f] : feature_source_2_type_) { @@ -87,13 +87,13 @@ class Cql2Cpp { if (not Parse(cql2_query, &root, error_msg)) return false; // Evaluate - cql2cpp::ValueT value; + ValueT value; if (evaluator_.Evaluate(root, &fs, &value) && std::holds_alternative(value)) { *result = std::get(value); if (dot != nullptr) { std::stringstream ss; - cql2cpp::Tree2Dot::GenerateDot(ss, root); + Tree2Dot::GenerateDot(ss, root); *dot = ss.str(); } return true; @@ -111,7 +111,7 @@ class Cql2Cpp { // to dot std::stringstream ss; - cql2cpp::Tree2Dot::GenerateDot(ss, root); + Tree2Dot::GenerateDot(ss, root); *dot = ss.str(); return true; @@ -129,7 +129,7 @@ class Cql2Cpp { cql2cpp::AstNode::set_ostream(&oss); - Cql2Parser parser; + Cql2ParserText parser; int ret = parser.parse(); if (error_msg != nullptr) *error_msg = oss.str(); if (ret == 0) {