diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-08-22 06:19:44 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-08-22 06:19:44 +0000 |
commit | ee98faf71642cf351d5cda241679b094aeec65ce (patch) | |
tree | 881b7a8b71fc9b9a21e6bca05da6f731ae1a2d64 /src | |
parent | 8829c8548ea26abaf2e7d2f1d85e0b99757f1978 (diff) | |
download | build-ee98faf71642cf351d5cda241679b094aeec65ce.tar.gz build-ee98faf71642cf351d5cda241679b094aeec65ce.tar.bz2 build-ee98faf71642cf351d5cda241679b094aeec65ce.tar.xz build-ee98faf71642cf351d5cda241679b094aeec65ce.zip |
Added targets, and the global set command, things are really coming along now.
Diffstat (limited to 'src')
-rw-r--r-- | src/build.l | 4 | ||||
-rw-r--r-- | src/build.y | 18 | ||||
-rw-r--r-- | src/builder.cpp | 13 | ||||
-rw-r--r-- | src/builder.h | 10 | ||||
-rw-r--r-- | src/target.cpp | 9 | ||||
-rw-r--r-- | src/target.h | 17 | ||||
-rw-r--r-- | src/targetfactory.cpp | 12 | ||||
-rw-r--r-- | src/targetfactory.h | 20 | ||||
-rw-r--r-- | src/targetfile.cpp | 12 | ||||
-rw-r--r-- | src/targetfile.h | 18 |
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 | ||
64 | rulecmd: TOK_MATCHES { printf(" Matches: " ); } func | 64 | rulecmd: 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 | ||
95 | targetcmd: TOK_RULE STRING { printf(" Rule %s\n", $2 ); } | 95 | targetcmd: 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 | ||
109 | set: TOK_SET { printf("Set: "); } setwhat | ||
110 | ; | ||
111 | |||
112 | setwhat: 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 |
109 | list: listitem listfilter | 117 | list: 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 | ||
5 | subExceptionDef( BuildException ); | 6 | subExceptionDef( BuildException ); |
6 | 7 | ||
7 | Builder::Builder() : | 8 | Builder::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 | ||
45 | int Builder::getTargetType( const char *sType ) | 47 | // |
48 | // Target functions | ||
49 | // | ||
50 | bool 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; | |||
11 | class FunctionFactory; | 11 | class FunctionFactory; |
12 | class Perform; | 12 | class Perform; |
13 | class PerformFactory; | 13 | class PerformFactory; |
14 | class Target; | ||
15 | class 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 ) |
16 | YY_DECL; | 18 | YY_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 | ||
33 | private: | 34 | private: |
34 | std::string file; | 35 | std::string file; |
35 | void scanBegin(); | 36 | void scanBegin(); |
36 | void scanEnd(); | 37 | void scanEnd(); |
37 | 38 | ||
39 | public: // Target functions | ||
40 | bool isTarget( const char *sType ); | ||
41 | |||
42 | private: // Target variables | ||
43 | Target *pTmpTarget; | ||
44 | TargetFactory &fTarget; | ||
45 | |||
38 | public: // Function functions | 46 | public: // 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 | |||
3 | Target::Target() | ||
4 | { | ||
5 | } | ||
6 | |||
7 | Target::~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 | |||
7 | class Target | ||
8 | { | ||
9 | public: | ||
10 | Target(); | ||
11 | virtual ~Target(); | ||
12 | |||
13 | private: | ||
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 | |||
3 | extern struct PluginInfo file; | ||
4 | |||
5 | TargetFactory::TargetFactory() | ||
6 | { | ||
7 | registerBuiltinPlugin( &file ); | ||
8 | } | ||
9 | |||
10 | TargetFactory::~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 | |||
10 | class TargetFactory : public Plugger<Target>, public Singleton<TargetFactory> | ||
11 | { | ||
12 | public: | ||
13 | TargetFactory(); | ||
14 | virtual ~TargetFactory(); | ||
15 | |||
16 | private: | ||
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 | |||
4 | PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 ); | ||
5 | |||
6 | TargetFile::TargetFile() | ||
7 | { | ||
8 | } | ||
9 | |||
10 | TargetFile::~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 | |||
8 | class TargetFile : public Target | ||
9 | { | ||
10 | public: | ||
11 | TargetFile(); | ||
12 | virtual ~TargetFile(); | ||
13 | |||
14 | private: | ||
15 | |||
16 | }; | ||
17 | |||
18 | #endif | ||