24 #include "Parser/parser.h"
28 template <
typename DDLSTMT>
29 auto parseDDL(
const std::string& stmt_type,
const std::string& stmt_str) {
30 std::list<std::unique_ptr<Parser::Stmt>> parse_trees;
31 std::string last_parsed;
33 if (parser.parse(stmt_str, parse_trees, last_parsed) > 0) {
34 throw std::runtime_error(
"Syntax error in " + stmt_type +
" \"" + stmt_str +
35 "\" at " + last_parsed);
37 if (
auto ddl_stmt = dynamic_cast<DDLSTMT*>(parse_trees.front().get())) {
38 parse_trees.front().release();
39 return std::unique_ptr<DDLSTMT>(ddl_stmt);
41 throw std::runtime_error(
"Expected " + stmt_type +
" is not found in \"" + stmt_str +
Classes representing a parse tree.
auto parseDDL(const std::string &stmt_type, const std::string &stmt_str)