diff options
-rw-r--r-- | project2/sql/sql.ll | 123 | ||||
-rw-r--r-- | project2/sql/sqlFlexLexer.cpp | 37 | ||||
-rw-r--r-- | project2/sql/sqlFlexLexer.h | 24 |
3 files changed, 0 insertions, 184 deletions
diff --git a/project2/sql/sql.ll b/project2/sql/sql.ll deleted file mode 100644 index ab40642..0000000 --- a/project2/sql/sql.ll +++ /dev/null @@ -1,123 +0,0 @@ -%option batch -%option c++ -%option noyywrap -%option 8bit -%option stack -%option yylineno -%option yyclass="sqlFlexLexer" -%option prefix="sqlBase" - -%{ -#include <stdexcept> -#include "sqlFlexLexer.h" -#pragma GCC diagnostic ignored "-Wsign-compare" -%} - -space [ \t\n\r\f] -non_newline [^\r\n] -mcomment_start "/*" -mcomment_stop "*/" -comment ("--"{non_newline}*) -other . -term ; -any ({other}|{space}) -quote ' -quote_apos '' -dolq_start [A-Za-z\200-\377_] -dolq_cont [A-Za-z\200-\377_0-9] -dollarquote \$({dolq_start}{dolq_cont}*)?\$ - -p2mockscriptdir "$P2MOCKSCRIPTDIR" - -%x COMMENT -%x STATEMENT -%x QUOTE -%x DOLLARQUOTE - -%% -{mcomment_start} { - comment += YYText(); - yy_push_state(COMMENT); -} - -<COMMENT>{mcomment_stop} { - comment += YYText(); - Comment(comment); - comment.clear(); - yy_pop_state(); -} - -<COMMENT>{any} { - comment += YYText(); -} - -<COMMENT><<EOF>> { - throw std::runtime_error("Unterminated comment"); -} - -{comment} { - Comment(YYText()); -} - -{other} { - statement += YYText(); - yy_push_state(STATEMENT); -} - -<STATEMENT>{quote} { - statement += YYText(); - yy_push_state(QUOTE); -} - -<STATEMENT>{dollarquote} { - statement += YYText(); - yy_push_state(DOLLARQUOTE); -} - -<QUOTE>{quote} { - statement += YYText(); - yy_pop_state(); -} - -<QUOTE>{p2mockscriptdir} { - statement += MockScriptDir(); -} - -<QUOTE>{quote_apos} { - statement += YYText(); -} - -<DOLLARQUOTE>{any} { - statement += YYText(); -} - -<DOLLARQUOTE>{dollarquote} { - statement += YYText(); - yy_pop_state(); -} - -<DOLLARQUOTE><<EOF>> { - throw std::runtime_error("Unterminated dollar quoted string"); -} - -<QUOTE>{any} { - statement += YYText(); -} - -<QUOTE><<EOF>> { - throw std::runtime_error("Unterminated quoted string"); -} - -<STATEMENT>{term} { - Statement(statement); - statement.clear(); - yy_pop_state(); -} - -<STATEMENT>{any} { - statement += YYText(); -} - -<*>[ \t\r\n\f] { -} - diff --git a/project2/sql/sqlFlexLexer.cpp b/project2/sql/sqlFlexLexer.cpp deleted file mode 100644 index eaacd50..0000000 --- a/project2/sql/sqlFlexLexer.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#define yyFlexLexer sqlBaseFlexLexer -#include <FlexLexer.h> -#include "sqlFlexLexer.h" -#include <logger.h> - -sqlFlexLexer::sqlFlexLexer(const boost::filesystem::path & s, std::istream & f, DB::Connection * c) : - yyFlexLexer(&f, NULL), - conn(c), - script(s) -{ -} - -void -sqlFlexLexer::LexerError(const char * msg) -{ - throw std::runtime_error(msg); -} - -void -sqlFlexLexer::Comment(const std::string & text) -{ - Logger()->messagebf(LOG_DEBUG, "Got comment: %s", text); -} - -void -sqlFlexLexer::Statement(const std::string & text) -{ - Logger()->messagebf(LOG_DEBUG, "Got statement: %s", text); - conn->execute(text); -} - -std::string -sqlFlexLexer::MockScriptDir() const -{ - return script.string(); -} - diff --git a/project2/sql/sqlFlexLexer.h b/project2/sql/sqlFlexLexer.h deleted file mode 100644 index 55019e5..0000000 --- a/project2/sql/sqlFlexLexer.h +++ /dev/null @@ -1,24 +0,0 @@ -#include <istream> -#include <string> -#include <connection.h> -#include <boost/filesystem/path.hpp> - -class sqlFlexLexer : public yyFlexLexer { - public: - sqlFlexLexer(const boost::filesystem::path &, std::istream &, DB::Connection *); - int yylex(); - - void Comment(const std::string &); - void Statement(const std::string &); - std::string MockScriptDir() const; - - protected: - void LexerError(const char *) override; - - private: - DB::Connection * conn; - const boost::filesystem::path script; - std::string comment; - std::string statement; -}; - |