summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-05-31 23:24:40 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-05-31 23:24:40 +0100
commit70297cec8122c0a0a7957664b60129e6809d57b6 (patch)
treeaa768cf8f752002b4d8ebd03cf8efa6cea23ba09
parentParse .p2 config files with flex (diff)
downloadproject2-70297cec8122c0a0a7957664b60129e6809d57b6.tar.bz2
project2-70297cec8122c0a0a7957664b60129e6809d57b6.tar.xz
project2-70297cec8122c0a0a7957664b60129e6809d57b6.zip
Add some experience to the flex, prefixes
-rw-r--r--project2/files/configFlexLexer.cpp8
-rw-r--r--project2/files/configFlexLexer.h1
-rw-r--r--project2/files/configuration.ll12
-rw-r--r--project2/files/optionsSource.cpp1
-rw-r--r--project2/sql/sql.ll10
-rw-r--r--project2/sql/sqlFlexLexer.cpp4
-rw-r--r--project2/sql/sqlFlexLexer.h4
7 files changed, 29 insertions, 11 deletions
diff --git a/project2/files/configFlexLexer.cpp b/project2/files/configFlexLexer.cpp
index fe44b0c..6d6f700 100644
--- a/project2/files/configFlexLexer.cpp
+++ b/project2/files/configFlexLexer.cpp
@@ -1,4 +1,5 @@
-#include "FlexLexer.h"
+#define yyFlexLexer configBaseFlexLexer
+#include <FlexLexer.h>
#include "configFlexLexer.h"
#include <stdexcept>
@@ -16,11 +17,6 @@ configFlexLexer::process() const
}
void
-configFlexLexer::LexerOutput(const char *, int)
-{
-}
-
-void
configFlexLexer::LexerError(const char * msg)
{
throw std::runtime_error(msg);
diff --git a/project2/files/configFlexLexer.h b/project2/files/configFlexLexer.h
index 177f11c..180c1fa 100644
--- a/project2/files/configFlexLexer.h
+++ b/project2/files/configFlexLexer.h
@@ -9,7 +9,6 @@ class configFlexLexer : public yyFlexLexer {
configFlexLexer(std::istream & in, const ConfigConsumer & consume, const Options::CurrentPlatform &);
int yylex();
- void LexerOutput(const char *, int) override;
void LexerError(const char * msg) override;
private:
diff --git a/project2/files/configuration.ll b/project2/files/configuration.ll
index b3c8de7..aa04456 100644
--- a/project2/files/configuration.ll
+++ b/project2/files/configuration.ll
@@ -1,10 +1,15 @@
%option batch
%option c++
%option noyywrap
+%option 8bit
+%option stack
+%option yylineno
%option yyclass="configFlexLexer"
+%option prefix="configBase"
%{
#include "configFlexLexer.h"
+#pragma GCC diagnostic ignored "-Wsign-compare"
%}
element [a-zA-Z][a-zA-Z0-9_-]*
@@ -62,3 +67,10 @@ value [^ ][^\r\n]*
BEGIN(INITIAL);
}
+<*>[ \t\r\n\f] {
+}
+
+<*>. {
+ throw std::runtime_error("Unexpected input");
+}
+
diff --git a/project2/files/optionsSource.cpp b/project2/files/optionsSource.cpp
index 2ebebdb..8e98df0 100644
--- a/project2/files/optionsSource.cpp
+++ b/project2/files/optionsSource.cpp
@@ -1,6 +1,7 @@
#include <pch.hpp>
#include <boost/filesystem/convenience.hpp>
#include "optionsSource.h"
+#define yyFlexLexer configBaseFlexLexer
#include <FlexLexer.h>
#include "configFlexLexer.h"
#include <boost/shared_ptr.hpp>
diff --git a/project2/sql/sql.ll b/project2/sql/sql.ll
index 604a53d..ab40642 100644
--- a/project2/sql/sql.ll
+++ b/project2/sql/sql.ll
@@ -1,13 +1,16 @@
%option batch
%option c++
%option noyywrap
+%option 8bit
+%option stack
+%option yylineno
%option yyclass="sqlFlexLexer"
+%option prefix="sqlBase"
%{
#include <stdexcept>
#include "sqlFlexLexer.h"
-std::string comment;
-std::string statement;
+#pragma GCC diagnostic ignored "-Wsign-compare"
%}
space [ \t\n\r\f]
@@ -115,3 +118,6 @@ p2mockscriptdir "$P2MOCKSCRIPTDIR"
statement += YYText();
}
+<*>[ \t\r\n\f] {
+}
+
diff --git a/project2/sql/sqlFlexLexer.cpp b/project2/sql/sqlFlexLexer.cpp
index cbf2416..eaacd50 100644
--- a/project2/sql/sqlFlexLexer.cpp
+++ b/project2/sql/sqlFlexLexer.cpp
@@ -1,3 +1,4 @@
+#define yyFlexLexer sqlBaseFlexLexer
#include <FlexLexer.h>
#include "sqlFlexLexer.h"
#include <logger.h>
@@ -10,8 +11,9 @@ sqlFlexLexer::sqlFlexLexer(const boost::filesystem::path & s, std::istream & f,
}
void
-sqlFlexLexer::LexerOutput(const char *, int)
+sqlFlexLexer::LexerError(const char * msg)
{
+ throw std::runtime_error(msg);
}
void
diff --git a/project2/sql/sqlFlexLexer.h b/project2/sql/sqlFlexLexer.h
index fbaf799..55019e5 100644
--- a/project2/sql/sqlFlexLexer.h
+++ b/project2/sql/sqlFlexLexer.h
@@ -13,10 +13,12 @@ class sqlFlexLexer : public yyFlexLexer {
std::string MockScriptDir() const;
protected:
- void LexerOutput(const char *, int) override;
+ void LexerError(const char *) override;
private:
DB::Connection * conn;
const boost::filesystem::path script;
+ std::string comment;
+ std::string statement;
};