| 1 | //===----------------------------------------------------------------------===// |
| 2 | // DuckDB |
| 3 | // |
| 4 | // postgres_parser.hpp |
| 5 | // |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include <string> |
| 12 | #include <vector> |
| 13 | #include "nodes/pg_list.hpp" |
| 14 | #include "pg_simplified_token.hpp" |
| 15 | #include "duckdb/common/vector.hpp" |
| 16 | |
| 17 | namespace duckdb { |
| 18 | class PostgresParser { |
| 19 | public: |
| 20 | PostgresParser(); |
| 21 | ~PostgresParser(); |
| 22 | |
| 23 | bool success; |
| 24 | duckdb_libpgquery::PGList *parse_tree; |
| 25 | std::string error_message; |
| 26 | int error_location; |
| 27 | public: |
| 28 | void Parse(const std::string &query); |
| 29 | static duckdb::vector<duckdb_libpgquery::PGSimplifiedToken> Tokenize(const std::string &query); |
| 30 | |
| 31 | static bool IsKeyword(const std::string &text); |
| 32 | static duckdb::vector<duckdb_libpgquery::PGKeyword> KeywordList(); |
| 33 | |
| 34 | static void SetPreserveIdentifierCase(bool downcase); |
| 35 | }; |
| 36 | |
| 37 | } |
| 38 | |