diff options
-rw-r--r-- | libdbpp/sqlParse.ll | 54 | ||||
-rw-r--r-- | libdbpp/sqlParseImpl.cpp | 53 |
2 files changed, 53 insertions, 54 deletions
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 <stdexcept> -#include <compileTimeFormatter.h> #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 <stdexcept> +#include <compileTimeFormatter.h> +#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); + } + +} |