From 559de553f4d2b73ff23c1f4c18fcfdd939b23402 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 1 Dec 2017 01:11:27 +0000 Subject: Pull the none lexer generated code into its own file --- libdbpp/sqlParse.ll | 54 ------------------------------------------------ libdbpp/sqlParseImpl.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 54 deletions(-) create mode 100644 libdbpp/sqlParseImpl.cpp diff --git a/libdbpp/sqlParse.ll b/libdbpp/sqlParse.ll index 18210ac..f9c1525 100644 --- a/libdbpp/sqlParse.ll +++ b/libdbpp/sqlParse.ll @@ -8,8 +8,6 @@ %option prefix="sqlBase" %{ -#include -#include #include "sqlParse.h" #pragma GCC diagnostic ignored "-Wsign-compare" %} @@ -131,55 +129,3 @@ scriptdir "$SCRIPTDIR" <*>[ \t\r\n\f] { } -%% - -namespace DB { - SqlParseException::SqlParseException(const char * r, unsigned int l) : reason(r), line(l) { } - - AdHocFormatter(SqlParseExceptionMsg, "Error parsing SQL script: %? at line %?"); - std::string - SqlParseException::message() const throw() - { - return SqlParseExceptionMsg::get(reason, line); - } - - SqlParse::SqlParse(std::istream & f, const boost::filesystem::path & s) : - yyFlexLexer(&f, NULL), - scriptDir(s) - { - if (!f.good()) { - throw SqlParseException("Script stream not in good state.", 0); - } - } - - void - SqlParse::Execute() - { - while (yylex()) ; - } - - void - SqlParse::LexerError(const char * msg) - { - throw std::runtime_error(msg); - } - - SqlExecuteScript::SqlExecuteScript(std::istream & f, const boost::filesystem::path & s, DB::Connection * c) : - SqlParse(f, s), - conn(c) - { - } - - void - SqlExecuteScript::Comment(const std::string &) const - { - } - - void - SqlExecuteScript::Statement(const std::string & text) const - { - conn->execute(text); - } - -} - diff --git a/libdbpp/sqlParseImpl.cpp b/libdbpp/sqlParseImpl.cpp new file mode 100644 index 0000000..57c4248 --- /dev/null +++ b/libdbpp/sqlParseImpl.cpp @@ -0,0 +1,53 @@ +#include +#include +#include "sqlParse.h" + +namespace DB { + SqlParseException::SqlParseException(const char * r, unsigned int l) : reason(r), line(l) { } + + AdHocFormatter(SqlParseExceptionMsg, "Error parsing SQL script: %? at line %?"); + std::string + SqlParseException::message() const throw() + { + return SqlParseExceptionMsg::get(reason, line); + } + + SqlParse::SqlParse(std::istream & f, const boost::filesystem::path & s) : + yyFlexLexer(&f, NULL), + scriptDir(s) + { + if (!f.good()) { + throw SqlParseException("Script stream not in good state.", 0); + } + } + + void + SqlParse::Execute() + { + while (yylex()) ; + } + + void + SqlParse::LexerError(const char * msg) + { + throw std::runtime_error(msg); + } + + SqlExecuteScript::SqlExecuteScript(std::istream & f, const boost::filesystem::path & s, DB::Connection * c) : + SqlParse(f, s), + conn(c) + { + } + + void + SqlExecuteScript::Comment(const std::string &) const + { + } + + void + SqlExecuteScript::Statement(const std::string & text) const + { + conn->execute(text); + } + +} -- cgit v1.2.3