From 4887f62bea708f24e03b3f926f2698c60a94c807 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 21 Aug 2006 05:54:52 +0000 Subject: Getting there, it compiles, now for the fun sophisticated pieces where the builder itself tells the lexer which tokens are functions, and which are target types. --- congo | 3 +++ src/build.l | 1 + src/build.y | 4 ---- src/builder.cpp | 30 ++++++++++++++++++++++++++++++ src/builder.h | 31 +++++++++++++++++++++++++++++++ src/main.cpp | 52 ++++++++++++++++++++++++++-------------------------- src/viewer.cpp | 9 +++++++++ src/viewer.h | 17 +++++++++++++++++ 8 files changed, 117 insertions(+), 30 deletions(-) create mode 100644 src/builder.cpp create mode 100644 src/builder.h create mode 100644 src/viewer.cpp create mode 100644 src/viewer.h diff --git a/congo b/congo index 3031f4e..f64cd9b 100644 --- a/congo +++ b/congo @@ -31,6 +31,9 @@ server action: check congod create file congod from files in src/congod, src/shared using rule exe create file congo from files in src/congo, src/shared using rule exe +create files "modules/db{name}.so" from directories in src/congod/db ... + from files in "src/congod/db/{name}" using rule lib + # # After all of that, some targets or list items may have their own additional # dependancies, depending on the rule that built them. You can define these diff --git a/src/build.l b/src/build.l index b174681..9a15719 100644 --- a/src/build.l +++ b/src/build.l @@ -31,6 +31,7 @@ std::string strbuf; "produces" return TOK_PRODUCES; "check" return TOK_CHECK; "clean" return TOK_CLEAN; +"target" return TOK_TARGET; \n+ { yylloc->last_line += yyleng; diff --git a/src/build.y b/src/build.y index a624418..d852c4c 100644 --- a/src/build.y +++ b/src/build.y @@ -2,10 +2,6 @@ %{ # include # include "builder.h" -# include "action.h" -# include "command.h" -# include "rule.h" -# include "filetarget.h" # include "build.tab.h" void yyerror( YYLTYPE *locp, Builder &bld, char const *msg ); %} diff --git a/src/builder.cpp b/src/builder.cpp new file mode 100644 index 0000000..1ecbf05 --- /dev/null +++ b/src/builder.cpp @@ -0,0 +1,30 @@ +#include "builder.h" + +Builder::Builder() +{ +} + +Builder::~Builder() +{ +} + +void yyparse( Builder &bld ); + +void Builder::load( const std::string &sFile ) +{ + file = sFile; + scanBegin(); + yyparse( *this ); + scanEnd(); +} + +void Builder::error( YYLTYPE *locp, const char *msg ) +{ + printf("%s\n", msg ); +} + +void Builder::error( const std::string &msg ) +{ + printf("%s\n", msg.c_str() ); +} + diff --git a/src/builder.h b/src/builder.h new file mode 100644 index 0000000..9c146ea --- /dev/null +++ b/src/builder.h @@ -0,0 +1,31 @@ +#ifndef BUILDER_H +#define BUILDER_H + +#include +#include +#include "build.tab.h" + +class Builder; + +#define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, Builder &bld ) +YY_DECL; + +class Builder +{ +public: + Builder(); + virtual ~Builder(); + + void error( YYLTYPE *locp, const char *msg ); + void error( const std::string &msg ); + + void load( const std::string &sFile ); + +private: + std::string file; + void scanBegin(); + void scanEnd(); + +}; + +#endif diff --git a/src/main.cpp b/src/main.cpp index 2b4baa5..9168df7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ #include "builder.h" -#include "viewerplain.h" -#include "viewerpercent.h" -#include "viewermake.h" +//#include "viewerplain.h" +//#include "viewerpercent.h" +//#include "viewermake.h" #include "paramproc.h" #include "staticstring.h" @@ -26,12 +26,12 @@ public: "Print out a debug dump of the read build.conf", "true" ); addParam("help", mkproc(ParamProc::help), "This help"); - pViewer = new ViewerPlain; + //pViewer = new ViewerPlain; } virtual ~Param() { - delete pViewer; + //delete pViewer; } virtual int cmdParam( int argc, char *argv[] ) @@ -47,20 +47,20 @@ public: int procViewPercent( int argc, char *argv[] ) { - delete pViewer; - pViewer = new ViewerPercent; + //delete pViewer; + //pViewer = new ViewerPercent; } int procViewMake( int argc, char *argv[] ) { - delete pViewer; - pViewer = new ViewerMake; + //delete pViewer; + //pViewer = new ViewerMake; } std::string sCache; std::string sFile; StaticString sAction; - Viewer *pViewer; + //Viewer *pViewer; bool bDebug; private: @@ -71,31 +71,31 @@ int main( int argc, char *argv[] ) Param prm; prm.process( argc, argv ); - Builder bld( *prm.pViewer ); + Builder bld;//*prm.pViewer ); - bld.setCache( prm.sCache ); - try - { + //bld.setCache( prm.sCache ); + //try + //{ bld.load( prm.sFile.c_str() ); - } - catch( BuildException &e ) - { - fputs( e.what(), stderr ); - fputs( "\n", stderr ); - return 1; - } + //} + //catch( BuildException &e ) + //{ + // fputs( e.what(), stderr ); + // fputs( "\n", stderr ); + // return 1; + //} if( prm.bDebug ) { printf("\n\n----------\nDebug dump\n----------\n"); - bld.debug(); + //bld.debug(); } else { - if( prm.sAction > 0 ) - bld.build( prm.sAction ); - else - bld.build(); + //if( prm.sAction > 0 ) + // bld.build( prm.sAction ); + //else + // bld.build(); } } diff --git a/src/viewer.cpp b/src/viewer.cpp new file mode 100644 index 0000000..93b2ac1 --- /dev/null +++ b/src/viewer.cpp @@ -0,0 +1,9 @@ +#include "viewer.h" + +Viewer::Viewer() +{ +} + +Viewer::~Viewer() +{ +} diff --git a/src/viewer.h b/src/viewer.h new file mode 100644 index 0000000..04f4ea7 --- /dev/null +++ b/src/viewer.h @@ -0,0 +1,17 @@ +#ifndef VIEWER_H +#define VIEWER_H + +#include + + +class Viewer +{ +public: + Viewer(); + virtual ~Viewer(); + +private: + +}; + +#endif -- cgit v1.2.3