aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/build.l33
-rw-r--r--src/build.y27
-rw-r--r--src/builder.cpp38
-rw-r--r--src/builder.h32
-rw-r--r--src/function.cpp9
-rw-r--r--src/function.h17
-rw-r--r--src/functioncommandtolist.cpp12
-rw-r--r--src/functioncommandtolist.h18
-rw-r--r--src/functiondirectoriesin.cpp12
-rw-r--r--src/functiondirectoriesin.h18
-rw-r--r--src/functionfactory.cpp20
-rw-r--r--src/functionfactory.h20
-rw-r--r--src/functionfilesin.cpp12
-rw-r--r--src/functionfilesin.h18
-rw-r--r--src/functionregexp.cpp12
-rw-r--r--src/functionregexp.h18
-rw-r--r--src/functiontostring.cpp12
-rw-r--r--src/functiontostring.h18
-rw-r--r--src/perform.cpp9
-rw-r--r--src/perform.h17
-rw-r--r--src/performcommand.cpp12
-rw-r--r--src/performcommand.h18
-rw-r--r--src/performfactory.cpp12
-rw-r--r--src/performfactory.h20
24 files changed, 399 insertions, 35 deletions
diff --git a/src/build.l b/src/build.l
index 8189f9d..aab7de1 100644
--- a/src/build.l
+++ b/src/build.l
@@ -7,7 +7,6 @@
7std::string strbuf; 7std::string strbuf;
8%} 8%}
9 9
10%x regexp
11%x strsq 10%x strsq
12%x strdq 11%x strdq
13%x comment 12%x comment
@@ -33,6 +32,8 @@ std::string strbuf;
33"clean" return TOK_CLEAN; 32"clean" return TOK_CLEAN;
34"target" return TOK_TARGET; 33"target" return TOK_TARGET;
35"input" return TOK_INPUT; 34"input" return TOK_INPUT;
35"filter" return TOK_FILTER;
36"prefix" return TOK_PREFIX;
36 37
37\n+ { 38\n+ {
38 yylloc->last_line += yyleng; 39 yylloc->last_line += yyleng;
@@ -45,19 +46,6 @@ std::string strbuf;
45 yylloc->first_column = yylloc->last_column+1; 46 yylloc->first_column = yylloc->last_column+1;
46} 47}
47 48
48"/" {
49 BEGIN( regexp );
50 strbuf = "";
51}
52<regexp>[^\n/\\]* strbuf += yytext;
53<regexp>"\\/" strbuf += "/";
54<regexp>"\\" strbuf += "\\";
55<regexp>"/" {
56 BEGIN( INITIAL );
57 yylval->strval = stringdup( strbuf.c_str() );
58 return REGEXP;
59}
60
61"#".* /* single line comment */ 49"#".* /* single line comment */
62 50
63[a-zA-Z][a-zA-Z0-9]* { 51[a-zA-Z][a-zA-Z0-9]* {
@@ -67,6 +55,11 @@ std::string strbuf;
67 { 55 {
68 return TARGETTYPE; 56 return TARGETTYPE;
69 } 57 }
58 else if( bld.isPerform( yytext ) )
59 {
60 yylval->strval = stringdup( yytext );
61 return PERFORM;
62 }
70 else if( bld.isFunction( yytext ) ) 63 else if( bld.isFunction( yytext ) )
71 { 64 {
72 yylval->strval = stringdup( yytext ); 65 yylval->strval = stringdup( yytext );
@@ -76,11 +69,6 @@ std::string strbuf;
76 } 69 }
77} 70}
78 71
79[^ \t\r\n\'\":=,/][^ \t\r\n\'\"=,]+[^ \t\r\n\'\":=,] {
80 yylval->strval = stringdup( yytext );
81 return STRING;
82}
83
84\" { 72\" {
85 BEGIN( strdq ); 73 BEGIN( strdq );
86 strbuf = ""; 74 strbuf = "";
@@ -103,6 +91,9 @@ std::string strbuf;
103<strdq,strsq>\\r strbuf += "\r"; 91<strdq,strsq>\\r strbuf += "\r";
104<strdq,strsq>\\b strbuf += "\b"; 92<strdq,strsq>\\b strbuf += "\b";
105<strdq,strsq>\\f strbuf += "\f"; 93<strdq,strsq>\\f strbuf += "\f";
94<strdq,strsq>\\\\ strbuf += "\\";
95<strdq,strsq>\\\" strbuf += "\"";
96<strdq,strsq>\\\' strbuf += "\'";
106 97
107<strdq>\" { 98<strdq>\" {
108 BEGIN( INITIAL ); 99 BEGIN( INITIAL );
@@ -117,7 +108,9 @@ std::string strbuf;
117} 108}
118 109
119. { 110. {
120 bld.error( yylloc, "Invalid character found!" ); 111 char buf[] = {"Character x is out of place"};
112 buf[10] = yytext[0];
113 bld.error( yylloc, "Character !" );
121} 114}
122 115
123%% 116%%
diff --git a/src/build.y b/src/build.y
index 5580299..1621dbc 100644
--- a/src/build.y
+++ b/src/build.y
@@ -20,9 +20,9 @@ void yyerror( YYLTYPE *locp, Builder &bld, char const *msg );
20} 20}
21 21
22%token <strval> STRING "string literal" 22%token <strval> STRING "string literal"
23%token <strval> REGEXP "regular expression"
24%token <tval> TARGETTYPE "target type" 23%token <tval> TARGETTYPE "target type"
25%token <strval> FUNCTION "function name" 24%token <strval> FUNCTION "function name"
25%token <strval> PERFORM "perform name"
26 26
27%token TOK_ADDSET "+=" 27%token TOK_ADDSET "+="
28%token TOK_DEFAULT "default" 28%token TOK_DEFAULT "default"
@@ -61,12 +61,11 @@ rulecmds: rulecmd
61 | rulecmds ',' rulecmd 61 | rulecmds ',' rulecmd
62 ; 62 ;
63 63
64rulecmd: TOK_MATCHES REGEXP { printf(" Matches: %s\n", $2 ); } 64rulecmd: TOK_MATCHES { printf(" Matches: " ); } func
65 | TOK_PRODUCES STRING { printf(" Produces: %s\n", $2 ); } 65 | TOK_PRODUCES STRING { printf(" Produces: %s\n", $2 ); }
66 | TOK_REQUIRES { printf(" Requires:\n"); } list {printf("\n");} 66 | TOK_REQUIRES { printf(" Requires:\n"); } list {printf("\n");}
67 | TOK_INPUT TOK_FILTER REGEXP { printf(" Input Filter: %s\n", $3 ); }
68 | TOK_INPUT TOK_FILTER { printf(" Input Filter: "); } func {printf("\n");} 67 | TOK_INPUT TOK_FILTER { printf(" Input Filter: "); } func {printf("\n");}
69 | TOK_PERFORM { printf(" Perform: "); } func {printf("\n");} 68 | TOK_PERFORM { printf(" Perform: "); } perf {printf("\n");}
70 ; 69 ;
71 70
72// Action interpretation 71// Action interpretation
@@ -78,7 +77,7 @@ actioncmds: actioncmd
78 | actioncmds ',' actioncmd 77 | actioncmds ',' actioncmd
79 ; 78 ;
80 79
81actioncmd: { printf("\t"); } actioncmdtype list {printf("\n");} 80actioncmd: { printf(" "); } actioncmdtype list {printf("\n");}
82 ; 81 ;
83 82
84actioncmdtype: TOK_CHECK { printf("check "); } 83actioncmdtype: TOK_CHECK { printf("check "); }
@@ -97,6 +96,7 @@ targetcmd: TOK_RULE STRING { printf(" Rule %s\n", $2 ); }
97 | TOK_TARGET TOK_PREFIX STRING { printf(" Target prefix: %s\n", $3 ); } 96 | TOK_TARGET TOK_PREFIX STRING { printf(" Target prefix: %s\n", $3 ); }
98 | TOK_TARGET TARGETTYPE { printf(" Target Type: %d\n", $2 ); } 97 | TOK_TARGET TARGETTYPE { printf(" Target Type: %d\n", $2 ); }
99 | TOK_INPUT { printf(" Input: "); } list { printf("\n"); } 98 | TOK_INPUT { printf(" Input: "); } list { printf("\n"); }
99 | TOK_INPUT TOK_FILTER { printf(" Input filter: "); } func
100 | TOK_REQUIRES { printf(" Requires: "); } list { printf("\n"); } 100 | TOK_REQUIRES { printf(" Requires: "); } list { printf("\n"); }
101 | TOK_SET { printf(" Set: "); } targetset 101 | TOK_SET { printf(" Set: "); } targetset
102 ; 102 ;
@@ -106,26 +106,23 @@ targetset: STRING '=' STRING { printf("%s = %s\n", $1, $3 ); }
106 ; 106 ;
107 107
108// list goo 108// list goo
109
110list: listitem listfilter 109list: listitem listfilter
111 | '[' { printf("["); } listitems ']' { printf("]"); } listfilter 110 | '[' { printf("["); } listitems ']' { printf("]"); } listfilter
112 ; 111 ;
113 112
114listfilter: 113listfilter:
115 | TOK_FILTER REGEXP 114 | TOK_FILTER { printf(" filtered by "); } func
116 | TOK_FILTER func
117 ; 115 ;
118 116
119listitems: listitem 117listitems: listitem
120 | listitems ',' {printf(", "); } listitem 118 | listitems ',' { printf(", "); } listitem
121 ; 119 ;
122 120
123listitem: STRING {printf("%s", $1 ); } 121listitem: STRING { printf("%s", $1 ); }
124 | func 122 | func
125 ; 123 ;
126 124
127// Function 125// Function
128
129func: FUNCTION { printf("%s(", $1 ); } '(' funcparams ')' { printf(")"); } 126func: FUNCTION { printf("%s(", $1 ); } '(' funcparams ')' { printf(")"); }
130 ; 127 ;
131 128
@@ -134,6 +131,14 @@ funcparams:
134 | funcparams ',' STRING { printf(", %s", $3 ); } 131 | funcparams ',' STRING { printf(", %s", $3 ); }
135 ; 132 ;
136 133
134// Perform
135perf: PERFORM { printf("%s(", $1 ); } '(' perfparams ')' { printf(")"); }
136 ;
137
138perfparams:
139 | STRING { printf("%s", $1 ); }
140 | perfparams ',' STRING { printf(", %s", $3 ); }
141 ;
137%% 142%%
138 143
139void yyerror( YYLTYPE *locp, Builder &bld, char const *msg ) 144void yyerror( YYLTYPE *locp, Builder &bld, char const *msg )
diff --git a/src/builder.cpp b/src/builder.cpp
index b6ae887..24e4536 100644
--- a/src/builder.cpp
+++ b/src/builder.cpp
@@ -1,8 +1,12 @@
1#include "builder.h" 1#include "builder.h"
2#include "functionfactory.h"
3#include "performfactory.h"
2 4
3subExceptionDef( BuildException ); 5subExceptionDef( BuildException );
4 6
5Builder::Builder() 7Builder::Builder() :
8 fFunction( FunctionFactory::getInstance() ),
9 fPerform( PerformFactory::getInstance() )
6{ 10{
7} 11}
8 12
@@ -17,7 +21,7 @@ void Builder::load( const std::string &sFile )
17{ 21{
18 file = sFile; 22 file = sFile;
19 scanBegin(); 23 scanBegin();
20 yydebug = 1; 24 //yydebug = 1;
21 yyparse( *this ); 25 yyparse( *this );
22 scanEnd(); 26 scanEnd();
23} 27}
@@ -45,8 +49,36 @@ int Builder::getTargetType( const char *sType )
45 return -1; 49 return -1;
46} 50}
47 51
52//
53// Function functions
54//
48bool Builder::isFunction( const char *sFunc ) 55bool Builder::isFunction( const char *sFunc )
49{ 56{
50 return true; 57 return fFunction.hasPlugin( sFunc );
58}
59
60void Builder::newFunctionCall( const char *sName )
61{
62
63}
64
65void Builder::addFunctionParam( const char *sParam )
66{
67}
68
69//
70// Perform functions
71//
72bool Builder::isPerform( const char *sPerf )
73{
74 return fPerform.hasPlugin( sPerf );
75}
76
77void Builder::newPerform( const char *sName )
78{
79}
80
81void Builder::addPerformParam( const char *sParam )
82{
51} 83}
52 84
diff --git a/src/builder.h b/src/builder.h
index 3293108..529edc6 100644
--- a/src/builder.h
+++ b/src/builder.h
@@ -7,6 +7,10 @@
7#include "exceptions.h" 7#include "exceptions.h"
8 8
9class Builder; 9class Builder;
10class Function;
11class FunctionFactory;
12class Perform;
13class PerformFactory;
10 14
11#define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, Builder &bld ) 15#define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, Builder &bld )
12YY_DECL; 16YY_DECL;
@@ -25,13 +29,39 @@ public:
25 void load( const std::string &sFile ); 29 void load( const std::string &sFile );
26 30
27 int getTargetType( const char *sType ); 31 int getTargetType( const char *sType );
28 bool isFunction( const char *sFunc );
29 32
30private: 33private:
31 std::string file; 34 std::string file;
32 void scanBegin(); 35 void scanBegin();
33 void scanEnd(); 36 void scanEnd();
34 37
38public: // Function functions
39 bool isFunction( const char *sFunc );
40 void newFunctionCall( const char *sName );
41 void addFunctionParam( const char *sParam );
42
43private: // Function variables
44 Function *pTmpFunc;
45 FunctionFactory &fFunction;
46
47public: // Perform functions
48 bool isPerform( const char *sPerf );
49 void newPerform( const char *sName );
50 void addPerformParam( const char *sParam );
51
52private: // Perform variables
53 Perform *pTmpPerform;
54 PerformFactory &fPerform;
55
56public: // List functions
57 void newList();
58 void addListString( const char *str );
59 void addListFunc();
60
61public: // Functions for dealing with rules
62 void addAction();
63 void addAction( const char *sName );
64 void addCommand( int nType );
35}; 65};
36 66
37#endif 67#endif
diff --git a/src/function.cpp b/src/function.cpp
new file mode 100644
index 0000000..5eeac97
--- /dev/null
+++ b/src/function.cpp
@@ -0,0 +1,9 @@
1#include "function.h"
2
3Function::Function()
4{
5}
6
7Function::~Function()
8{
9}
diff --git a/src/function.h b/src/function.h
new file mode 100644
index 0000000..44a894d
--- /dev/null
+++ b/src/function.h
@@ -0,0 +1,17 @@
1#ifndef FUNCTION_H
2#define FUNCTION_H
3
4#include <stdint.h>
5
6
7class Function
8{
9public:
10 Function();
11 virtual ~Function();
12
13private:
14
15};
16
17#endif
diff --git a/src/functioncommandtolist.cpp b/src/functioncommandtolist.cpp
new file mode 100644
index 0000000..8d18870
--- /dev/null
+++ b/src/functioncommandtolist.cpp
@@ -0,0 +1,12 @@
1#include "functioncommandtolist.h"
2#include "plugger.h"
3
4PluginInterface2(commandToList, FunctionCommandToList, Function, "Mike Buland", 0, 1 );
5
6FunctionCommandToList::FunctionCommandToList()
7{
8}
9
10FunctionCommandToList::~FunctionCommandToList()
11{
12}
diff --git a/src/functioncommandtolist.h b/src/functioncommandtolist.h
new file mode 100644
index 0000000..90b4bf3
--- /dev/null
+++ b/src/functioncommandtolist.h
@@ -0,0 +1,18 @@
1#ifndef FUNCTION_COMMAND_TO_LIST_H
2#define FUNCTION__H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionCommandToList : public Function
9{
10public:
11 FunctionCommandToList();
12 virtual ~FunctionCommandToList();
13
14private:
15
16};
17
18#endif
diff --git a/src/functiondirectoriesin.cpp b/src/functiondirectoriesin.cpp
new file mode 100644
index 0000000..f847e13
--- /dev/null
+++ b/src/functiondirectoriesin.cpp
@@ -0,0 +1,12 @@
1#include "functiondirectoriesin.h"
2#include "plugger.h"
3
4PluginInterface2(directoriesIn, FunctionDirectoriesIn, Function, "Mike Buland", 0, 1 );
5
6FunctionDirectoriesIn::FunctionDirectoriesIn()
7{
8}
9
10FunctionDirectoriesIn::~FunctionDirectoriesIn()
11{
12}
diff --git a/src/functiondirectoriesin.h b/src/functiondirectoriesin.h
new file mode 100644
index 0000000..5f6ee42
--- /dev/null
+++ b/src/functiondirectoriesin.h
@@ -0,0 +1,18 @@
1#ifndef FUNCTION_DIRECTORIES_IN_H
2#define FUNCTION_DIRECTORIES_IN_H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionDirectoriesIn : public Function
9{
10public:
11 FunctionDirectoriesIn();
12 virtual ~FunctionDirectoriesIn();
13
14private:
15
16};
17
18#endif
diff --git a/src/functionfactory.cpp b/src/functionfactory.cpp
new file mode 100644
index 0000000..b78cfcb
--- /dev/null
+++ b/src/functionfactory.cpp
@@ -0,0 +1,20 @@
1#include "functionfactory.h"
2
3extern struct PluginInfo directoriesIn;
4extern struct PluginInfo filesIn;
5extern struct PluginInfo regexp;
6extern struct PluginInfo toString;
7extern struct PluginInfo commandToList;
8
9FunctionFactory::FunctionFactory()
10{
11 registerBuiltinPlugin( &directoriesIn );
12 registerBuiltinPlugin( &filesIn );
13 registerBuiltinPlugin( &regexp );
14 registerBuiltinPlugin( &toString );
15 registerBuiltinPlugin( &commandToList );
16}
17
18FunctionFactory::~FunctionFactory()
19{
20}
diff --git a/src/functionfactory.h b/src/functionfactory.h
new file mode 100644
index 0000000..0541143
--- /dev/null
+++ b/src/functionfactory.h
@@ -0,0 +1,20 @@
1#ifndef FUNCTION_FACTORY_H
2#define FUNCTION_FACTORY_H
3
4#include <stdint.h>
5
6#include "plugger.h"
7#include "singleton.h"
8#include "function.h"
9
10class FunctionFactory : public Plugger<Function>, public Singleton<FunctionFactory>
11{
12public:
13 FunctionFactory();
14 virtual ~FunctionFactory();
15
16private:
17
18};
19
20#endif
diff --git a/src/functionfilesin.cpp b/src/functionfilesin.cpp
new file mode 100644
index 0000000..3a9d163
--- /dev/null
+++ b/src/functionfilesin.cpp
@@ -0,0 +1,12 @@
1#include "functionfilesin.h"
2#include "plugger.h"
3
4PluginInterface2(filesIn, FunctionFilesIn, Function, "Mike Buland", 0, 1 );
5
6FunctionFilesIn::FunctionFilesIn()
7{
8}
9
10FunctionFilesIn::~FunctionFilesIn()
11{
12}
diff --git a/src/functionfilesin.h b/src/functionfilesin.h
new file mode 100644
index 0000000..070f508
--- /dev/null
+++ b/src/functionfilesin.h
@@ -0,0 +1,18 @@
1#ifndef FUNCTION_FILES_IN_H
2#define FUNCTION_FILES_IN_H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionFilesIn : public Function
9{
10public:
11 FunctionFilesIn();
12 virtual ~FunctionFilesIn();
13
14private:
15
16};
17
18#endif
diff --git a/src/functionregexp.cpp b/src/functionregexp.cpp
new file mode 100644
index 0000000..fd632ae
--- /dev/null
+++ b/src/functionregexp.cpp
@@ -0,0 +1,12 @@
1#include "functionregexp.h"
2#include "plugger.h"
3
4PluginInterface2(regexp, FunctionRegexp, Function, "Mike Buland", 0, 1 );
5
6FunctionRegexp::FunctionRegexp()
7{
8}
9
10FunctionRegexp::~FunctionRegexp()
11{
12}
diff --git a/src/functionregexp.h b/src/functionregexp.h
new file mode 100644
index 0000000..0adaf97
--- /dev/null
+++ b/src/functionregexp.h
@@ -0,0 +1,18 @@
1#ifndef FUNCTION_REGEXP_H
2#define FUNCTION_REGEXP_H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionRegexp : public Function
9{
10public:
11 FunctionRegexp();
12 virtual ~FunctionRegexp();
13
14private:
15
16};
17
18#endif
diff --git a/src/functiontostring.cpp b/src/functiontostring.cpp
new file mode 100644
index 0000000..93a8b56
--- /dev/null
+++ b/src/functiontostring.cpp
@@ -0,0 +1,12 @@
1#include "functiontostring.h"
2#include "plugger.h"
3
4PluginInterface2(toString, FunctionToString, Function, "Mike Buland", 0, 1 );
5
6FunctionToString::FunctionToString()
7{
8}
9
10FunctionToString::~FunctionToString()
11{
12}
diff --git a/src/functiontostring.h b/src/functiontostring.h
new file mode 100644
index 0000000..08baadd
--- /dev/null
+++ b/src/functiontostring.h
@@ -0,0 +1,18 @@
1#ifndef FUNCTION_TO_STRING_H
2#define FUNCTION_TO_STRING_H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionToString : public Function
9{
10public:
11 FunctionToString();
12 virtual ~FunctionToString();
13
14private:
15
16};
17
18#endif
diff --git a/src/perform.cpp b/src/perform.cpp
new file mode 100644
index 0000000..937a76c
--- /dev/null
+++ b/src/perform.cpp
@@ -0,0 +1,9 @@
1#include "perform.h"
2
3Perform::Perform()
4{
5}
6
7Perform::~Perform()
8{
9}
diff --git a/src/perform.h b/src/perform.h
new file mode 100644
index 0000000..0b6a16d
--- /dev/null
+++ b/src/perform.h
@@ -0,0 +1,17 @@
1#ifndef PERFORM_H
2#define PERFORM_H
3
4#include <stdint.h>
5
6
7class Perform
8{
9public:
10 Perform();
11 virtual ~Perform();
12
13private:
14
15};
16
17#endif
diff --git a/src/performcommand.cpp b/src/performcommand.cpp
new file mode 100644
index 0000000..7c7dd42
--- /dev/null
+++ b/src/performcommand.cpp
@@ -0,0 +1,12 @@
1#include "performcommand.h"
2#include "plugger.h"
3
4PluginInterface2(command, PerformCommand, Perform, "Mike Buland", 0, 1 );
5
6PerformCommand::PerformCommand()
7{
8}
9
10PerformCommand::~PerformCommand()
11{
12}
diff --git a/src/performcommand.h b/src/performcommand.h
new file mode 100644
index 0000000..219ae28
--- /dev/null
+++ b/src/performcommand.h
@@ -0,0 +1,18 @@
1#ifndef PERFORM_COMMAND_H
2#define PERFORM_COMMAND_H
3
4#include <stdint.h>
5
6#include "perform.h"
7
8class PerformCommand : public Perform
9{
10public:
11 PerformCommand();
12 virtual ~PerformCommand();
13
14private:
15
16};
17
18#endif
diff --git a/src/performfactory.cpp b/src/performfactory.cpp
new file mode 100644
index 0000000..6c7d57a
--- /dev/null
+++ b/src/performfactory.cpp
@@ -0,0 +1,12 @@
1#include "performfactory.h"
2
3extern struct PluginInfo command;
4
5PerformFactory::PerformFactory()
6{
7 registerBuiltinPlugin( &command );
8}
9
10PerformFactory::~PerformFactory()
11{
12}
diff --git a/src/performfactory.h b/src/performfactory.h
new file mode 100644
index 0000000..f5ce5c0
--- /dev/null
+++ b/src/performfactory.h
@@ -0,0 +1,20 @@
1#ifndef PERFORM_FACTORY_H
2#define PERFORM_FACTORY_H
3
4#include <stdint.h>
5
6#include "perform.h"
7#include "plugger.h"
8#include "singleton.h"
9
10class PerformFactory : public Plugger<Perform>, public Singleton<PerformFactory>
11{
12public:
13 PerformFactory();
14 virtual ~PerformFactory();
15
16private:
17
18};
19
20#endif