aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/build.l4
-rw-r--r--src/build.y18
-rw-r--r--src/builder.cpp13
-rw-r--r--src/builder.h10
-rw-r--r--src/target.cpp9
-rw-r--r--src/target.h17
-rw-r--r--src/targetfactory.cpp12
-rw-r--r--src/targetfactory.h20
-rw-r--r--src/targetfile.cpp12
-rw-r--r--src/targetfile.h18
10 files changed, 120 insertions, 13 deletions
diff --git a/src/build.l b/src/build.l
index 20253bc..3e95132 100644
--- a/src/build.l
+++ b/src/build.l
@@ -50,9 +50,9 @@ std::string strbuf;
50 50
51[a-zA-Z][a-zA-Z0-9]* { 51[a-zA-Z][a-zA-Z0-9]* {
52 { 52 {
53 yylval->tval = bld.getTargetType( yytext ); 53 if( bld.isTarget( yytext ) )
54 if( yylval->tval >= 0 )
55 { 54 {
55 yylval->strval = stringdup( yytext );
56 return TARGETTYPE; 56 return TARGETTYPE;
57 } 57 }
58 else if( bld.isPerform( yytext ) ) 58 else if( bld.isPerform( yytext ) )
diff --git a/src/build.y b/src/build.y
index 1621dbc..1424867 100644
--- a/src/build.y
+++ b/src/build.y
@@ -16,11 +16,10 @@ void yyerror( YYLTYPE *locp, Builder &bld, char const *msg );
16%error-verbose 16%error-verbose
17%union { 17%union {
18 char *strval; 18 char *strval;
19 int tval;
20} 19}
21 20
22%token <strval> STRING "string literal" 21%token <strval> STRING "string literal"
23%token <tval> TARGETTYPE "target type" 22%token <strval> TARGETTYPE "target type"
24%token <strval> FUNCTION "function name" 23%token <strval> FUNCTION "function name"
25%token <strval> PERFORM "perform name" 24%token <strval> PERFORM "perform name"
26 25
@@ -51,6 +50,7 @@ input:
51 | input rule 50 | input rule
52 | input action 51 | input action
53 | input target 52 | input target
53 | input set
54 ; 54 ;
55 55
56// Rule interpretation 56// Rule interpretation
@@ -61,7 +61,7 @@ rulecmds: rulecmd
61 | rulecmds ',' rulecmd 61 | rulecmds ',' rulecmd
62 ; 62 ;
63 63
64rulecmd: TOK_MATCHES { printf(" Matches: " ); } func 64rulecmd: TOK_MATCHES { printf(" Matches: " ); } func { printf("\n"); }
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 { printf(" Input Filter: "); } func {printf("\n");} 67 | TOK_INPUT TOK_FILTER { printf(" Input Filter: "); } func {printf("\n");}
@@ -94,9 +94,9 @@ targetcmds: targetcmd
94 94
95targetcmd: TOK_RULE STRING { printf(" Rule %s\n", $2 ); } 95targetcmd: TOK_RULE STRING { printf(" Rule %s\n", $2 ); }
96 | TOK_TARGET TOK_PREFIX STRING { printf(" Target prefix: %s\n", $3 ); } 96 | TOK_TARGET TOK_PREFIX STRING { printf(" Target prefix: %s\n", $3 ); }
97 | TOK_TARGET TARGETTYPE { printf(" Target Type: %d\n", $2 ); } 97 | TOK_TARGET TARGETTYPE { printf(" Target Type: %s\n", $2 ); }
98 | TOK_INPUT { printf(" Input: "); } list { printf("\n"); } 98 | TOK_INPUT { printf(" Input: "); } list { printf("\n"); }
99 | TOK_INPUT TOK_FILTER { printf(" Input filter: "); } func 99 | TOK_INPUT TOK_FILTER { printf(" Input filter: "); } func { printf("\n"); }
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 ;
@@ -105,6 +105,14 @@ targetset: STRING '=' STRING { printf("%s = %s\n", $1, $3 ); }
105 | STRING TOK_ADDSET STRING { printf("%s += %s\n", $1, $3 ); } 105 | STRING TOK_ADDSET STRING { printf("%s += %s\n", $1, $3 ); }
106 ; 106 ;
107 107
108// global set
109set: TOK_SET { printf("Set: "); } setwhat
110 ;
111
112setwhat: STRING '=' STRING { printf("%s = %s\n", $1, $3 ); }
113 | STRING TOK_ADDSET STRING { printf("%s += %s\n", $1, $3 ); }
114 ;
115
108// list goo 116// list goo
109list: listitem listfilter 117list: listitem listfilter
110 | '[' { printf("["); } listitems ']' { printf("]"); } listfilter 118 | '[' { printf("["); } listitems ']' { printf("]"); } listfilter
diff --git a/src/builder.cpp b/src/builder.cpp
index 24e4536..e8cd6e2 100644
--- a/src/builder.cpp
+++ b/src/builder.cpp
@@ -1,12 +1,14 @@
1#include "builder.h" 1#include "builder.h"
2#include "functionfactory.h" 2#include "functionfactory.h"
3#include "performfactory.h" 3#include "performfactory.h"
4#include "targetfactory.h"
4 5
5subExceptionDef( BuildException ); 6subExceptionDef( BuildException );
6 7
7Builder::Builder() : 8Builder::Builder() :
8 fFunction( FunctionFactory::getInstance() ), 9 fFunction( FunctionFactory::getInstance() ),
9 fPerform( PerformFactory::getInstance() ) 10 fPerform( PerformFactory::getInstance() ),
11 fTarget( TargetFactory::getInstance() )
10{ 12{
11} 13}
12 14
@@ -42,11 +44,12 @@ void Builder::error( const std::string &msg )
42 throw BuildException("%s", msg.c_str() ); 44 throw BuildException("%s", msg.c_str() );
43} 45}
44 46
45int Builder::getTargetType( const char *sType ) 47//
48// Target functions
49//
50bool Builder::isTarget( const char *sType )
46{ 51{
47 if( !strcmp( sType, "file" ) ) 52 return fTarget.hasPlugin( sType );
48 return 0;
49 return -1;
50} 53}
51 54
52// 55//
diff --git a/src/builder.h b/src/builder.h
index 529edc6..a6f88f4 100644
--- a/src/builder.h
+++ b/src/builder.h
@@ -11,6 +11,8 @@ class Function;
11class FunctionFactory; 11class FunctionFactory;
12class Perform; 12class Perform;
13class PerformFactory; 13class PerformFactory;
14class Target;
15class TargetFactory;
14 16
15#define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, Builder &bld ) 17#define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, Builder &bld )
16YY_DECL; 18YY_DECL;
@@ -28,13 +30,19 @@ public:
28 30
29 void load( const std::string &sFile ); 31 void load( const std::string &sFile );
30 32
31 int getTargetType( const char *sType );
32 33
33private: 34private:
34 std::string file; 35 std::string file;
35 void scanBegin(); 36 void scanBegin();
36 void scanEnd(); 37 void scanEnd();
37 38
39public: // Target functions
40 bool isTarget( const char *sType );
41
42private: // Target variables
43 Target *pTmpTarget;
44 TargetFactory &fTarget;
45
38public: // Function functions 46public: // Function functions
39 bool isFunction( const char *sFunc ); 47 bool isFunction( const char *sFunc );
40 void newFunctionCall( const char *sName ); 48 void newFunctionCall( const char *sName );
diff --git a/src/target.cpp b/src/target.cpp
new file mode 100644
index 0000000..f22bc54
--- /dev/null
+++ b/src/target.cpp
@@ -0,0 +1,9 @@
1#include "target.h"
2
3Target::Target()
4{
5}
6
7Target::~Target()
8{
9}
diff --git a/src/target.h b/src/target.h
new file mode 100644
index 0000000..b7bee83
--- /dev/null
+++ b/src/target.h
@@ -0,0 +1,17 @@
1#ifndef TARGET_H
2#define TARGET_H
3
4#include <stdint.h>
5
6
7class Target
8{
9public:
10 Target();
11 virtual ~Target();
12
13private:
14
15};
16
17#endif
diff --git a/src/targetfactory.cpp b/src/targetfactory.cpp
new file mode 100644
index 0000000..ad7d090
--- /dev/null
+++ b/src/targetfactory.cpp
@@ -0,0 +1,12 @@
1#include "targetfactory.h"
2
3extern struct PluginInfo file;
4
5TargetFactory::TargetFactory()
6{
7 registerBuiltinPlugin( &file );
8}
9
10TargetFactory::~TargetFactory()
11{
12}
diff --git a/src/targetfactory.h b/src/targetfactory.h
new file mode 100644
index 0000000..bf8862f
--- /dev/null
+++ b/src/targetfactory.h
@@ -0,0 +1,20 @@
1#ifndef TARGET_FACTORY_H
2#define TARGET_FACTORY_H
3
4#include <stdint.h>
5
6#include "plugger.h"
7#include "singleton.h"
8#include "target.h"
9
10class TargetFactory : public Plugger<Target>, public Singleton<TargetFactory>
11{
12public:
13 TargetFactory();
14 virtual ~TargetFactory();
15
16private:
17
18};
19
20#endif
diff --git a/src/targetfile.cpp b/src/targetfile.cpp
new file mode 100644
index 0000000..fee41c9
--- /dev/null
+++ b/src/targetfile.cpp
@@ -0,0 +1,12 @@
1#include "targetfile.h"
2#include "plugger.h"
3
4PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 );
5
6TargetFile::TargetFile()
7{
8}
9
10TargetFile::~TargetFile()
11{
12}
diff --git a/src/targetfile.h b/src/targetfile.h
new file mode 100644
index 0000000..28fc2b1
--- /dev/null
+++ b/src/targetfile.h
@@ -0,0 +1,18 @@
1#ifndef TARGET_FILE_H
2#define TARGET_FILE_H
3
4#include <stdint.h>
5
6#include "target.h"
7
8class TargetFile : public Target
9{
10public:
11 TargetFile();
12 virtual ~TargetFile();
13
14private:
15
16};
17
18#endif