diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-08-22 15:12:20 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-08-22 15:12:20 +0000 |
commit | f5cf5725026ecb2fa63d729fb6745b4da15e69d8 (patch) | |
tree | af48e59cc29dcea1218221dbb6ed9f0cd7f19989 | |
parent | ee98faf71642cf351d5cda241679b094aeec65ce (diff) | |
download | build-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-- | Makefile | 143 | ||||
-rw-r--r-- | build.conf | 1 | ||||
-rw-r--r-- | src/action.cpp | 9 | ||||
-rw-r--r-- | src/action.h | 22 | ||||
-rw-r--r-- | src/build.cpp | 9 | ||||
-rw-r--r-- | src/build.h | 17 | ||||
-rw-r--r-- | src/build.y | 71 | ||||
-rw-r--r-- | src/builder.cpp | 98 | ||||
-rw-r--r-- | src/builder.h | 25 | ||||
-rw-r--r-- | src/function.cpp | 6 | ||||
-rw-r--r-- | src/function.h | 6 | ||||
-rw-r--r-- | src/functioncommandtolist.cpp | 5 | ||||
-rw-r--r-- | src/functioncommandtolist.h | 2 | ||||
-rw-r--r-- | src/functiondirectoriesin.cpp | 5 | ||||
-rw-r--r-- | src/functiondirectoriesin.h | 2 | ||||
-rw-r--r-- | src/functionfilesin.cpp | 5 | ||||
-rw-r--r-- | src/functionfilesin.h | 2 | ||||
-rw-r--r-- | src/functionregexp.cpp | 5 | ||||
-rw-r--r-- | src/functionregexp.h | 2 | ||||
-rw-r--r-- | src/functiontostring.cpp | 5 | ||||
-rw-r--r-- | src/functiontostring.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 6 |
22 files changed, 389 insertions, 59 deletions
@@ -1,54 +1,119 @@ | |||
1 | SRC:=$(wildcard src/*.cpp) | 1 | .PHONY: all clean parser-header lexer-header build-header |
2 | OBJS:=$(patsubst %.cpp,%.o,$(SRC)) | ||
3 | VER:=r$(shell svn info | grep "Revision" | cut -d\ -f2) | ||
4 | LIBS:=bu++ | ||
5 | LIBDIRS:=$(patsubst %,lib%,$(LIBS)) | ||
6 | LIBFILES:=$(foreach dir,$(LIBDIRS),$(dir)/$(dir).a) | ||
7 | DEPFILES:=$(patsubst %.o,%.d,$(OBJS)) | ||
8 | 2 | ||
9 | .PHONY: all clean dist checklibs | 3 | .SILENT: all clean parser-header src/build.tab.c src/build.tab.o parser lexer-header src/build.yy.c src/build.yy.o lexer build-header src/builder.o src/main.o src/perform.o src/performfactory.o src/functionregexp.o src/functioncommandtolist.o src/performcommand.o src/functionfilesin.o src/functionfactory.o src/function.o src/functiontostring.o src/viewer.o src/functiondirectoriesin.o build |
10 | 4 | ||
11 | all: checklibs src/version.h build | 5 | all: parser-header parser lexer-header lexer build-header build |
12 | 6 | ||
13 | checklibs: | 7 | parser-header: |
14 | for ldir in $(LIBDIRS); do make -C $$ldir; done | 8 | echo "--- parser ---" |
15 | 9 | ||
16 | -include $(DEPFILES) | 10 | src/build.tab.c: src/build.y |
11 | echo " comp: src/build.tab.c" | ||
12 | cd src; bison ../src/build.y; cd .. | ||
17 | 13 | ||
18 | src/version.h: .svn | 14 | src/build.tab.o: src/build.tab.c |
19 | echo "#define SVNREV \"$(VER)\"" > src/version.h | 15 | echo " comp: src/build.tab.o" |
16 | g++ -c src/build.tab.c -ggdb -Ilibbu++/src -Isrc -o src/build.tab.o | ||
20 | 17 | ||
21 | %.o: %.cpp %.d | 18 | parser: src/build.tab.o |
22 | g++ -ggdb $(CXXFLAGS) -Isrc $(patsubst %,-I%/src,$(LIBDIRS)) -c -o $@ $< | 19 | echo " stupid: parser" |
20 | |||
23 | 21 | ||
24 | clean: | 22 | lexer-header: |
25 | -rm $(foreach dir,src,$(wildcard $(dir)/*.o)) build src/version.h | 23 | echo |
24 | echo "--- lexer ---" | ||
25 | |||
26 | src/build.yy.c: src/build.l | ||
27 | echo " comp: src/build.yy.c" | ||
28 | flex --bison-bridge --bison-locations -o src/build.yy.c src/build.l | ||
29 | |||
30 | src/build.yy.o: src/build.yy.c | ||
31 | echo " comp: src/build.yy.o" | ||
32 | g++ -c src/build.yy.c -ggdb -Ilibbu++/src -Isrc -o src/build.yy.o | ||
33 | |||
34 | lexer: src/build.yy.o | ||
35 | echo " stupid: lexer" | ||
36 | |||
37 | |||
38 | build-header: | ||
39 | echo | ||
40 | echo "--- build ---" | ||
41 | |||
42 | src/builder.o: src/builder.cpp | ||
43 | echo " comp: src/builder.o" | ||
44 | g++ -c src/builder.cpp -ggdb -Ilibbu++/src -Isrc -o src/builder.o | ||
45 | |||
46 | src/main.o: src/main.cpp | ||
47 | echo " comp: src/main.o" | ||
48 | g++ -c src/main.cpp -ggdb -Ilibbu++/src -Isrc -o src/main.o | ||
26 | 49 | ||
27 | depclean: | 50 | src/perform.o: src/perform.cpp |
28 | -rm $(foreach dir,src src/lib $(TOOLDIRS),$(wildcard $(dir)/*.d)) | 51 | echo " comp: src/perform.o" |
52 | g++ -c src/perform.cpp -ggdb -Ilibbu++/src -Isrc -o src/perform.o | ||
29 | 53 | ||
30 | %.d: %.cpp | 54 | src/performfactory.o: src/performfactory.cpp |
31 | g++ -Isrc -Isrc/lib $(CXXFLAGS) $(patsubst %,-I%/src,$(LIBDIRS)) -M $(CPPFLAGS) $< | sed 's,\($(patsubst src/%,%,$*)\)\.o[:]*,src/\1.o $@:,g' > $@ | 55 | echo " comp: src/performfactory.o" |
56 | g++ -c src/performfactory.cpp -ggdb -Ilibbu++/src -Isrc -o src/performfactory.o | ||
32 | 57 | ||
33 | $(LIBFILES): | 58 | src/functionregexp.o: src/functionregexp.cpp |
34 | make -C $(dir $@) $(notdir $@) | 59 | echo " comp: src/functionregexp.o" |
60 | g++ -c src/functionregexp.cpp -ggdb -Ilibbu++/src -Isrc -o src/functionregexp.o | ||
35 | 61 | ||
36 | test: | 62 | src/functioncommandtolist.o: src/functioncommandtolist.cpp |
37 | -build | 63 | echo " comp: src/functioncommandtolist.o" |
64 | g++ -c src/functioncommandtolist.cpp -ggdb -Ilibbu++/src -Isrc -o src/functioncommandtolist.o | ||
38 | 65 | ||
39 | build: $(LIBFILES) $(OBJS) | 66 | src/performcommand.o: src/performcommand.cpp |
40 | g++ -ggdb $(OBJS) -o build $(patsubst %,-L%,$(LIBDIRS)) $(patsubst %,-l%,$(LIBS)) | 67 | echo " comp: src/performcommand.o" |
68 | g++ -c src/performcommand.cpp -ggdb -Ilibbu++/src -Isrc -o src/performcommand.o | ||
41 | 69 | ||
42 | api: $(LIBSRC) $(TOOLSRC) | 70 | src/functionfilesin.o: src/functionfilesin.cpp |
43 | sed 's/PROJECT_NUMBER.*/PROJECT_NUMBER = $(VER)/' < Doxyfile > Doxyfile.tmp | 71 | echo " comp: src/functionfilesin.o" |
44 | doxygen Doxyfile.tmp | 72 | g++ -c src/functionfilesin.cpp -ggdb -Ilibbu++/src -Isrc -o src/functionfilesin.o |
45 | rm Doxyfile.tmp | ||
46 | make -C api/latex | ||
47 | 73 | ||
48 | dist: clean src/version.h | 74 | src/functionfactory.o: src/functionfactory.cpp |
49 | mkdir build-$(VER) | 75 | echo " comp: src/functionfactory.o" |
50 | cp -a --target-directory=build-$(VER) Makefile src | 76 | g++ -c src/functionfactory.cpp -ggdb -Ilibbu++/src -Isrc -o src/functionfactory.o |
51 | tar --exclude=\.svn -c build-$(VER) | bzip2 -9 > build-$(VER).tar.bz2 | 77 | |
52 | rm -Rf build-$(VER) | 78 | src/function.o: src/function.cpp |
53 | -for dir in $(LIBDIRS); do make -C $$dir dist; done | 79 | echo " comp: src/function.o" |
80 | g++ -c src/function.cpp -ggdb -Ilibbu++/src -Isrc -o src/function.o | ||
81 | |||
82 | src/functiontostring.o: src/functiontostring.cpp | ||
83 | echo " comp: src/functiontostring.o" | ||
84 | g++ -c src/functiontostring.cpp -ggdb -Ilibbu++/src -Isrc -o src/functiontostring.o | ||
85 | |||
86 | src/viewer.o: src/viewer.cpp | ||
87 | echo " comp: src/viewer.o" | ||
88 | g++ -c src/viewer.cpp -ggdb -Ilibbu++/src -Isrc -o src/viewer.o | ||
89 | |||
90 | src/functiondirectoriesin.o: src/functiondirectoriesin.cpp | ||
91 | echo " comp: src/functiondirectoriesin.o" | ||
92 | g++ -c src/functiondirectoriesin.cpp -ggdb -Ilibbu++/src -Isrc -o src/functiondirectoriesin.o | ||
93 | |||
94 | build: src/functionfactory.o src/functiontostring.o src/perform.o src/functiondirectoriesin.o src/viewer.o src/main.o src/performcommand.o src/functionregexp.o src/builder.o src/build.yy.o src/functionfilesin.o src/function.o src/performfactory.o src/functioncommandtolist.o src/build.tab.o | ||
95 | echo " exe: build" | ||
96 | g++ src/functionfactory.o src/functiontostring.o src/perform.o src/functiondirectoriesin.o src/viewer.o src/main.o src/performcommand.o src/functionregexp.o src/builder.o src/build.yy.o src/functionfilesin.o src/function.o src/performfactory.o src/functioncommandtolist.o src/build.tab.o -Llibbu++ -lbu++ -ldl -o build | ||
97 | |||
98 | clean: | ||
99 | -if [ -f src/build.tab.c ] ; then echo " rm: src/build.tab.c" ; rm src/build.tab.c ; fi | ||
100 | -if [ -f src/build.tab.o ] ; then echo " rm: src/build.tab.o" ; rm src/build.tab.o ; fi | ||
101 | -if [ -f parser ] ; then echo " rm: parser" ; rm parser ; fi | ||
102 | -if [ -f src/build.yy.c ] ; then echo " rm: src/build.yy.c" ; rm src/build.yy.c ; fi | ||
103 | -if [ -f src/build.yy.o ] ; then echo " rm: src/build.yy.o" ; rm src/build.yy.o ; fi | ||
104 | -if [ -f lexer ] ; then echo " rm: lexer" ; rm lexer ; fi | ||
105 | -if [ -f src/builder.o ] ; then echo " rm: src/builder.o" ; rm src/builder.o ; fi | ||
106 | -if [ -f src/main.o ] ; then echo " rm: src/main.o" ; rm src/main.o ; fi | ||
107 | -if [ -f src/perform.o ] ; then echo " rm: src/perform.o" ; rm src/perform.o ; fi | ||
108 | -if [ -f src/performfactory.o ] ; then echo " rm: src/performfactory.o" ; rm src/performfactory.o ; fi | ||
109 | -if [ -f src/functionregexp.o ] ; then echo " rm: src/functionregexp.o" ; rm src/functionregexp.o ; fi | ||
110 | -if [ -f src/functioncommandtolist.o ] ; then echo " rm: src/functioncommandtolist.o" ; rm src/functioncommandtolist.o ; fi | ||
111 | -if [ -f src/performcommand.o ] ; then echo " rm: src/performcommand.o" ; rm src/performcommand.o ; fi | ||
112 | -if [ -f src/functionfilesin.o ] ; then echo " rm: src/functionfilesin.o" ; rm src/functionfilesin.o ; fi | ||
113 | -if [ -f src/functionfactory.o ] ; then echo " rm: src/functionfactory.o" ; rm src/functionfactory.o ; fi | ||
114 | -if [ -f src/function.o ] ; then echo " rm: src/function.o" ; rm src/function.o ; fi | ||
115 | -if [ -f src/functiontostring.o ] ; then echo " rm: src/functiontostring.o" ; rm src/functiontostring.o ; fi | ||
116 | -if [ -f src/viewer.o ] ; then echo " rm: src/viewer.o" ; rm src/viewer.o ; fi | ||
117 | -if [ -f src/functiondirectoriesin.o ] ; then echo " rm: src/functiondirectoriesin.o" ; rm src/functiondirectoriesin.o ; fi | ||
118 | -if [ -f build ] ; then echo " rm: build" ; rm build ; fi | ||
54 | 119 | ||
@@ -1,6 +1,7 @@ | |||
1 | # build.conf for build, kind of whacky, eh? | 1 | # build.conf for build, kind of whacky, eh? |
2 | 2 | ||
3 | default action: check "build", check "cleanup" | 3 | default action: check "build", check "cleanup" |
4 | "clean" action: clean ["build", "cleanup"] | ||
4 | 5 | ||
5 | set "CXXFLAGS" += "-ggdb" | 6 | set "CXXFLAGS" += "-ggdb" |
6 | 7 | ||
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 | |||
3 | Action::Action() | ||
4 | { | ||
5 | } | ||
6 | |||
7 | Action::~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 | |||
6 | class Action | ||
7 | { | ||
8 | public: | ||
9 | enum eAction | ||
10 | { | ||
11 | actCheck, | ||
12 | actClean | ||
13 | }; | ||
14 | public: | ||
15 | Action(); | ||
16 | virtual ~Action(); | ||
17 | |||
18 | private: | ||
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 | |||
3 | Build::Build() | ||
4 | { | ||
5 | } | ||
6 | |||
7 | Build::~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 | |||
7 | class Build | ||
8 | { | ||
9 | public: | ||
10 | Build(); | ||
11 | virtual ~Build(); | ||
12 | |||
13 | private: | ||
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" | ||
6 | void yyerror( YYLTYPE *locp, Builder &bld, char const *msg ); | 7 | void 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 |
72 | action: TOK_DEFAULT TOK_ACTION ':' { printf("Default action:\n"); } actioncmds | 73 | action: 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 | ||
76 | actioncmds: actioncmd | 90 | actioncmds: actioncmd |
77 | | actioncmds ',' actioncmd | 91 | | actioncmds ',' actioncmd |
78 | ; | 92 | ; |
79 | 93 | ||
80 | actioncmd: { printf(" "); } actioncmdtype list {printf("\n");} | 94 | actioncmd: 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 | ||
83 | actioncmdtype: TOK_CHECK { printf("check "); } | ||
84 | | TOK_CLEAN { printf("clean "); } | ||
85 | ; | ||
86 | |||
87 | // Target interpretation | 104 | // Target interpretation |
88 | target: list ':' { printf(" are targets:\n"); } targetcmds | 105 | target: 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 |
117 | list: listitem listfilter | 134 | list: singlelistitem listfilter |
118 | | '[' { printf("["); } listitems ']' { printf("]"); } listfilter | 135 | | '[' |
136 | { | ||
137 | bld.newList(); | ||
138 | } | ||
139 | listitems ']' listfilter | ||
119 | ; | 140 | ; |
120 | 141 | ||
121 | listfilter: | 142 | listfilter: |
@@ -123,20 +144,42 @@ listfilter: | |||
123 | ; | 144 | ; |
124 | 145 | ||
125 | listitems: listitem | 146 | listitems: listitem |
126 | | listitems ',' { printf(", "); } listitem | 147 | | listitems ',' listitem |
127 | ; | 148 | ; |
128 | 149 | ||
129 | listitem: STRING { printf("%s", $1 ); } | 150 | listitem: STRING |
151 | { | ||
152 | bld.addListString( $1 ); | ||
153 | } | ||
130 | | func | 154 | | func |
155 | { | ||
156 | bld.addListFunc(); | ||
157 | } | ||
131 | ; | 158 | ; |
132 | 159 | ||
160 | singlelistitem: 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 |
134 | func: FUNCTION { printf("%s(", $1 ); } '(' funcparams ')' { printf(")"); } | 173 | func: FUNCTION |
174 | { | ||
175 | bld.newFunctionCall( $1 ); | ||
176 | } | ||
177 | '(' funcparams ')' | ||
135 | ; | 178 | ; |
136 | 179 | ||
137 | funcparams: | 180 | funcparams: |
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 | ||
6 | subExceptionDef( BuildException ); | 7 | subExceptionDef( BuildException ); |
7 | 8 | ||
@@ -62,11 +63,46 @@ bool Builder::isFunction( const char *sFunc ) | |||
62 | 63 | ||
63 | void Builder::newFunctionCall( const char *sName ) | 64 | void Builder::newFunctionCall( const char *sName ) |
64 | { | 65 | { |
65 | 66 | pTmpFunc = fFunction.instantiate( sName ); | |
66 | } | 67 | } |
67 | 68 | ||
68 | void Builder::addFunctionParam( const char *sParam ) | 69 | void Builder::addFunctionParam( const char *sParam ) |
69 | { | 70 | { |
71 | pTmpFunc->addParam( sParam ); | ||
72 | } | ||
73 | |||
74 | void Builder::newList() | ||
75 | { | ||
76 | lTmp.clear(); | ||
77 | } | ||
78 | |||
79 | void Builder::addListString( const char *str ) | ||
80 | { | ||
81 | lTmp.push_back( BuildListItem(str, NULL) ); | ||
82 | } | ||
83 | |||
84 | void Builder::addListFunc() | ||
85 | { | ||
86 | lTmp.push_back( BuildListItem("", pTmpFunc ) ); | ||
87 | } | ||
88 | |||
89 | StringList 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 | // | ||
127 | void Builder::addAction() | ||
128 | { | ||
129 | lActions.push_back( ActionTmp("", ActionTmpCmdList()) ); | ||
130 | } | ||
131 | |||
132 | void Builder::addAction( const char *sName ) | ||
133 | { | ||
134 | lActions.push_back( ActionTmp(sName, ActionTmpCmdList()) ); | ||
135 | } | ||
136 | |||
137 | void Builder::addCommand( int nType ) | ||
138 | { | ||
139 | lActions.back().second.push_back( ActionTmpCmd( nType, lTmp ) ); | ||
140 | } | ||
141 | |||
142 | // | ||
143 | // Debug | ||
144 | // | ||
145 | void 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 | ||
20 | subExceptionDecl( BuildException ); | 22 | subExceptionDecl( BuildException ); |
21 | 23 | ||
24 | typedef std::list<std::string> StringList; | ||
25 | |||
22 | class Builder | 26 | class Builder |
23 | { | 27 | { |
24 | public: | 28 | public: |
@@ -30,7 +34,6 @@ public: | |||
30 | 34 | ||
31 | void load( const std::string &sFile ); | 35 | void load( const std::string &sFile ); |
32 | 36 | ||
33 | |||
34 | private: | 37 | private: |
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 | |||
77 | private: | ||
78 | BuildList lTmp; | ||
79 | |||
69 | public: // Functions for dealing with rules | 80 | public: // Functions for dealing with rules |
81 | |||
82 | public: // 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 | |||
87 | private: // 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 | |||
94 | public: // 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() | |||
7 | Function::~Function() | 7 | Function::~Function() |
8 | { | 8 | { |
9 | } | 9 | } |
10 | |||
11 | void 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 | ||
7 | class Function | 7 | class 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 | |||
13 | private: | 16 | private: |
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() | |||
10 | FunctionCommandToList::~FunctionCommandToList() | 10 | FunctionCommandToList::~FunctionCommandToList() |
11 | { | 11 | { |
12 | } | 12 | } |
13 | |||
14 | void 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 | |||
10 | public: | 10 | public: |
11 | FunctionCommandToList(); | 11 | FunctionCommandToList(); |
12 | virtual ~FunctionCommandToList(); | 12 | virtual ~FunctionCommandToList(); |
13 | |||
14 | virtual void execute( StringList &lInput, StringList &lOutput ); | ||
13 | 15 | ||
14 | private: | 16 | private: |
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() | |||
10 | FunctionDirectoriesIn::~FunctionDirectoriesIn() | 10 | FunctionDirectoriesIn::~FunctionDirectoriesIn() |
11 | { | 11 | { |
12 | } | 12 | } |
13 | |||
14 | void 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 | |||
10 | public: | 10 | public: |
11 | FunctionDirectoriesIn(); | 11 | FunctionDirectoriesIn(); |
12 | virtual ~FunctionDirectoriesIn(); | 12 | virtual ~FunctionDirectoriesIn(); |
13 | |||
14 | virtual void execute( StringList &lInput, StringList &lOutput ); | ||
13 | 15 | ||
14 | private: | 16 | private: |
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() | |||
10 | FunctionFilesIn::~FunctionFilesIn() | 10 | FunctionFilesIn::~FunctionFilesIn() |
11 | { | 11 | { |
12 | } | 12 | } |
13 | |||
14 | void 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 | |||
10 | public: | 10 | public: |
11 | FunctionFilesIn(); | 11 | FunctionFilesIn(); |
12 | virtual ~FunctionFilesIn(); | 12 | virtual ~FunctionFilesIn(); |
13 | |||
14 | virtual void execute( StringList &lInput, StringList &lOutput ); | ||
13 | 15 | ||
14 | private: | 16 | private: |
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() | |||
10 | FunctionRegexp::~FunctionRegexp() | 10 | FunctionRegexp::~FunctionRegexp() |
11 | { | 11 | { |
12 | } | 12 | } |
13 | |||
14 | void 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 | |||
10 | public: | 10 | public: |
11 | FunctionRegexp(); | 11 | FunctionRegexp(); |
12 | virtual ~FunctionRegexp(); | 12 | virtual ~FunctionRegexp(); |
13 | |||
14 | virtual void execute( StringList &lInput, StringList &lOutput ); | ||
13 | 15 | ||
14 | private: | 16 | private: |
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() | |||
10 | FunctionToString::~FunctionToString() | 10 | FunctionToString::~FunctionToString() |
11 | { | 11 | { |
12 | } | 12 | } |
13 | |||
14 | void 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 | |||
10 | public: | 10 | public: |
11 | FunctionToString(); | 11 | FunctionToString(); |
12 | virtual ~FunctionToString(); | 12 | virtual ~FunctionToString(); |
13 | |||
14 | virtual void execute( StringList &lInput, StringList &lOutput ); | ||
13 | 15 | ||
14 | private: | 16 | private: |
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 ); |