aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-08-22 15:12:20 +0000
committerMike Buland <eichlan@xagasoft.com>2006-08-22 15:12:20 +0000
commitf5cf5725026ecb2fa63d729fb6745b4da15e69d8 (patch)
treeaf48e59cc29dcea1218221dbb6ed9f0cd7f19989 /src
parentee98faf71642cf351d5cda241679b094aeec65ce (diff)
downloadbuild-f5cf5725026ecb2fa63d729fb6745b4da15e69d8.tar.gz
build-f5cf5725026ecb2fa63d729fb6745b4da15e69d8.tar.bz2
build-f5cf5725026ecb2fa63d729fb6745b4da15e69d8.tar.xz
build-f5cf5725026ecb2fa63d729fb6745b4da15e69d8.zip
Started on the crazy process of building the stage one compiled data. It's
going pretty quickly, we'll see how the targets go, they'll be the only tricky part.
Diffstat (limited to '')
-rw-r--r--src/action.cpp9
-rw-r--r--src/action.h22
-rw-r--r--src/build.cpp9
-rw-r--r--src/build.h17
-rw-r--r--src/build.y71
-rw-r--r--src/builder.cpp98
-rw-r--r--src/builder.h25
-rw-r--r--src/function.cpp6
-rw-r--r--src/function.h6
-rw-r--r--src/functioncommandtolist.cpp5
-rw-r--r--src/functioncommandtolist.h2
-rw-r--r--src/functiondirectoriesin.cpp5
-rw-r--r--src/functiondirectoriesin.h2
-rw-r--r--src/functionfilesin.cpp5
-rw-r--r--src/functionfilesin.h2
-rw-r--r--src/functionregexp.cpp5
-rw-r--r--src/functionregexp.h2
-rw-r--r--src/functiontostring.cpp5
-rw-r--r--src/functiontostring.h2
-rw-r--r--src/main.cpp6
20 files changed, 284 insertions, 20 deletions
diff --git a/src/action.cpp b/src/action.cpp
new file mode 100644
index 0000000..cdf50e8
--- /dev/null
+++ b/src/action.cpp
@@ -0,0 +1,9 @@
1#include "action.h"
2
3Action::Action()
4{
5}
6
7Action::~Action()
8{
9}
diff --git a/src/action.h b/src/action.h
new file mode 100644
index 0000000..4ec3b4a
--- /dev/null
+++ b/src/action.h
@@ -0,0 +1,22 @@
1#ifndef ACTION_H
2#define ACTION_H
3
4#include <stdint.h>
5
6class Action
7{
8public:
9 enum eAction
10 {
11 actCheck,
12 actClean
13 };
14public:
15 Action();
16 virtual ~Action();
17
18private:
19
20};
21
22#endif
diff --git a/src/build.cpp b/src/build.cpp
new file mode 100644
index 0000000..d3bd960
--- /dev/null
+++ b/src/build.cpp
@@ -0,0 +1,9 @@
1#include "build.h"
2
3Build::Build()
4{
5}
6
7Build::~Build()
8{
9}
diff --git a/src/build.h b/src/build.h
new file mode 100644
index 0000000..a2bf3ed
--- /dev/null
+++ b/src/build.h
@@ -0,0 +1,17 @@
1#ifndef BUILD_H
2#define BUILD_H
3
4#include <stdint.h>
5
6
7class Build
8{
9public:
10 Build();
11 virtual ~Build();
12
13private:
14
15};
16
17#endif
diff --git a/src/build.y b/src/build.y
index 1424867..40f8d34 100644
--- a/src/build.y
+++ b/src/build.y
@@ -3,6 +3,7 @@
3# include <string> 3# include <string>
4# include "builder.h" 4# include "builder.h"
5# include "build.tab.h" 5# include "build.tab.h"
6# include "action.h"
6void yyerror( YYLTYPE *locp, Builder &bld, char const *msg ); 7void yyerror( YYLTYPE *locp, Builder &bld, char const *msg );
7%} 8%}
8 9
@@ -69,21 +70,37 @@ rulecmd: TOK_MATCHES { printf(" Matches: " ); } func { printf("\n"); }
69 ; 70 ;
70 71
71// Action interpretation 72// Action interpretation
72action: TOK_DEFAULT TOK_ACTION ':' { printf("Default action:\n"); } actioncmds 73action: TOK_DEFAULT TOK_ACTION ':'
73 | STRING TOK_ACTION ':' { printf("\"%s\" action:\n", $1 ); } actioncmds 74 {
75 bld.addAction();
76 }
77 actioncmds
78 | STRING TOK_ACTION ':'
79 {
80 if( $1[0] == '\0' )
81 bld.error(
82 &yylloc,
83 "You cannot use an empty string as the name of an action."
84 );
85 bld.addAction( $1 );
86 }
87 actioncmds
74 ; 88 ;
75 89
76actioncmds: actioncmd 90actioncmds: actioncmd
77 | actioncmds ',' actioncmd 91 | actioncmds ',' actioncmd
78 ; 92 ;
79 93
80actioncmd: { printf(" "); } actioncmdtype list {printf("\n");} 94actioncmd: TOK_CHECK list
95 {
96 bld.addCommand( Action::actCheck );
97 }
98 | TOK_CLEAN list
99 {
100 bld.addCommand( Action::actClean );
101 }
81 ; 102 ;
82 103
83actioncmdtype: TOK_CHECK { printf("check "); }
84 | TOK_CLEAN { printf("clean "); }
85 ;
86
87// Target interpretation 104// Target interpretation
88target: list ':' { printf(" are targets:\n"); } targetcmds 105target: list ':' { printf(" are targets:\n"); } targetcmds
89 ; 106 ;
@@ -114,8 +131,12 @@ setwhat: STRING '=' STRING { printf("%s = %s\n", $1, $3 ); }
114 ; 131 ;
115 132
116// list goo 133// list goo
117list: listitem listfilter 134list: singlelistitem listfilter
118 | '[' { printf("["); } listitems ']' { printf("]"); } listfilter 135 | '['
136 {
137 bld.newList();
138 }
139 listitems ']' listfilter
119 ; 140 ;
120 141
121listfilter: 142listfilter:
@@ -123,20 +144,42 @@ listfilter:
123 ; 144 ;
124 145
125listitems: listitem 146listitems: listitem
126 | listitems ',' { printf(", "); } listitem 147 | listitems ',' listitem
127 ; 148 ;
128 149
129listitem: STRING { printf("%s", $1 ); } 150listitem: STRING
151 {
152 bld.addListString( $1 );
153 }
130 | func 154 | func
155 {
156 bld.addListFunc();
157 }
131 ; 158 ;
132 159
160singlelistitem: STRING
161 {
162 bld.newList();
163 bld.addListString( $1 );
164 }
165 | func
166 {
167 bld.newList();
168 bld.addListFunc();
169 }
170 ;
171
133// Function 172// Function
134func: FUNCTION { printf("%s(", $1 ); } '(' funcparams ')' { printf(")"); } 173func: FUNCTION
174 {
175 bld.newFunctionCall( $1 );
176 }
177 '(' funcparams ')'
135 ; 178 ;
136 179
137funcparams: 180funcparams:
138 | STRING { printf("%s", $1 ); } 181 | STRING { bld.addFunctionParam( $1 ); }
139 | funcparams ',' STRING { printf(", %s", $3 ); } 182 | funcparams ',' STRING { bld.addFunctionParam( $3 ); }
140 ; 183 ;
141 184
142// Perform 185// Perform
diff --git a/src/builder.cpp b/src/builder.cpp
index e8cd6e2..70be725 100644
--- a/src/builder.cpp
+++ b/src/builder.cpp
@@ -2,6 +2,7 @@
2#include "functionfactory.h" 2#include "functionfactory.h"
3#include "performfactory.h" 3#include "performfactory.h"
4#include "targetfactory.h" 4#include "targetfactory.h"
5#include "action.h"
5 6
6subExceptionDef( BuildException ); 7subExceptionDef( BuildException );
7 8
@@ -62,11 +63,46 @@ bool Builder::isFunction( const char *sFunc )
62 63
63void Builder::newFunctionCall( const char *sName ) 64void Builder::newFunctionCall( const char *sName )
64{ 65{
65 66 pTmpFunc = fFunction.instantiate( sName );
66} 67}
67 68
68void Builder::addFunctionParam( const char *sParam ) 69void Builder::addFunctionParam( const char *sParam )
69{ 70{
71 pTmpFunc->addParam( sParam );
72}
73
74void Builder::newList()
75{
76 lTmp.clear();
77}
78
79void Builder::addListString( const char *str )
80{
81 lTmp.push_back( BuildListItem(str, NULL) );
82}
83
84void Builder::addListFunc()
85{
86 lTmp.push_back( BuildListItem("", pTmpFunc ) );
87}
88
89StringList Builder::buildToStringList( Builder::BuildList &lSrc, StringList &lIn )
90{
91 StringList lOut;
92
93 for( BuildList::iterator i = lSrc.begin(); i != lSrc.end(); i++ )
94 {
95 if( (*i).second )
96 {
97 (*i).second->execute( lIn, lOut );
98 }
99 else
100 {
101 lOut.push_back( (*i).first );
102 }
103 }
104
105 return lOut;
70} 106}
71 107
72// 108//
@@ -85,3 +121,63 @@ void Builder::addPerformParam( const char *sParam )
85{ 121{
86} 122}
87 123
124//
125// Functions for dealing with actions
126//
127void Builder::addAction()
128{
129 lActions.push_back( ActionTmp("", ActionTmpCmdList()) );
130}
131
132void Builder::addAction( const char *sName )
133{
134 lActions.push_back( ActionTmp(sName, ActionTmpCmdList()) );
135}
136
137void Builder::addCommand( int nType )
138{
139 lActions.back().second.push_back( ActionTmpCmd( nType, lTmp ) );
140}
141
142//
143// Debug
144//
145void Builder::debugDump()
146{
147 printf("Actions:\n");
148 for( ActionTmpList::iterator i = lActions.begin();
149 i != lActions.end(); i++ )
150 {
151 if( (*i).first == "" )
152 {
153 printf(" default:\n");
154 }
155 else
156 {
157 printf(" \"%s\":\n", (*i).first.c_str() );
158 }
159 for( ActionTmpCmdList::iterator j = (*i).second.begin();
160 j != (*i).second.end(); j++ )
161 {
162 printf(" %d [", (*j).first );
163 for( BuildList::iterator k = (*j).second.begin();
164 k != (*j).second.end(); k++ )
165 {
166 if( k != (*j).second.begin() )
167 {
168 printf(", ");
169 }
170 if( (*k).second )
171 {
172 printf("func()");
173 }
174 else
175 {
176 printf("\"%s\"", (*k).first.c_str() );
177 }
178 }
179 printf("]\n");
180 }
181 }
182}
183
diff --git a/src/builder.h b/src/builder.h
index a6f88f4..1d126dc 100644
--- a/src/builder.h
+++ b/src/builder.h
@@ -3,6 +3,8 @@
3 3
4#include <stdint.h> 4#include <stdint.h>
5#include <string> 5#include <string>
6#include <list>
7#include <utility>
6#include "build.tab.h" 8#include "build.tab.h"
7#include "exceptions.h" 9#include "exceptions.h"
8 10
@@ -19,6 +21,8 @@ YY_DECL;
19 21
20subExceptionDecl( BuildException ); 22subExceptionDecl( BuildException );
21 23
24typedef std::list<std::string> StringList;
25
22class Builder 26class Builder
23{ 27{
24public: 28public:
@@ -30,7 +34,6 @@ public:
30 34
31 void load( const std::string &sFile ); 35 void load( const std::string &sFile );
32 36
33
34private: 37private:
35 std::string file; 38 std::string file;
36 void scanBegin(); 39 void scanBegin();
@@ -66,10 +69,30 @@ public: // List functions
66 void addListString( const char *str ); 69 void addListString( const char *str );
67 void addListFunc(); 70 void addListFunc();
68 71
72 typedef std::pair<std::string, Function *> BuildListItem;
73 typedef std::list<BuildListItem> BuildList;
74
75 StringList buildToStringList( BuildList &lSrc, StringList &lIn );
76
77private:
78 BuildList lTmp;
79
69public: // Functions for dealing with rules 80public: // Functions for dealing with rules
81
82public: // Functions for dealing with actions
70 void addAction(); 83 void addAction();
71 void addAction( const char *sName ); 84 void addAction( const char *sName );
72 void addCommand( int nType ); 85 void addCommand( int nType );
86
87private: // Action variables
88 typedef std::pair<int, BuildList> ActionTmpCmd;
89 typedef std::list<ActionTmpCmd> ActionTmpCmdList;
90 typedef std::pair<std::string, ActionTmpCmdList> ActionTmp;
91 typedef std::list<ActionTmp> ActionTmpList;
92 ActionTmpList lActions;
93
94public: // Debug
95 void debugDump();
73}; 96};
74 97
75#endif 98#endif
diff --git a/src/function.cpp b/src/function.cpp
index 5eeac97..e7554e1 100644
--- a/src/function.cpp
+++ b/src/function.cpp
@@ -7,3 +7,9 @@ Function::Function()
7Function::~Function() 7Function::~Function()
8{ 8{
9} 9}
10
11void Function::addParam( const char *str )
12{
13 lParams.push_back( str );
14}
15
diff --git a/src/function.h b/src/function.h
index 44a894d..c840922 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 5#include "builder.h"
6 6
7class Function 7class Function
8{ 8{
@@ -10,7 +10,11 @@ public:
10 Function(); 10 Function();
11 virtual ~Function(); 11 virtual ~Function();
12 12
13 void addParam( const char *str );
14 virtual void execute( StringList &lInput, StringList &lOutput )=0;
15
13private: 16private:
17 StringList lParams;
14 18
15}; 19};
16 20
diff --git a/src/functioncommandtolist.cpp b/src/functioncommandtolist.cpp
index 8d18870..6299f6f 100644
--- a/src/functioncommandtolist.cpp
+++ b/src/functioncommandtolist.cpp
@@ -10,3 +10,8 @@ FunctionCommandToList::FunctionCommandToList()
10FunctionCommandToList::~FunctionCommandToList() 10FunctionCommandToList::~FunctionCommandToList()
11{ 11{
12} 12}
13
14void FunctionCommandToList::execute( StringList &lInput, StringList &lOutput )
15{
16}
17
diff --git a/src/functioncommandtolist.h b/src/functioncommandtolist.h
index 90b4bf3..5bebe16 100644
--- a/src/functioncommandtolist.h
+++ b/src/functioncommandtolist.h
@@ -10,6 +10,8 @@ class FunctionCommandToList : public Function
10public: 10public:
11 FunctionCommandToList(); 11 FunctionCommandToList();
12 virtual ~FunctionCommandToList(); 12 virtual ~FunctionCommandToList();
13
14 virtual void execute( StringList &lInput, StringList &lOutput );
13 15
14private: 16private:
15 17
diff --git a/src/functiondirectoriesin.cpp b/src/functiondirectoriesin.cpp
index f847e13..a22e5d7 100644
--- a/src/functiondirectoriesin.cpp
+++ b/src/functiondirectoriesin.cpp
@@ -10,3 +10,8 @@ FunctionDirectoriesIn::FunctionDirectoriesIn()
10FunctionDirectoriesIn::~FunctionDirectoriesIn() 10FunctionDirectoriesIn::~FunctionDirectoriesIn()
11{ 11{
12} 12}
13
14void FunctionDirectoriesIn::execute( StringList &lInput, StringList &lOutput )
15{
16}
17
diff --git a/src/functiondirectoriesin.h b/src/functiondirectoriesin.h
index 5f6ee42..d769a0d 100644
--- a/src/functiondirectoriesin.h
+++ b/src/functiondirectoriesin.h
@@ -10,6 +10,8 @@ class FunctionDirectoriesIn : public Function
10public: 10public:
11 FunctionDirectoriesIn(); 11 FunctionDirectoriesIn();
12 virtual ~FunctionDirectoriesIn(); 12 virtual ~FunctionDirectoriesIn();
13
14 virtual void execute( StringList &lInput, StringList &lOutput );
13 15
14private: 16private:
15 17
diff --git a/src/functionfilesin.cpp b/src/functionfilesin.cpp
index 3a9d163..7dc073b 100644
--- a/src/functionfilesin.cpp
+++ b/src/functionfilesin.cpp
@@ -10,3 +10,8 @@ FunctionFilesIn::FunctionFilesIn()
10FunctionFilesIn::~FunctionFilesIn() 10FunctionFilesIn::~FunctionFilesIn()
11{ 11{
12} 12}
13
14void FunctionFilesIn::execute( StringList &lInput, StringList &lOutput )
15{
16}
17
diff --git a/src/functionfilesin.h b/src/functionfilesin.h
index 070f508..2ad23f9 100644
--- a/src/functionfilesin.h
+++ b/src/functionfilesin.h
@@ -10,6 +10,8 @@ class FunctionFilesIn : public Function
10public: 10public:
11 FunctionFilesIn(); 11 FunctionFilesIn();
12 virtual ~FunctionFilesIn(); 12 virtual ~FunctionFilesIn();
13
14 virtual void execute( StringList &lInput, StringList &lOutput );
13 15
14private: 16private:
15 17
diff --git a/src/functionregexp.cpp b/src/functionregexp.cpp
index fd632ae..045f745 100644
--- a/src/functionregexp.cpp
+++ b/src/functionregexp.cpp
@@ -10,3 +10,8 @@ FunctionRegexp::FunctionRegexp()
10FunctionRegexp::~FunctionRegexp() 10FunctionRegexp::~FunctionRegexp()
11{ 11{
12} 12}
13
14void FunctionRegexp::execute( StringList &lInput, StringList &lOutput )
15{
16}
17
diff --git a/src/functionregexp.h b/src/functionregexp.h
index 0adaf97..80a8220 100644
--- a/src/functionregexp.h
+++ b/src/functionregexp.h
@@ -10,6 +10,8 @@ class FunctionRegexp : public Function
10public: 10public:
11 FunctionRegexp(); 11 FunctionRegexp();
12 virtual ~FunctionRegexp(); 12 virtual ~FunctionRegexp();
13
14 virtual void execute( StringList &lInput, StringList &lOutput );
13 15
14private: 16private:
15 17
diff --git a/src/functiontostring.cpp b/src/functiontostring.cpp
index 93a8b56..f5f43b2 100644
--- a/src/functiontostring.cpp
+++ b/src/functiontostring.cpp
@@ -10,3 +10,8 @@ FunctionToString::FunctionToString()
10FunctionToString::~FunctionToString() 10FunctionToString::~FunctionToString()
11{ 11{
12} 12}
13
14void FunctionToString::execute( StringList &lInput, StringList &lOutput )
15{
16}
17
diff --git a/src/functiontostring.h b/src/functiontostring.h
index 08baadd..93bc20f 100644
--- a/src/functiontostring.h
+++ b/src/functiontostring.h
@@ -10,6 +10,8 @@ class FunctionToString : public Function
10public: 10public:
11 FunctionToString(); 11 FunctionToString();
12 virtual ~FunctionToString(); 12 virtual ~FunctionToString();
13
14 virtual void execute( StringList &lInput, StringList &lOutput );
13 15
14private: 16private:
15 17
diff --git a/src/main.cpp b/src/main.cpp
index 9168df7..97c2708 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -85,12 +85,12 @@ int main( int argc, char *argv[] )
85 // return 1; 85 // return 1;
86 //} 86 //}
87 87
88 if( prm.bDebug ) 88 //if( prm.bDebug )
89 { 89 {
90 printf("\n\n----------\nDebug dump\n----------\n"); 90 printf("\n\n----------\nDebug dump\n----------\n");
91 //bld.debug(); 91 bld.debugDump();
92 } 92 }
93 else 93 //else
94 { 94 {
95 //if( prm.sAction > 0 ) 95 //if( prm.sAction > 0 )
96 // bld.build( prm.sAction ); 96 // bld.build( prm.sAction );