From 375112224567de0b2f3666cef13b1c5832f1ed6f Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 29 Aug 2006 22:50:44 +0000 Subject: Updated a load, now there's a seperate module for performing string processing pre parser, and whatever. --- src/build.cpp | 11 +++++++++++ src/buildparser.cpp | 30 ++++++++++++++++++++++++++++ src/rule.cpp | 1 + src/rule.h | 8 +++++++- src/stringproc.cpp | 12 ++++++++++++ src/stringproc.h | 28 ++++++++++++++++++++++++++ src/stringprocbuild.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ src/stringprocbuild.h | 20 +++++++++++++++++++ 8 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 src/stringproc.cpp create mode 100644 src/stringproc.h create mode 100644 src/stringprocbuild.cpp create mode 100644 src/stringprocbuild.h (limited to 'src') diff --git a/src/build.cpp b/src/build.cpp index ec97ccb..03d3c5a 100644 --- a/src/build.cpp +++ b/src/build.cpp @@ -138,5 +138,16 @@ void Build::debugDump() ); } } + + printf("Rules:\n"); + for( RuleMap::iterator i = mRule.begin(); i != mRule.end(); i++ ) + { + printf(" %s:\n", (*i).first.c_str() ); + printf(" Matches: func\n"); + printf(" Filters: %d\n", (*i).second->getFilterList().size() ); + printf(" Performs: %d\n", (*i).second->getPerformList().size() ); + printf(" Produces:\n"); + printf(" Requires:\n"); + } } diff --git a/src/buildparser.cpp b/src/buildparser.cpp index 7903e04..5ebcfd3 100644 --- a/src/buildparser.cpp +++ b/src/buildparser.cpp @@ -411,6 +411,36 @@ Build *BuildParser::genBuild() } } + for( RuleTmpList::iterator i = lRuleTmp.begin(); i != lRuleTmp.end(); i++ ) + { + Rule *pRule = new Rule; + pRule->setName( (*i).sName ); + pRule->getMatchesList().push_back( (*i).pMatches ); + + for( FunctionList::iterator j = (*i).lFilter.begin(); + j != (*i).lFilter.end(); j++ ) + { + pRule->getFilterList().push_back( *j ); + } + + for( PerformList::iterator j = (*i).lPerform.begin(); + j != (*i).lPerform.end(); j++ ) + { + pRule->getPerformList().push_back( *j ); + } + + /*StringList lITmp = buildToStringList( + (*i).lProduces, StringList() + ); + + for( StringList::iterator i = lITmp.begin(); i != lITmp.end(); i++ ) + { + get + }*/ + + bld->addRule( pRule ); + } + return bld; } diff --git a/src/rule.cpp b/src/rule.cpp index 22af322..2212936 100644 --- a/src/rule.cpp +++ b/src/rule.cpp @@ -7,3 +7,4 @@ Rule::Rule() Rule::~Rule() { } + diff --git a/src/rule.h b/src/rule.h index ff251ca..012073a 100644 --- a/src/rule.h +++ b/src/rule.h @@ -27,7 +27,7 @@ public: this->sName = sName; } - FunctionList &getFunctionList() + FunctionList &getFilterList() { return lFilter; } @@ -37,8 +37,14 @@ public: return lPerform; } + FunctionList &getMatchesList() + { + return lMatches; + } + private: std::string sName; + FunctionList lMatches; FunctionList lFilter; PerformList lPerform; }; diff --git a/src/stringproc.cpp b/src/stringproc.cpp new file mode 100644 index 0000000..23abca9 --- /dev/null +++ b/src/stringproc.cpp @@ -0,0 +1,12 @@ +#include "stringproc.h" + +StringProc::StringProc( Build *pBld ) : + pBld( pBld ) +{ +} + +StringProc::~StringProc() +{ +} + + diff --git a/src/stringproc.h b/src/stringproc.h new file mode 100644 index 0000000..237ad6f --- /dev/null +++ b/src/stringproc.h @@ -0,0 +1,28 @@ +#ifndef STRING_PROC_H +#define STRING_PROC_H + +#include +#include + +class Build; + +class StringProc +{ +public: + StringProc( Build *pBld ); + virtual ~StringProc(); + + virtual std::string replVars( const std::string &sSrc, const std::string &sCont )=0; + +protected: + Build *getBuild() + { + return pBld; + } + +private: + Build *pBld; + +}; + +#endif diff --git a/src/stringprocbuild.cpp b/src/stringprocbuild.cpp new file mode 100644 index 0000000..56eae12 --- /dev/null +++ b/src/stringprocbuild.cpp @@ -0,0 +1,52 @@ +#include "stringprocbuild.h" +#include "build.h" + +StringProcBuild::StringProcBuild( Build *pBld ) : + StringProc( pBld ) +{ +} + +StringProcBuild::~StringProcBuild() +{ +} + +std::string StringProcBuild::replVars( const std::string &sSrc, const std::string &sCont ) +{ + std::string sDes, sBuf; + int nMode = 0; + + int nLen = sSrc.size(); + for( int j = 0; j < nLen; j++ ) + { + if( sSrc[j] == '{' ) + { + sBuf = ""; + nMode = 1; + } + else if( nMode == 0 ) + { + sDes += sSrc[j]; + } + else if( nMode == 1 ) + { + if( sSrc[j] == '}' ) + { + sDes += getBuild()->getVar( sCont, sBuf ); + nMode = 0; + } + else + { + sBuf += sSrc[j]; + } + } + } + + if( nMode == 1 ) + { + throw BuildException( + "Unterminated variable replacement found: \"%s\"", + sSrc.c_str() + ); + } +} + diff --git a/src/stringprocbuild.h b/src/stringprocbuild.h new file mode 100644 index 0000000..13dd4f6 --- /dev/null +++ b/src/stringprocbuild.h @@ -0,0 +1,20 @@ +#ifndef STRING_PROC_BUILD_H +#define STRING_PROC_BUILD_H + +#include + +#include "stringproc.h" + +class StringProcBuild : public StringProc +{ +public: + StringProcBuild( Build *pBld ); + virtual ~StringProcBuild(); + + virtual std::string replVars( const std::string &sSrc, const std::string &sCont ); + +private: + +}; + +#endif -- cgit v1.2.3