From ee98faf71642cf351d5cda241679b094aeec65ce Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 22 Aug 2006 06:19:44 +0000 Subject: Added targets, and the global set command, things are really coming along now. --- src/build.l | 4 ++-- src/build.y | 18 +++++++++++++----- src/builder.cpp | 13 ++++++++----- src/builder.h | 10 +++++++++- src/target.cpp | 9 +++++++++ src/target.h | 17 +++++++++++++++++ src/targetfactory.cpp | 12 ++++++++++++ src/targetfactory.h | 20 ++++++++++++++++++++ src/targetfile.cpp | 12 ++++++++++++ src/targetfile.h | 18 ++++++++++++++++++ 10 files changed, 120 insertions(+), 13 deletions(-) create mode 100644 src/target.cpp create mode 100644 src/target.h create mode 100644 src/targetfactory.cpp create mode 100644 src/targetfactory.h create mode 100644 src/targetfile.cpp create mode 100644 src/targetfile.h (limited to 'src') 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; [a-zA-Z][a-zA-Z0-9]* { { - yylval->tval = bld.getTargetType( yytext ); - if( yylval->tval >= 0 ) + if( bld.isTarget( yytext ) ) { + yylval->strval = stringdup( yytext ); return TARGETTYPE; } 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 ); %error-verbose %union { char *strval; - int tval; } %token STRING "string literal" -%token TARGETTYPE "target type" +%token TARGETTYPE "target type" %token FUNCTION "function name" %token PERFORM "perform name" @@ -51,6 +50,7 @@ input: | input rule | input action | input target + | input set ; // Rule interpretation @@ -61,7 +61,7 @@ rulecmds: rulecmd | rulecmds ',' rulecmd ; -rulecmd: TOK_MATCHES { printf(" Matches: " ); } func +rulecmd: TOK_MATCHES { printf(" Matches: " ); } func { printf("\n"); } | TOK_PRODUCES STRING { printf(" Produces: %s\n", $2 ); } | TOK_REQUIRES { printf(" Requires:\n"); } list {printf("\n");} | TOK_INPUT TOK_FILTER { printf(" Input Filter: "); } func {printf("\n");} @@ -94,9 +94,9 @@ targetcmds: targetcmd targetcmd: TOK_RULE STRING { printf(" Rule %s\n", $2 ); } | TOK_TARGET TOK_PREFIX STRING { printf(" Target prefix: %s\n", $3 ); } - | TOK_TARGET TARGETTYPE { printf(" Target Type: %d\n", $2 ); } + | TOK_TARGET TARGETTYPE { printf(" Target Type: %s\n", $2 ); } | TOK_INPUT { printf(" Input: "); } list { printf("\n"); } - | TOK_INPUT TOK_FILTER { printf(" Input filter: "); } func + | TOK_INPUT TOK_FILTER { printf(" Input filter: "); } func { printf("\n"); } | TOK_REQUIRES { printf(" Requires: "); } list { printf("\n"); } | TOK_SET { printf(" Set: "); } targetset ; @@ -105,6 +105,14 @@ targetset: STRING '=' STRING { printf("%s = %s\n", $1, $3 ); } | STRING TOK_ADDSET STRING { printf("%s += %s\n", $1, $3 ); } ; +// global set +set: TOK_SET { printf("Set: "); } setwhat + ; + +setwhat: STRING '=' STRING { printf("%s = %s\n", $1, $3 ); } + | STRING TOK_ADDSET STRING { printf("%s += %s\n", $1, $3 ); } + ; + // list goo list: listitem listfilter | '[' { 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 @@ #include "builder.h" #include "functionfactory.h" #include "performfactory.h" +#include "targetfactory.h" subExceptionDef( BuildException ); Builder::Builder() : fFunction( FunctionFactory::getInstance() ), - fPerform( PerformFactory::getInstance() ) + fPerform( PerformFactory::getInstance() ), + fTarget( TargetFactory::getInstance() ) { } @@ -42,11 +44,12 @@ void Builder::error( const std::string &msg ) throw BuildException("%s", msg.c_str() ); } -int Builder::getTargetType( const char *sType ) +// +// Target functions +// +bool Builder::isTarget( const char *sType ) { - if( !strcmp( sType, "file" ) ) - return 0; - return -1; + return fTarget.hasPlugin( sType ); } // 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; class FunctionFactory; class Perform; class PerformFactory; +class Target; +class TargetFactory; #define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, Builder &bld ) YY_DECL; @@ -28,13 +30,19 @@ public: void load( const std::string &sFile ); - int getTargetType( const char *sType ); private: std::string file; void scanBegin(); void scanEnd(); +public: // Target functions + bool isTarget( const char *sType ); + +private: // Target variables + Target *pTmpTarget; + TargetFactory &fTarget; + public: // Function functions bool isFunction( const char *sFunc ); 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 @@ +#include "target.h" + +Target::Target() +{ +} + +Target::~Target() +{ +} 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 @@ +#ifndef TARGET_H +#define TARGET_H + +#include + + +class Target +{ +public: + Target(); + virtual ~Target(); + +private: + +}; + +#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 @@ +#include "targetfactory.h" + +extern struct PluginInfo file; + +TargetFactory::TargetFactory() +{ + registerBuiltinPlugin( &file ); +} + +TargetFactory::~TargetFactory() +{ +} 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 @@ +#ifndef TARGET_FACTORY_H +#define TARGET_FACTORY_H + +#include + +#include "plugger.h" +#include "singleton.h" +#include "target.h" + +class TargetFactory : public Plugger, public Singleton +{ +public: + TargetFactory(); + virtual ~TargetFactory(); + +private: + +}; + +#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 @@ +#include "targetfile.h" +#include "plugger.h" + +PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 ); + +TargetFile::TargetFile() +{ +} + +TargetFile::~TargetFile() +{ +} 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 @@ +#ifndef TARGET_FILE_H +#define TARGET_FILE_H + +#include + +#include "target.h" + +class TargetFile : public Target +{ +public: + TargetFile(); + virtual ~TargetFile(); + +private: + +}; + +#endif -- cgit v1.2.3