diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-12-01 01:11:27 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-12-01 01:11:27 +0000 |
commit | 559de553f4d2b73ff23c1f4c18fcfdd939b23402 (patch) | |
tree | 65c542dfb45afa236e0e6ff6ccefc3e09de1c147 | |
parent | Internalise some of the core functionality of the SQL parser (diff) | |
download | libdbpp-559de553f4d2b73ff23c1f4c18fcfdd939b23402.tar.bz2 libdbpp-559de553f4d2b73ff23c1f4c18fcfdd939b23402.tar.xz libdbpp-559de553f4d2b73ff23c1f4c18fcfdd939b23402.zip |
Pull the none lexer generated code into its own file
-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); + } + +} |