aboutsummaryrefslogtreecommitdiff
path: root/src/build.y
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-08-18 17:21:02 +0000
committerMike Buland <eichlan@xagasoft.com>2006-08-18 17:21:02 +0000
commitdf5286fe3bca619beb4771da1ffa8ace9613e9e5 (patch)
tree0ad268267325c586527b8d36461ab0040e9ae8ec /src/build.y
parent4f94dfde7cbe043dfeb11a8712636bac348d3177 (diff)
downloadbuild-df5286fe3bca619beb4771da1ffa8ace9613e9e5.tar.gz
build-df5286fe3bca619beb4771da1ffa8ace9613e9e5.tar.bz2
build-df5286fe3bca619beb4771da1ffa8ace9613e9e5.tar.xz
build-df5286fe3bca619beb4771da1ffa8ace9613e9e5.zip
Gutted, deleted almost all the source, too many changes to keep it around, we'll
see what happens next.
Diffstat (limited to '')
-rw-r--r--src/build.y285
1 files changed, 68 insertions, 217 deletions
diff --git a/src/build.y b/src/build.y
index d1f3945..a624418 100644
--- a/src/build.y
+++ b/src/build.y
@@ -20,268 +20,119 @@ void yyerror( YYLTYPE *locp, Builder &bld, char const *msg );
20%error-verbose 20%error-verbose
21%union { 21%union {
22 char *strval; 22 char *strval;
23 int tval;
23} 24}
24 25
25%token <strval> STRING "string literal" 26%token <strval> STRING "string literal"
26%token <strval> REGEXP "regular expression" 27%token <strval> REGEXP "regular expression"
28%token <tval> TARGETTYPE "target type"
29%token <strval> FUNCTION "function name"
27 30
28%token TOK_ADDSET "+=" 31%token TOK_ADDSET "+="
29%token TOK_DEFAULT "default" 32%token TOK_DEFAULT "default"
30%token TOK_ACTION "action" 33%token TOK_ACTION "action"
31%token TOK_CREATE "create" 34%token TOK_CHECK "check"
32%token TOK_FILE "file" 35%token TOK_CLEAN "clean"
33%token TOK_FROM "from"
34%token TOK_FILES "files"
35%token TOK_IN "in"
36%token TOK_USING "using"
37%token TOK_RULE "rule" 36%token TOK_RULE "rule"
38%token TOK_REQUIRES "requires" 37%token TOK_TARGET "target"
39%token TOK_FOR "for"
40%token TOK_SET "set" 38%token TOK_SET "set"
39%token TOK_INPUT "input"
40%token TOK_FILTER "filter"
41%token TOK_PREFIX "prefix"
42%token TOK_REQUIRES "requires"
41%token TOK_MATCHES "matches" 43%token TOK_MATCHES "matches"
42%token TOK_MATCHING "matching"
43%token TOK_ALL "all"
44%token TOK_ONE "one"
45%token TOK_PERFORM "perform" 44%token TOK_PERFORM "perform"
46%token TOK_PRODUCES "produces" 45%token TOK_PRODUCES "produces"
47%token TOK_COMMAND "command" 46
48%token TOK_CHECK "check"
49%token TOK_CLEAN "clean"
50%token TOK_DIRECTORIES "directories"
51%token TOK_TARGETS "targets"
52%token TOK_EOL "end of line"
53%token ',' ':' '=' 47%token ',' ':' '='
54 48
55%destructor { delete[] $$; } STRING 49%destructor { delete[] $$; } STRING
56 50
57%% 51%%
58 52
53// General input format
59input: 54input:
60 | input fullline 55 | input rule
56 | input action
57 | input target
61 ; 58 ;
62 59
63fullline: TOK_EOL 60// Rule interpretation
64 | line TOK_EOL 61rule: TOK_RULE STRING ':' rulecmds
65 ;
66
67line: TOK_DEFAULT TOK_ACTION ':'
68 {
69 bld.add( new Action() );
70 }
71 actionlst
72 | STRING TOK_ACTION ':'
73 {
74 bld.add( new Action( $1 ) );
75 }
76 actionlst
77 | TOK_FOR fortypes TOK_MATCHING REGEXP
78 {
79 bld.setFilter( $4 );
80 }
81 augments
82 {
83 bld.endList();
84 }
85 listcmds
86 | STRING TOK_REQUIRES
87 {
88 bld.setTmp( $1 );
89 bld.requiresRegexp( false );
90 }
91 reqcompletion
92 | REGEXP TOK_REQUIRES
93 {
94 bld.setTmp( $1 );
95 bld.requiresRegexp( true );
96 }
97 reqcompletion
98 | listcmds
99 | TOK_FOR STRING
100 {
101 bld.startList( STRING );
102 bld.addListItem( $2 );
103 }
104 listcmds
105 {
106
107 }
108 | rule
109 ; 62 ;
110 63
111fortypes: TOK_DIRECTORIES 64rulecmds: rulecmd
112 { 65 | rulecmds ',' rulecmd
113 bld.startList( TOK_DIRECTORIES );
114 }
115 | TOK_TARGETS
116 {
117 bld.startList( TOK_TARGETS );
118 }
119 | TOK_FILES
120 {
121 bld.startList( TOK_FILES );
122 }
123 ;
124
125augments:
126 | TOK_IN STRING
127 {
128 bld.augmentList( $2 );
129 }
130 ; 66 ;
131 67
132reqcompletion: reqlst 68rulecmd: TOK_MATCHES REGEXP
133 | TOK_FROM TOK_COMMAND STRING 69 | TOK_PRODUCES STRING
134 { 70 | TOK_REQUIRES list
135 bld.requiresFromCommand( bld.getTmp(), $3 ); 71 | TOK_INPUT TOK_FILTER REGEXP
136 } 72 | TOK_INPUT TOK_FILTER func
137 ; 73 | TOK_PERFORM func
74 ;
138 75
139reqlst: STRING 76// Action interpretation
140 { 77action: TOK_DEFAULT TOK_ACTION ':' actioncmds
141 bld.requires( bld.getTmp(), $1 ); 78 | STRING TOK_ACTION ':' actioncmds
142 }
143 | reqlst ',' STRING
144 {
145 bld.requires( bld.getTmp(), $3 );
146 }
147 ; 79 ;
148 80
149listcmds: TOK_SET setexpr 81actioncmds: actioncmd
150 | TOK_CREATE createwhat TOK_FROM createfrom TOK_USING createusing 82 | actioncmds ',' actioncmd
151 {
152 bld.endTarget();
153 }
154 ;
155
156createwhat: TOK_FILE STRING
157 {
158 bld.addTarget( TOK_FILE, $2 );
159 }
160 ; 83 ;
161 84
162createfrom: TOK_FILES TOK_IN 85actioncmd: actioncmdtype list
163 { 86 ;
164 bld.setTargetInputType( TOK_FILES );
165 }
166 createfromdirlst
167 ;
168
169createfromdirlst: createfromdir
170 | createfromdirlst ',' createfromdir
171 ;
172 87
173createfromdir: STRING 88actioncmdtype: TOK_CHECK
174 { 89 | TOK_CLEAN
175 bld.addTargetInput( $1 );
176 }
177 ; 90 ;
178 91
179createusing: TOK_RULE STRING 92// Target interpretation
180 {
181 bld.setTargetRule( $2 );
182 }
183 ;
184
185actionlst: action
186 | actionlst ',' action
187 ;
188 93
189action: TOK_CHECK STRING 94target: list ':' targetcmds
190 {
191 bld.add( new Command( Command::cmdCheck, $2 ) );
192 }
193 | TOK_CHECK REGEXP
194 {
195 bld.addRegexCommand( Command::cmdCheck, $2 );
196 }
197 | TOK_CLEAN STRING
198 {
199 bld.add( new Command( Command::cmdClean, $2 ) );
200 }
201 | TOK_CLEAN REGEXP
202 {
203 bld.addRegexCommand( Command::cmdClean, $2 );
204 }
205 ; 95 ;
206 96
207setexpr: STRING '=' STRING 97targetcmds: targetcmd
208 { 98 | targetcmds ',' targetcmd
209 bld.varSet( $1, $3 ); 99 ;
210 } 100
211 | STRING TOK_ADDSET STRING 101targetcmd: TOK_RULE STRING
212 { 102 | TOK_TARGET TOK_PREFIX STRING
213 bld.varAddSet( $1, $3 ); 103 | TOK_TARGET TARGETTYPE
214 } 104 | TOK_INPUT list
215 | STRING '=' TOK_FROM TOK_COMMAND STRING 105 | TOK_REQUIRES list
216 { 106 ;
217 bld.varSet( $1, bld.cmdToString( $5 ).c_str() );
218 }
219 | STRING TOK_ADDSET TOK_FROM TOK_COMMAND STRING
220 {
221 bld.varSet( $1, bld.cmdToString( $5 ).c_str() );
222 }
223 ;
224 107
225rule: TOK_RULE STRING 108// list goo
226 { 109
227 bld.add( new Rule( $2 ) ); 110list: listitem listfilter
228 } 111 | '[' listitems ']' listfilter
229 rulesublst TOK_PERFORM rulecompletion
230 ; 112 ;
231 113
232rulesublst: rulesub 114listfilter:
233 | rulesublst rulesub 115 | TOK_FILTER REGEXP
116 | TOK_FILTER func
234 ; 117 ;
235 118
236rulesub: TOK_MATCHES rulematches 119listitems: listitem
237 | TOK_PRODUCES produceslst 120 | listitems ',' listitem
238 ; 121 ;
239 122
240produceslst: STRING 123listitem: STRING
241 { 124 | func
242 bld.lastRule()->addProduces( $1 ); 125 ;
243 }
244 | produceslst ',' STRING
245 {
246 bld.lastRule()->addProduces( $3 );
247 }
248 ;
249 126
250rulematches: TOK_ALL REGEXP 127// Function
251 {
252 try
253 {
254 bld.lastRule()->setMatches( Rule::matchAll, $2 );
255 }
256 catch( BuildException &e )
257 {
258 std::string s("RegExp compile error: ");
259 s += e.what();
260 yyerror( &yyloc, bld, s.c_str() );
261 return 1;
262 }
263 }
264 | TOK_ONE REGEXP
265 {
266 try
267 {
268 bld.lastRule()->setMatches( Rule::matchOne, $2 );
269 }
270 catch( BuildException &e )
271 {
272 std::string s("RegExp compile error: ");
273 s += e.what();
274 yyerror( &yyloc, bld, s.c_str() );
275 return 1;
276 }
277 }
278 ;
279 128
280rulecompletion: TOK_COMMAND STRING 129func: FUNCTION '(' funcparams ')'
281 { 130 ;
282 bld.lastRule()->setPerforms( Rule::perfCommand, $2 ); 131
283 } 132funcparams:
284 ; 133 | STRING
134 | funcparams ',' STRING
135 ;
285 136
286%% 137%%
287 138