diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-08-28 18:26:07 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-08-28 18:26:07 +0000 |
commit | f7809b1a74da9a653b475b6fa499b078cad48c74 (patch) | |
tree | 612bed8a7e6303889f32e97ef984885841a8e819 | |
parent | d2fe7edb2bfea20987a1f69935179fa5fc9f3b37 (diff) | |
download | build-f7809b1a74da9a653b475b6fa499b078cad48c74.tar.gz build-f7809b1a74da9a653b475b6fa499b078cad48c74.tar.bz2 build-f7809b1a74da9a653b475b6fa499b078cad48c74.tar.xz build-f7809b1a74da9a653b475b6fa499b078cad48c74.zip |
Renamed Builder to BuildParser, soon I'll add the Parser base class and make
the whole thing official.
-rw-r--r-- | src/build.l | 6 | ||||
-rw-r--r-- | src/build.y | 11 | ||||
-rw-r--r-- | src/buildparser.cpp (renamed from src/builder.cpp) | 78 | ||||
-rw-r--r-- | src/buildparser.h (renamed from src/builder.h) | 10 | ||||
-rw-r--r-- | src/function.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 4 |
6 files changed, 55 insertions, 56 deletions
diff --git a/src/build.l b/src/build.l index 3e95132..41abaf4 100644 --- a/src/build.l +++ b/src/build.l | |||
@@ -1,6 +1,6 @@ | |||
1 | %{ | 1 | %{ |
2 | # include <string> | 2 | # include <string> |
3 | # include "builder.h" | 3 | # include "buildparser.h" |
4 | # include "build.tab.h" | 4 | # include "build.tab.h" |
5 | # include "stringrep.h" | 5 | # include "stringrep.h" |
6 | 6 | ||
@@ -116,7 +116,7 @@ std::string strbuf; | |||
116 | 116 | ||
117 | %% | 117 | %% |
118 | 118 | ||
119 | void Builder::scanBegin() | 119 | void BuildParser::scanBegin() |
120 | { | 120 | { |
121 | yy_flex_debug = false; | 121 | yy_flex_debug = false; |
122 | if( !(yyin = fopen( file.c_str(), "r" )) ) | 122 | if( !(yyin = fopen( file.c_str(), "r" )) ) |
@@ -125,7 +125,7 @@ void Builder::scanBegin() | |||
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | void Builder::scanEnd() | 128 | void BuildParser::scanEnd() |
129 | { | 129 | { |
130 | fclose( yyin ); | 130 | fclose( yyin ); |
131 | } | 131 | } |
diff --git a/src/build.y b/src/build.y index e9c0083..bb30d84 100644 --- a/src/build.y +++ b/src/build.y | |||
@@ -1,14 +1,14 @@ | |||
1 | %defines | 1 | %defines |
2 | %{ | 2 | %{ |
3 | # include <string> | 3 | # include <string> |
4 | # include "builder.h" | 4 | # include "buildparser.h" |
5 | # include "build.tab.h" | 5 | # include "build.tab.h" |
6 | # include "action.h" | 6 | # include "action.h" |
7 | void yyerror( YYLTYPE *locp, Builder &bld, char const *msg ); | 7 | void yyerror( YYLTYPE *locp, BuildParser &bld, char const *msg ); |
8 | %} | 8 | %} |
9 | 9 | ||
10 | %parse-param { Builder &bld } | 10 | %parse-param { BuildParser &bld } |
11 | %lex-param { Builder &bld } | 11 | %lex-param { BuildParser &bld } |
12 | %pure-parser | 12 | %pure-parser |
13 | 13 | ||
14 | %locations | 14 | %locations |
@@ -254,8 +254,7 @@ perfparams: | |||
254 | ; | 254 | ; |
255 | %% | 255 | %% |
256 | 256 | ||
257 | void yyerror( YYLTYPE *locp, Builder &bld, char const *msg ) | 257 | void yyerror( YYLTYPE *locp, BuildParser &bld, char const *msg ) |
258 | { | 258 | { |
259 | bld.error( locp, msg ); | 259 | bld.error( locp, msg ); |
260 | } | 260 | } |
261 | |||
diff --git a/src/builder.cpp b/src/buildparser.cpp index 1e916ab..cb285d4 100644 --- a/src/builder.cpp +++ b/src/buildparser.cpp | |||
@@ -1,4 +1,4 @@ | |||
1 | #include "builder.h" | 1 | #include "buildparser.h" |
2 | #include "functionfactory.h" | 2 | #include "functionfactory.h" |
3 | #include "performfactory.h" | 3 | #include "performfactory.h" |
4 | #include "targetfactory.h" | 4 | #include "targetfactory.h" |
@@ -6,21 +6,21 @@ | |||
6 | #include "build.h" | 6 | #include "build.h" |
7 | #include "rule.h" | 7 | #include "rule.h" |
8 | 8 | ||
9 | Builder::Builder() : | 9 | BuildParser::BuildParser() : |
10 | fFunction( FunctionFactory::getInstance() ), | 10 | fFunction( FunctionFactory::getInstance() ), |
11 | fPerform( PerformFactory::getInstance() ), | 11 | fPerform( PerformFactory::getInstance() ), |
12 | fTarget( TargetFactory::getInstance() ) | 12 | fTarget( TargetFactory::getInstance() ) |
13 | { | 13 | { |
14 | } | 14 | } |
15 | 15 | ||
16 | Builder::~Builder() | 16 | BuildParser::~BuildParser() |
17 | { | 17 | { |
18 | } | 18 | } |
19 | 19 | ||
20 | void yyparse( Builder &bld ); | 20 | void yyparse( BuildParser &bld ); |
21 | extern int yydebug; | 21 | extern int yydebug; |
22 | 22 | ||
23 | Build *Builder::load( const std::string &sFile ) | 23 | Build *BuildParser::load( const std::string &sFile ) |
24 | { | 24 | { |
25 | file = sFile; | 25 | file = sFile; |
26 | scanBegin(); | 26 | scanBegin(); |
@@ -31,7 +31,7 @@ Build *Builder::load( const std::string &sFile ) | |||
31 | return genBuild(); | 31 | return genBuild(); |
32 | } | 32 | } |
33 | 33 | ||
34 | void Builder::error( YYLTYPE *locp, const char *msg ) | 34 | void BuildParser::error( YYLTYPE *locp, const char *msg ) |
35 | { | 35 | { |
36 | fflush( stdout ); | 36 | fflush( stdout ); |
37 | throw BuildException("%s: %d.%d-%d.%d: %s", | 37 | throw BuildException("%s: %d.%d-%d.%d: %s", |
@@ -41,7 +41,7 @@ void Builder::error( YYLTYPE *locp, const char *msg ) | |||
41 | msg ); | 41 | msg ); |
42 | } | 42 | } |
43 | 43 | ||
44 | void Builder::error( const std::string &msg ) | 44 | void BuildParser::error( const std::string &msg ) |
45 | { | 45 | { |
46 | fflush( stdout ); | 46 | fflush( stdout ); |
47 | throw BuildException("%s", msg.c_str() ); | 47 | throw BuildException("%s", msg.c_str() ); |
@@ -50,32 +50,32 @@ void Builder::error( const std::string &msg ) | |||
50 | // | 50 | // |
51 | // Target functions | 51 | // Target functions |
52 | // | 52 | // |
53 | bool Builder::isTarget( const char *sType ) | 53 | bool BuildParser::isTarget( const char *sType ) |
54 | { | 54 | { |
55 | return fTarget.hasPlugin( sType ); | 55 | return fTarget.hasPlugin( sType ); |
56 | } | 56 | } |
57 | 57 | ||
58 | void Builder::newTarget() | 58 | void BuildParser::newTarget() |
59 | { | 59 | { |
60 | lTargetTmp.push_back( TargetTmp(lTmp, TargetInfo()) ); | 60 | lTargetTmp.push_back( TargetTmp(lTmp, TargetInfo()) ); |
61 | } | 61 | } |
62 | 62 | ||
63 | void Builder::setTargetRule( const char *sRule ) | 63 | void BuildParser::setTargetRule( const char *sRule ) |
64 | { | 64 | { |
65 | lTargetTmp.back().second.sRule = sRule; | 65 | lTargetTmp.back().second.sRule = sRule; |
66 | } | 66 | } |
67 | 67 | ||
68 | void Builder::setTargetPrefix( const char *sPrefix ) | 68 | void BuildParser::setTargetPrefix( const char *sPrefix ) |
69 | { | 69 | { |
70 | lTargetTmp.back().second.sPrefix = sPrefix; | 70 | lTargetTmp.back().second.sPrefix = sPrefix; |
71 | } | 71 | } |
72 | 72 | ||
73 | void Builder::setTargetType( const char *sType ) | 73 | void BuildParser::setTargetType( const char *sType ) |
74 | { | 74 | { |
75 | lTargetTmp.back().second.sType = sType; | 75 | lTargetTmp.back().second.sType = sType; |
76 | } | 76 | } |
77 | 77 | ||
78 | void Builder::addTargetInput() | 78 | void BuildParser::addTargetInput() |
79 | { | 79 | { |
80 | lTargetTmp.back().second.lInput.insert( | 80 | lTargetTmp.back().second.lInput.insert( |
81 | lTargetTmp.back().second.lInput.end(), | 81 | lTargetTmp.back().second.lInput.end(), |
@@ -83,7 +83,7 @@ void Builder::addTargetInput() | |||
83 | ); | 83 | ); |
84 | } | 84 | } |
85 | 85 | ||
86 | void Builder::addTargetRequires() | 86 | void BuildParser::addTargetRequires() |
87 | { | 87 | { |
88 | lTargetTmp.back().second.lRequires.insert( | 88 | lTargetTmp.back().second.lRequires.insert( |
89 | lTargetTmp.back().second.lRequires.end(), | 89 | lTargetTmp.back().second.lRequires.end(), |
@@ -91,7 +91,7 @@ void Builder::addTargetRequires() | |||
91 | ); | 91 | ); |
92 | } | 92 | } |
93 | 93 | ||
94 | void Builder::addTargetSet( const char *sVar, const char *sVal, int nHow ) | 94 | void BuildParser::addTargetSet( const char *sVar, const char *sVal, int nHow ) |
95 | { | 95 | { |
96 | lTargetTmp.back().second.lVar.push_back( SetVar( sVar, sVal, nHow ) ); | 96 | lTargetTmp.back().second.lVar.push_back( SetVar( sVar, sVal, nHow ) ); |
97 | } | 97 | } |
@@ -99,17 +99,17 @@ void Builder::addTargetSet( const char *sVar, const char *sVal, int nHow ) | |||
99 | // | 99 | // |
100 | // Function functions | 100 | // Function functions |
101 | // | 101 | // |
102 | bool Builder::isFunction( const char *sFunc ) | 102 | bool BuildParser::isFunction( const char *sFunc ) |
103 | { | 103 | { |
104 | return fFunction.hasPlugin( sFunc ); | 104 | return fFunction.hasPlugin( sFunc ); |
105 | } | 105 | } |
106 | 106 | ||
107 | void Builder::newFunctionCall( const char *sName ) | 107 | void BuildParser::newFunctionCall( const char *sName ) |
108 | { | 108 | { |
109 | pTmpFunc = fFunction.instantiate( sName ); | 109 | pTmpFunc = fFunction.instantiate( sName ); |
110 | } | 110 | } |
111 | 111 | ||
112 | void Builder::addFunctionParam( const char *sParam ) | 112 | void BuildParser::addFunctionParam( const char *sParam ) |
113 | { | 113 | { |
114 | pTmpFunc->addParam( sParam ); | 114 | pTmpFunc->addParam( sParam ); |
115 | } | 115 | } |
@@ -117,22 +117,22 @@ void Builder::addFunctionParam( const char *sParam ) | |||
117 | // | 117 | // |
118 | // List functions | 118 | // List functions |
119 | // | 119 | // |
120 | void Builder::newList() | 120 | void BuildParser::newList() |
121 | { | 121 | { |
122 | lTmp.clear(); | 122 | lTmp.clear(); |
123 | } | 123 | } |
124 | 124 | ||
125 | void Builder::addListString( const char *str ) | 125 | void BuildParser::addListString( const char *str ) |
126 | { | 126 | { |
127 | lTmp.push_back( BuildListItem(str, NULL) ); | 127 | lTmp.push_back( BuildListItem(str, NULL) ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void Builder::addListFunc() | 130 | void BuildParser::addListFunc() |
131 | { | 131 | { |
132 | lTmp.push_back( BuildListItem("", pTmpFunc ) ); | 132 | lTmp.push_back( BuildListItem("", pTmpFunc ) ); |
133 | } | 133 | } |
134 | 134 | ||
135 | void Builder::filterList() | 135 | void BuildParser::filterList() |
136 | { | 136 | { |
137 | StringList lTmp2; | 137 | StringList lTmp2; |
138 | StringList lIn = buildToStringList( lTmp, StringList() ); | 138 | StringList lIn = buildToStringList( lTmp, StringList() ); |
@@ -144,7 +144,7 @@ void Builder::filterList() | |||
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | StringList Builder::buildToStringList( const BuildList &lSrc, const StringList &lIn ) | 147 | StringList BuildParser::buildToStringList( const BuildList &lSrc, const StringList &lIn ) |
148 | { | 148 | { |
149 | StringList lOut; | 149 | StringList lOut; |
150 | 150 | ||
@@ -166,18 +166,18 @@ StringList Builder::buildToStringList( const BuildList &lSrc, const StringList & | |||
166 | // | 166 | // |
167 | // Rule functions | 167 | // Rule functions |
168 | // | 168 | // |
169 | void Builder::addRule( const char *sName ) | 169 | void BuildParser::addRule( const char *sName ) |
170 | { | 170 | { |
171 | lRuleTmp.push_back( RuleInfo() ); | 171 | lRuleTmp.push_back( RuleInfo() ); |
172 | lRuleTmp.back().sName = sName; | 172 | lRuleTmp.back().sName = sName; |
173 | } | 173 | } |
174 | 174 | ||
175 | void Builder::addRuleMatches() | 175 | void BuildParser::addRuleMatches() |
176 | { | 176 | { |
177 | lRuleTmp.back().pMatches = pTmpFunc; | 177 | lRuleTmp.back().pMatches = pTmpFunc; |
178 | } | 178 | } |
179 | 179 | ||
180 | void Builder::addRuleProduces() | 180 | void BuildParser::addRuleProduces() |
181 | { | 181 | { |
182 | lRuleTmp.back().lProduces.insert( | 182 | lRuleTmp.back().lProduces.insert( |
183 | lRuleTmp.back().lProduces.end(), | 183 | lRuleTmp.back().lProduces.end(), |
@@ -185,7 +185,7 @@ void Builder::addRuleProduces() | |||
185 | ); | 185 | ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void Builder::addRuleRequires() | 188 | void BuildParser::addRuleRequires() |
189 | { | 189 | { |
190 | lRuleTmp.back().lRequires.insert( | 190 | lRuleTmp.back().lRequires.insert( |
191 | lRuleTmp.back().lRequires.end(), | 191 | lRuleTmp.back().lRequires.end(), |
@@ -193,12 +193,12 @@ void Builder::addRuleRequires() | |||
193 | ); | 193 | ); |
194 | } | 194 | } |
195 | 195 | ||
196 | void Builder::addRuleInputFilter() | 196 | void BuildParser::addRuleInputFilter() |
197 | { | 197 | { |
198 | lRuleTmp.back().lFilter.push_back( pTmpFunc ); | 198 | lRuleTmp.back().lFilter.push_back( pTmpFunc ); |
199 | } | 199 | } |
200 | 200 | ||
201 | void Builder::addRulePerform() | 201 | void BuildParser::addRulePerform() |
202 | { | 202 | { |
203 | lRuleTmp.back().lPerform.push_back( pTmpPerform ); | 203 | lRuleTmp.back().lPerform.push_back( pTmpPerform ); |
204 | } | 204 | } |
@@ -206,17 +206,17 @@ void Builder::addRulePerform() | |||
206 | // | 206 | // |
207 | // Perform functions | 207 | // Perform functions |
208 | // | 208 | // |
209 | bool Builder::isPerform( const char *sPerf ) | 209 | bool BuildParser::isPerform( const char *sPerf ) |
210 | { | 210 | { |
211 | return fPerform.hasPlugin( sPerf ); | 211 | return fPerform.hasPlugin( sPerf ); |
212 | } | 212 | } |
213 | 213 | ||
214 | void Builder::newPerform( const char *sName ) | 214 | void BuildParser::newPerform( const char *sName ) |
215 | { | 215 | { |
216 | pTmpPerform = fPerform.instantiate( sName ); | 216 | pTmpPerform = fPerform.instantiate( sName ); |
217 | } | 217 | } |
218 | 218 | ||
219 | void Builder::addPerformParam( const char *sParam ) | 219 | void BuildParser::addPerformParam( const char *sParam ) |
220 | { | 220 | { |
221 | pTmpPerform->addParam( sParam ); | 221 | pTmpPerform->addParam( sParam ); |
222 | } | 222 | } |
@@ -224,17 +224,17 @@ void Builder::addPerformParam( const char *sParam ) | |||
224 | // | 224 | // |
225 | // Functions for dealing with actions | 225 | // Functions for dealing with actions |
226 | // | 226 | // |
227 | void Builder::addAction() | 227 | void BuildParser::addAction() |
228 | { | 228 | { |
229 | lActions.push_back( ActionTmp("", ActionTmpCmdList()) ); | 229 | lActions.push_back( ActionTmp("", ActionTmpCmdList()) ); |
230 | } | 230 | } |
231 | 231 | ||
232 | void Builder::addAction( const char *sName ) | 232 | void BuildParser::addAction( const char *sName ) |
233 | { | 233 | { |
234 | lActions.push_back( ActionTmp(sName, ActionTmpCmdList()) ); | 234 | lActions.push_back( ActionTmp(sName, ActionTmpCmdList()) ); |
235 | } | 235 | } |
236 | 236 | ||
237 | void Builder::addCommand( int nType ) | 237 | void BuildParser::addCommand( int nType ) |
238 | { | 238 | { |
239 | lActions.back().second.push_back( ActionTmpCmd( nType, lTmp ) ); | 239 | lActions.back().second.push_back( ActionTmpCmd( nType, lTmp ) ); |
240 | } | 240 | } |
@@ -242,7 +242,7 @@ void Builder::addCommand( int nType ) | |||
242 | // | 242 | // |
243 | // Global variable functions | 243 | // Global variable functions |
244 | // | 244 | // |
245 | void Builder::addGlobalSet( const char *sVar, const char *sValue, int nHow ) | 245 | void BuildParser::addGlobalSet( const char *sVar, const char *sValue, int nHow ) |
246 | { | 246 | { |
247 | lGlobalVars.push_back( SetVar( sVar, sValue, nHow ) ); | 247 | lGlobalVars.push_back( SetVar( sVar, sValue, nHow ) ); |
248 | } | 248 | } |
@@ -250,7 +250,7 @@ void Builder::addGlobalSet( const char *sVar, const char *sValue, int nHow ) | |||
250 | // | 250 | // |
251 | // Debug | 251 | // Debug |
252 | // | 252 | // |
253 | void Builder::debugDump() | 253 | void BuildParser::debugDump() |
254 | { | 254 | { |
255 | printf("Actions:\n"); | 255 | printf("Actions:\n"); |
256 | for( ActionTmpList::iterator i = lActions.begin(); | 256 | for( ActionTmpList::iterator i = lActions.begin(); |
@@ -331,7 +331,7 @@ void Builder::debugDump() | |||
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | void Builder::printBuildList( const BuildList &lst ) | 334 | void BuildParser::printBuildList( const BuildList &lst ) |
335 | { | 335 | { |
336 | printf("["); | 336 | printf("["); |
337 | for( BuildList::const_iterator k = lst.begin(); | 337 | for( BuildList::const_iterator k = lst.begin(); |
@@ -356,7 +356,7 @@ void Builder::printBuildList( const BuildList &lst ) | |||
356 | // | 356 | // |
357 | // Actually make a build object | 357 | // Actually make a build object |
358 | // | 358 | // |
359 | Build *Builder::genBuild() | 359 | Build *BuildParser::genBuild() |
360 | { | 360 | { |
361 | Build *bld = new Build; | 361 | Build *bld = new Build; |
362 | 362 | ||
diff --git a/src/builder.h b/src/buildparser.h index 367769f..642cc73 100644 --- a/src/builder.h +++ b/src/buildparser.h | |||
@@ -8,7 +8,7 @@ | |||
8 | #include "build.tab.h" | 8 | #include "build.tab.h" |
9 | 9 | ||
10 | class Build; | 10 | class Build; |
11 | class Builder; | 11 | class BuildParser; |
12 | class Function; | 12 | class Function; |
13 | class FunctionFactory; | 13 | class FunctionFactory; |
14 | class Perform; | 14 | class Perform; |
@@ -16,7 +16,7 @@ class PerformFactory; | |||
16 | class Target; | 16 | class Target; |
17 | class TargetFactory; | 17 | class TargetFactory; |
18 | 18 | ||
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, BuildParser &bld ) |
20 | YY_DECL; | 20 | YY_DECL; |
21 | 21 | ||
22 | typedef std::list<std::string> StringList; | 22 | typedef std::list<std::string> StringList; |
@@ -46,15 +46,15 @@ enum eSetHow | |||
46 | setAdd | 46 | setAdd |
47 | }; | 47 | }; |
48 | 48 | ||
49 | class Builder | 49 | class BuildParser |
50 | { | 50 | { |
51 | typedef std::pair<std::string, Function *> BuildListItem; | 51 | typedef std::pair<std::string, Function *> BuildListItem; |
52 | typedef std::list<BuildListItem> BuildList; | 52 | typedef std::list<BuildListItem> BuildList; |
53 | typedef Triplet<std::string, std::string, int> SetVar; | 53 | typedef Triplet<std::string, std::string, int> SetVar; |
54 | typedef std::list<SetVar> SetVarList; | 54 | typedef std::list<SetVar> SetVarList; |
55 | public: | 55 | public: |
56 | Builder(); | 56 | BuildParser(); |
57 | virtual ~Builder(); | 57 | virtual ~BuildParser(); |
58 | 58 | ||
59 | void error( YYLTYPE *locp, const char *msg ); | 59 | void error( YYLTYPE *locp, const char *msg ); |
60 | void error( const std::string &msg ); | 60 | void error( const std::string &msg ); |
diff --git a/src/function.h b/src/function.h index 0e8f49e..73dcb01 100644 --- a/src/function.h +++ b/src/function.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #define FUNCTION_H | 2 | #define FUNCTION_H |
3 | 3 | ||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include "builder.h" | 5 | #include "build.h" |
6 | 6 | ||
7 | class Function | 7 | class Function |
8 | { | 8 | { |
diff --git a/src/main.cpp b/src/main.cpp index be95f07..9dbf046 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
@@ -1,4 +1,4 @@ | |||
1 | #include "builder.h" | 1 | #include "buildparser.h" |
2 | //#include "viewerplain.h" | 2 | //#include "viewerplain.h" |
3 | //#include "viewerpercent.h" | 3 | //#include "viewerpercent.h" |
4 | //#include "viewermake.h" | 4 | //#include "viewermake.h" |
@@ -72,7 +72,7 @@ int main( int argc, char *argv[] ) | |||
72 | Param prm; | 72 | Param prm; |
73 | prm.process( argc, argv ); | 73 | prm.process( argc, argv ); |
74 | 74 | ||
75 | Builder bld;//*prm.pViewer ); | 75 | BuildParser bld;//*prm.pViewer ); |
76 | 76 | ||
77 | //bld.setCache( prm.sCache ); | 77 | //bld.setCache( prm.sCache ); |
78 | //try | 78 | //try |