diff options
Diffstat (limited to 'src/builder.h')
| -rw-r--r-- | src/builder.h | 94 |
1 files changed, 83 insertions, 11 deletions
diff --git a/src/builder.h b/src/builder.h index 1d126dc..8d72627 100644 --- a/src/builder.h +++ b/src/builder.h | |||
| @@ -6,8 +6,8 @@ | |||
| 6 | #include <list> | 6 | #include <list> |
| 7 | #include <utility> | 7 | #include <utility> |
| 8 | #include "build.tab.h" | 8 | #include "build.tab.h" |
| 9 | #include "exceptions.h" | ||
| 10 | 9 | ||
| 10 | class Build; | ||
| 11 | class Builder; | 11 | class Builder; |
| 12 | class Function; | 12 | class Function; |
| 13 | class FunctionFactory; | 13 | class FunctionFactory; |
| @@ -19,12 +19,37 @@ class TargetFactory; | |||
| 19 | #define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, Builder &bld ) | 19 | #define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, Builder &bld ) |
| 20 | YY_DECL; | 20 | YY_DECL; |
| 21 | 21 | ||
| 22 | subExceptionDecl( BuildException ); | ||
| 23 | |||
| 24 | typedef std::list<std::string> StringList; | 22 | typedef std::list<std::string> StringList; |
| 25 | 23 | ||
| 24 | template<class tx, class ty, class tz> | ||
| 25 | class Triplet | ||
| 26 | { | ||
| 27 | public: | ||
| 28 | Triplet( const tx &x, const ty &y, const tz &z ) : | ||
| 29 | first( x ), second( y ), third( z ) | ||
| 30 | {} | ||
| 31 | |||
| 32 | Triplet( const Triplet &src ) : | ||
| 33 | first( src.first ), second( src.second ), third( src.third ) | ||
| 34 | {} | ||
| 35 | |||
| 36 | tx first; | ||
| 37 | ty second; | ||
| 38 | tz third; | ||
| 39 | }; | ||
| 40 | |||
| 41 | enum eSetHow | ||
| 42 | { | ||
| 43 | setSet, | ||
| 44 | setAdd | ||
| 45 | }; | ||
| 46 | |||
| 26 | class Builder | 47 | class Builder |
| 27 | { | 48 | { |
| 49 | typedef std::pair<std::string, Function *> BuildListItem; | ||
| 50 | typedef std::list<BuildListItem> BuildList; | ||
| 51 | typedef Triplet<std::string, std::string, int> SetVar; | ||
| 52 | typedef std::list<SetVar> SetVarList; | ||
| 28 | public: | 53 | public: |
| 29 | Builder(); | 54 | Builder(); |
| 30 | virtual ~Builder(); | 55 | virtual ~Builder(); |
| @@ -32,19 +57,40 @@ public: | |||
| 32 | void error( YYLTYPE *locp, const char *msg ); | 57 | void error( YYLTYPE *locp, const char *msg ); |
| 33 | void error( const std::string &msg ); | 58 | void error( const std::string &msg ); |
| 34 | 59 | ||
| 35 | void load( const std::string &sFile ); | 60 | Build *load( const std::string &sFile ); |
| 36 | 61 | ||
| 37 | private: | 62 | private: |
| 38 | std::string file; | 63 | std::string file; |
| 39 | void scanBegin(); | 64 | void scanBegin(); |
| 40 | void scanEnd(); | 65 | void scanEnd(); |
| 41 | 66 | ||
| 67 | Build *genBuild(); | ||
| 68 | |||
| 42 | public: // Target functions | 69 | public: // Target functions |
| 43 | bool isTarget( const char *sType ); | 70 | bool isTarget( const char *sType ); |
| 71 | void newTarget(); | ||
| 72 | void setTargetRule( const char *sRule ); | ||
| 73 | void setTargetPrefix( const char *sPrefix ); | ||
| 74 | void setTargetType( const char *sType ); | ||
| 75 | void addTargetInput(); | ||
| 76 | void addTargetRequires(); | ||
| 77 | void addTargetSet( const char *sVar, const char *sVal, int nHow ); | ||
| 44 | 78 | ||
| 45 | private: // Target variables | 79 | private: // Target variables |
| 46 | Target *pTmpTarget; | ||
| 47 | TargetFactory &fTarget; | 80 | TargetFactory &fTarget; |
| 81 | class TargetInfo | ||
| 82 | { | ||
| 83 | public: | ||
| 84 | std::string sRule; | ||
| 85 | std::string sPrefix; | ||
| 86 | std::string sType; | ||
| 87 | BuildList lInput; | ||
| 88 | BuildList lRequires; | ||
| 89 | SetVarList lVar; | ||
| 90 | }; | ||
| 91 | typedef std::pair<BuildList,TargetInfo> TargetTmp; | ||
| 92 | typedef std::list<TargetTmp> TargetTmpList; | ||
| 93 | TargetTmpList lTargetTmp; | ||
| 48 | 94 | ||
| 49 | public: // Function functions | 95 | public: // Function functions |
| 50 | bool isFunction( const char *sFunc ); | 96 | bool isFunction( const char *sFunc ); |
| @@ -68,16 +114,35 @@ public: // List functions | |||
| 68 | void newList(); | 114 | void newList(); |
| 69 | void addListString( const char *str ); | 115 | void addListString( const char *str ); |
| 70 | void addListFunc(); | 116 | void addListFunc(); |
| 117 | void filterList(); | ||
| 71 | 118 | ||
| 72 | typedef std::pair<std::string, Function *> BuildListItem; | 119 | StringList buildToStringList( const BuildList &lSrc, const StringList &lIn ); |
| 73 | typedef std::list<BuildListItem> BuildList; | ||
| 74 | 120 | ||
| 75 | StringList buildToStringList( BuildList &lSrc, StringList &lIn ); | 121 | private: // List variables |
| 76 | |||
| 77 | private: | ||
| 78 | BuildList lTmp; | 122 | BuildList lTmp; |
| 79 | 123 | ||
| 80 | public: // Functions for dealing with rules | 124 | public: // Rules functions |
| 125 | void addRule( const char *sName ); | ||
| 126 | void addRuleMatches(); | ||
| 127 | void addRuleProduces(); | ||
| 128 | void addRuleRequires(); | ||
| 129 | void addRuleInputFilter(); | ||
| 130 | void addRulePerform(); | ||
| 131 | |||
| 132 | private: // Rule variables | ||
| 133 | class RuleInfo | ||
| 134 | { | ||
| 135 | public: | ||
| 136 | std::string sName; | ||
| 137 | Function *pMatches; | ||
| 138 | BuildList lProduces; | ||
| 139 | BuildList lRequires; | ||
| 140 | std::list<Function *> lFilter; | ||
| 141 | std::list<Perform *> lPerform; | ||
| 142 | }; | ||
| 143 | |||
| 144 | typedef std::list<RuleInfo> RuleTmpList; | ||
| 145 | RuleTmpList lRuleTmp; | ||
| 81 | 146 | ||
| 82 | public: // Functions for dealing with actions | 147 | public: // Functions for dealing with actions |
| 83 | void addAction(); | 148 | void addAction(); |
| @@ -91,8 +156,15 @@ private: // Action variables | |||
| 91 | typedef std::list<ActionTmp> ActionTmpList; | 156 | typedef std::list<ActionTmp> ActionTmpList; |
| 92 | ActionTmpList lActions; | 157 | ActionTmpList lActions; |
| 93 | 158 | ||
| 159 | public: // Global variable functions | ||
| 160 | void addGlobalSet( const char *sVar, const char *sValue, int nHow ); | ||
| 161 | |||
| 162 | private: // Global variable variables | ||
| 163 | SetVarList lGlobalVars; | ||
| 164 | |||
| 94 | public: // Debug | 165 | public: // Debug |
| 95 | void debugDump(); | 166 | void debugDump(); |
| 167 | void printBuildList( const BuildList &lst ); | ||
| 96 | }; | 168 | }; |
| 97 | 169 | ||
| 98 | #endif | 170 | #endif |
