1 | //----------------------------------------------------------- |
---|
2 | // Copyright Christian Arnault LAL-Orsay CNRS |
---|
3 | // arnault@lal.in2p3.fr |
---|
4 | // Modified by garonne@lal.in2p3.fr |
---|
5 | // See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
6 | //----------------------------------------------------------- |
---|
7 | |
---|
8 | #include "cmt_syntax.h" |
---|
9 | #include "cmt.h" |
---|
10 | #include "cmt_symbol.h" |
---|
11 | #include "cmt_constituent.h" |
---|
12 | #include "cmt_pattern.h" |
---|
13 | #include "cmt_error.h" |
---|
14 | #include "cmt_branch.h" |
---|
15 | #include "cmt_error.h" |
---|
16 | #include "cmt_script.h" |
---|
17 | #include "cmt_language.h" |
---|
18 | #include "cmt_project.h" |
---|
19 | #include "cmt_cmtpath_pattern.h" |
---|
20 | |
---|
21 | |
---|
22 | class KwdAction : public Kwd |
---|
23 | { |
---|
24 | public: |
---|
25 | void action (const CmtSystem::cmt_string_vector& words, |
---|
26 | Use* use, |
---|
27 | const cmt_string& file_name, |
---|
28 | int line_number) |
---|
29 | { |
---|
30 | Symbol::action (words, CommandAction, use); |
---|
31 | } |
---|
32 | void action (const CmtSystem::cmt_string_vector& words, |
---|
33 | Project* project, |
---|
34 | const cmt_string& file_name, |
---|
35 | int line_number) |
---|
36 | {} |
---|
37 | }; |
---|
38 | |
---|
39 | class KwdAlias : public Kwd |
---|
40 | { |
---|
41 | public: |
---|
42 | void action (const CmtSystem::cmt_string_vector& words, |
---|
43 | Use* use, |
---|
44 | const cmt_string& file_name, |
---|
45 | int line_number) |
---|
46 | { |
---|
47 | Symbol::action (words, CommandAlias, use); |
---|
48 | } |
---|
49 | void action (const CmtSystem::cmt_string_vector& words, |
---|
50 | Project* project, |
---|
51 | const cmt_string& file_name, |
---|
52 | int line_number) |
---|
53 | {} |
---|
54 | |
---|
55 | }; |
---|
56 | |
---|
57 | class KwdApplication : public Kwd |
---|
58 | { |
---|
59 | public: |
---|
60 | void action (const CmtSystem::cmt_string_vector& words, |
---|
61 | Use* use, |
---|
62 | const cmt_string& file_name, |
---|
63 | int line_number) |
---|
64 | { |
---|
65 | if (use == &(Use::current ())) |
---|
66 | { |
---|
67 | Constituent::action (Application, words); |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | void action (const CmtSystem::cmt_string_vector& words, |
---|
72 | Project* project, |
---|
73 | const cmt_string& file_name, |
---|
74 | int line_number) |
---|
75 | {} |
---|
76 | |
---|
77 | }; |
---|
78 | |
---|
79 | class KwdApplyPattern : public Kwd |
---|
80 | { |
---|
81 | public: |
---|
82 | void action (const CmtSystem::cmt_string_vector& words, |
---|
83 | Use* use, |
---|
84 | const cmt_string& file_name, |
---|
85 | int line_number) |
---|
86 | { |
---|
87 | ApplyPattern::action (words, use); |
---|
88 | } |
---|
89 | void action (const CmtSystem::cmt_string_vector& words, |
---|
90 | Project* project, |
---|
91 | const cmt_string& file_name, |
---|
92 | int line_number) |
---|
93 | {} |
---|
94 | |
---|
95 | }; |
---|
96 | |
---|
97 | class KwdApplyTag : public Kwd |
---|
98 | { |
---|
99 | public: |
---|
100 | void action (const CmtSystem::cmt_string_vector& words, |
---|
101 | Use* use, |
---|
102 | const cmt_string& file_name, |
---|
103 | int line_number) |
---|
104 | { |
---|
105 | Tag::action_apply (words, use); |
---|
106 | } |
---|
107 | void action (const CmtSystem::cmt_string_vector& words, |
---|
108 | Project* project, |
---|
109 | const cmt_string& file_name, |
---|
110 | int line_number) |
---|
111 | { |
---|
112 | action (words, project->get_use(), file_name, line_number); |
---|
113 | } |
---|
114 | |
---|
115 | }; |
---|
116 | |
---|
117 | //---------------------------------------------------------- |
---|
118 | class KwdAuthor : public Kwd |
---|
119 | { |
---|
120 | public: |
---|
121 | void action (const CmtSystem::cmt_string_vector& words, |
---|
122 | Use* use, |
---|
123 | const cmt_string& file_name, |
---|
124 | int line_number) |
---|
125 | { |
---|
126 | use->author_action (words); |
---|
127 | |
---|
128 | } |
---|
129 | void action (const CmtSystem::cmt_string_vector& words, |
---|
130 | Project* project, |
---|
131 | const cmt_string& file_name, |
---|
132 | int line_number) |
---|
133 | { |
---|
134 | cmt_string author; |
---|
135 | project->project_author_action (words); |
---|
136 | } |
---|
137 | }; |
---|
138 | //---------------------------------------------------------- |
---|
139 | |
---|
140 | |
---|
141 | class KwdBranches : public Kwd |
---|
142 | { |
---|
143 | public: |
---|
144 | void action (const CmtSystem::cmt_string_vector& words, |
---|
145 | Use* use, |
---|
146 | const cmt_string& file_name, |
---|
147 | int line_number) |
---|
148 | { |
---|
149 | if (use == &(Use::current ())) |
---|
150 | { |
---|
151 | Branch::action (words); |
---|
152 | } |
---|
153 | } |
---|
154 | void action (const CmtSystem::cmt_string_vector& words, |
---|
155 | Project* project, |
---|
156 | const cmt_string& file_name, |
---|
157 | int line_number) |
---|
158 | {} |
---|
159 | |
---|
160 | }; |
---|
161 | |
---|
162 | class KwdBuildStrategy : public Kwd |
---|
163 | { |
---|
164 | public: |
---|
165 | bool decode (const cmt_string& w, cmt_string& strategy, cmt_string& value) |
---|
166 | { |
---|
167 | bool result = true; |
---|
168 | |
---|
169 | value = w; |
---|
170 | |
---|
171 | /*Symbol* symbol = Symbol::find ("use_strategy"); |
---|
172 | if (symbol != 0) |
---|
173 | { |
---|
174 | cmt_string s = symbol->build_macro_value (); |
---|
175 | Symbol::expand (s); |
---|
176 | cerr <<"# value s: "<<s<<endl; |
---|
177 | } */ |
---|
178 | |
---|
179 | Symbol::expand(value); |
---|
180 | //cerr <<"# value: "<<value<<endl; |
---|
181 | |
---|
182 | if (value == "prototypes") |
---|
183 | { |
---|
184 | strategy = "BuildPrototypes"; |
---|
185 | } |
---|
186 | else if (value == "no_prototypes") |
---|
187 | { |
---|
188 | strategy = "BuildPrototypes"; |
---|
189 | } |
---|
190 | else if ((value == "with_installarea") || (value == "with_install_area")) |
---|
191 | { |
---|
192 | value = "with_installarea"; |
---|
193 | strategy = "InstallArea"; |
---|
194 | } |
---|
195 | else if ((value == "without_installarea") || (value == "without_install_area")) |
---|
196 | { |
---|
197 | value = "without_installarea"; |
---|
198 | strategy = "InstallArea"; |
---|
199 | } |
---|
200 | else |
---|
201 | { |
---|
202 | result = false; |
---|
203 | } |
---|
204 | |
---|
205 | return (result); |
---|
206 | } |
---|
207 | |
---|
208 | void action (const CmtSystem::cmt_string_vector& words, |
---|
209 | Use* use, |
---|
210 | const cmt_string& file_name, |
---|
211 | int line_number) |
---|
212 | { |
---|
213 | |
---|
214 | cmt_string cmtpath; |
---|
215 | cmt_string offset; |
---|
216 | |
---|
217 | use->get_cmtpath_and_offset (cmtpath, offset); |
---|
218 | |
---|
219 | Project* p = Project::find_by_cmtpath (cmtpath); |
---|
220 | |
---|
221 | for (int i = 1; i < words.size (); i++) |
---|
222 | { |
---|
223 | const cmt_string& w = words[i]; |
---|
224 | |
---|
225 | cmt_string strategy; |
---|
226 | cmt_string value; |
---|
227 | |
---|
228 | bool in_error = false; |
---|
229 | |
---|
230 | if (decode (w, strategy, value)) |
---|
231 | { |
---|
232 | |
---|
233 | if (p != 0) p->set_strategy (strategy, value, use->get_package_name ()); |
---|
234 | } |
---|
235 | else |
---|
236 | { |
---|
237 | in_error = true; |
---|
238 | |
---|
239 | CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword"); |
---|
240 | } |
---|
241 | } |
---|
242 | } |
---|
243 | |
---|
244 | void action (const CmtSystem::cmt_string_vector& words, |
---|
245 | Project* project, |
---|
246 | const cmt_string& file_name, |
---|
247 | int line_number) |
---|
248 | { |
---|
249 | // action (words, project->get_use(), file_name, line_number); |
---|
250 | // cerr << project->get_use()->get_strategy ("InstallArea") << endl; |
---|
251 | |
---|
252 | |
---|
253 | for (int i = 1; i < words.size (); i++) |
---|
254 | { |
---|
255 | const cmt_string& w = words[i]; |
---|
256 | |
---|
257 | cmt_string strategy; |
---|
258 | cmt_string value; |
---|
259 | |
---|
260 | bool in_error = false; |
---|
261 | |
---|
262 | if (decode (w, strategy, value)) |
---|
263 | { |
---|
264 | if (project != 0) |
---|
265 | { |
---|
266 | // project->set_strategy (strategy, value, project->get_use()->get_package_name ()); |
---|
267 | project->set_strategy (strategy, value, ""); |
---|
268 | cmt_string s = "build_strategy "; |
---|
269 | s += words[i]; |
---|
270 | s += "\n"; |
---|
271 | bool no_found = true; |
---|
272 | int size = project->m_extra_lines.size (); |
---|
273 | for (int n = 0; n < size; n++) |
---|
274 | { |
---|
275 | if (s==project->m_extra_lines[n]) |
---|
276 | no_found = false; |
---|
277 | } |
---|
278 | if (no_found) |
---|
279 | { |
---|
280 | cmt_string & buffer = project->m_extra_lines.add(); |
---|
281 | buffer = s; |
---|
282 | } |
---|
283 | } |
---|
284 | } |
---|
285 | else |
---|
286 | { |
---|
287 | in_error = true; |
---|
288 | |
---|
289 | CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword"); |
---|
290 | } |
---|
291 | } |
---|
292 | } |
---|
293 | }; |
---|
294 | |
---|
295 | class KwdCleanupScript : public Kwd |
---|
296 | { |
---|
297 | public: |
---|
298 | void action (const CmtSystem::cmt_string_vector& words, |
---|
299 | Use* use, |
---|
300 | const cmt_string& file_name, |
---|
301 | int line_number) |
---|
302 | { |
---|
303 | Script::action (words, CleanupScript, use); |
---|
304 | Symbol::action (words, CommandCleanupScript, use); |
---|
305 | } |
---|
306 | void action (const CmtSystem::cmt_string_vector& words, |
---|
307 | Project* project, |
---|
308 | const cmt_string& file_name, |
---|
309 | int line_number) |
---|
310 | {} |
---|
311 | }; |
---|
312 | |
---|
313 | class KwdCmtPathPattern : public Kwd |
---|
314 | { |
---|
315 | public: |
---|
316 | void action (const CmtSystem::cmt_string_vector& words, |
---|
317 | Use* use, |
---|
318 | const cmt_string& /*file_name*/, |
---|
319 | int /*line_number*/) |
---|
320 | { |
---|
321 | CmtPathPattern::action (words, use); |
---|
322 | } |
---|
323 | void action (const CmtSystem::cmt_string_vector& words, |
---|
324 | Project* project, |
---|
325 | const cmt_string& file_name, |
---|
326 | int line_number) |
---|
327 | {} |
---|
328 | |
---|
329 | }; |
---|
330 | |
---|
331 | class KwdCmtPathPatternRevert : public Kwd |
---|
332 | { |
---|
333 | public: |
---|
334 | void action (const CmtSystem::cmt_string_vector& words, |
---|
335 | Use* use, |
---|
336 | const cmt_string& /*file_name*/, |
---|
337 | int /*line_number*/) |
---|
338 | { |
---|
339 | CmtPathPattern::action (words, use, true); |
---|
340 | } |
---|
341 | |
---|
342 | void action (const CmtSystem::cmt_string_vector& words, |
---|
343 | Project* project, |
---|
344 | const cmt_string& file_name, |
---|
345 | int line_number) |
---|
346 | {} |
---|
347 | }; |
---|
348 | |
---|
349 | class KwdContainer : public Kwd |
---|
350 | { |
---|
351 | public: |
---|
352 | void action (const CmtSystem::cmt_string_vector& words, |
---|
353 | Use* use, |
---|
354 | const cmt_string& file_name, |
---|
355 | int line_number) |
---|
356 | { |
---|
357 | } |
---|
358 | |
---|
359 | void action (const CmtSystem::cmt_string_vector& words, |
---|
360 | Project* project, |
---|
361 | const cmt_string& file_name, |
---|
362 | int line_number) |
---|
363 | { |
---|
364 | project->container_action (words[1], words[2]); |
---|
365 | } |
---|
366 | }; |
---|
367 | |
---|
368 | class KwdDocument : public Kwd |
---|
369 | { |
---|
370 | public: |
---|
371 | void action (const CmtSystem::cmt_string_vector& words, |
---|
372 | Use* use, |
---|
373 | const cmt_string& file_name, |
---|
374 | int line_number) |
---|
375 | { |
---|
376 | if (use == &(Use::current ())) |
---|
377 | { |
---|
378 | Constituent::action (Document, words); |
---|
379 | } |
---|
380 | } |
---|
381 | void action (const CmtSystem::cmt_string_vector& words, |
---|
382 | Project* project, |
---|
383 | const cmt_string& file_name, |
---|
384 | int line_number) |
---|
385 | {} |
---|
386 | |
---|
387 | }; |
---|
388 | |
---|
389 | class KwdEndPrivate : public Kwd |
---|
390 | { |
---|
391 | public: |
---|
392 | void action (const CmtSystem::cmt_string_vector& words, |
---|
393 | Use* use, |
---|
394 | const cmt_string& file_name, |
---|
395 | int line_number) |
---|
396 | { |
---|
397 | if (use != &(Use::current ())) |
---|
398 | { |
---|
399 | use->pop_scope_section (); |
---|
400 | } |
---|
401 | } |
---|
402 | void action (const CmtSystem::cmt_string_vector& words, |
---|
403 | Project* project, |
---|
404 | const cmt_string& file_name, |
---|
405 | int line_number) |
---|
406 | {} |
---|
407 | }; |
---|
408 | |
---|
409 | class KwdEndPublic : public Kwd |
---|
410 | { |
---|
411 | public: |
---|
412 | void action (const CmtSystem::cmt_string_vector& words, |
---|
413 | Use* use, |
---|
414 | const cmt_string& file_name, |
---|
415 | int line_number) |
---|
416 | { |
---|
417 | if (use != &(Use::current ())) |
---|
418 | { |
---|
419 | use->pop_scope_section (); |
---|
420 | } |
---|
421 | } |
---|
422 | void action (const CmtSystem::cmt_string_vector& words, |
---|
423 | Project* project, |
---|
424 | const cmt_string& file_name, |
---|
425 | int line_number) |
---|
426 | {} |
---|
427 | }; |
---|
428 | |
---|
429 | class KwdIgnorePattern : public Kwd |
---|
430 | { |
---|
431 | public: |
---|
432 | void action (const CmtSystem::cmt_string_vector& words, |
---|
433 | Use* use, |
---|
434 | const cmt_string& file_name, |
---|
435 | int line_number) |
---|
436 | { |
---|
437 | IgnorePattern::action (words, use); |
---|
438 | } |
---|
439 | void action (const CmtSystem::cmt_string_vector& words, |
---|
440 | Project* project, |
---|
441 | const cmt_string& file_name, |
---|
442 | int line_number) |
---|
443 | {} |
---|
444 | |
---|
445 | }; |
---|
446 | |
---|
447 | class KwdIncludeDirs : public Kwd |
---|
448 | { |
---|
449 | public: |
---|
450 | void action (const CmtSystem::cmt_string_vector& words, |
---|
451 | Use* use, |
---|
452 | const cmt_string& file_name, |
---|
453 | int line_number) |
---|
454 | { |
---|
455 | Include::action (words, use); |
---|
456 | } |
---|
457 | void action (const CmtSystem::cmt_string_vector& words, |
---|
458 | Project* project, |
---|
459 | const cmt_string& file_name, |
---|
460 | int line_number) |
---|
461 | {} |
---|
462 | |
---|
463 | }; |
---|
464 | |
---|
465 | class KwdIncludePath : public Kwd |
---|
466 | { |
---|
467 | public: |
---|
468 | void action (const CmtSystem::cmt_string_vector& words, |
---|
469 | Use* use, |
---|
470 | const cmt_string& file_name, |
---|
471 | int line_number) |
---|
472 | { |
---|
473 | if (words.size () > 1) |
---|
474 | { |
---|
475 | use->set_include_path (words[1]); |
---|
476 | } |
---|
477 | } |
---|
478 | void action (const CmtSystem::cmt_string_vector& words, |
---|
479 | Project* project, |
---|
480 | const cmt_string& file_name, |
---|
481 | int line_number) |
---|
482 | {} |
---|
483 | |
---|
484 | }; |
---|
485 | |
---|
486 | class KwdLanguage : public Kwd |
---|
487 | { |
---|
488 | public: |
---|
489 | void action (const CmtSystem::cmt_string_vector& words, |
---|
490 | Use* use, |
---|
491 | const cmt_string& file_name, |
---|
492 | int line_number) |
---|
493 | { |
---|
494 | Language::action (words); |
---|
495 | } |
---|
496 | void action (const CmtSystem::cmt_string_vector& words, |
---|
497 | Project* project, |
---|
498 | const cmt_string& file_name, |
---|
499 | int line_number) |
---|
500 | {} |
---|
501 | |
---|
502 | }; |
---|
503 | |
---|
504 | class KwdLibrary : public Kwd |
---|
505 | { |
---|
506 | public: |
---|
507 | void action (const CmtSystem::cmt_string_vector& words, |
---|
508 | Use* use, |
---|
509 | const cmt_string& file_name, |
---|
510 | int line_number) |
---|
511 | { |
---|
512 | if (use == &(Use::current ())) |
---|
513 | { |
---|
514 | Constituent::action (Library, words); |
---|
515 | } |
---|
516 | } |
---|
517 | void action (const CmtSystem::cmt_string_vector& words, |
---|
518 | Project* project, |
---|
519 | const cmt_string& file_name, |
---|
520 | int line_number) |
---|
521 | {} |
---|
522 | }; |
---|
523 | |
---|
524 | class KwdMacro : public Kwd |
---|
525 | { |
---|
526 | public: |
---|
527 | void action (const CmtSystem::cmt_string_vector& words, |
---|
528 | Use* use, |
---|
529 | const cmt_string& file_name, |
---|
530 | int line_number) |
---|
531 | { |
---|
532 | Symbol::action (words, CommandMacro, use); |
---|
533 | } |
---|
534 | void action (const CmtSystem::cmt_string_vector& words, |
---|
535 | Project* project, |
---|
536 | const cmt_string& file_name, |
---|
537 | int line_number) |
---|
538 | { |
---|
539 | action (words, project->get_use(), file_name, line_number); |
---|
540 | } |
---|
541 | }; |
---|
542 | |
---|
543 | class KwdMacroPrepend : public Kwd |
---|
544 | { |
---|
545 | public: |
---|
546 | void action (const CmtSystem::cmt_string_vector& words, |
---|
547 | Use* use, |
---|
548 | const cmt_string& file_name, |
---|
549 | int line_number) |
---|
550 | { |
---|
551 | Symbol::action (words, CommandMacroPrepend, use); |
---|
552 | } |
---|
553 | void action (const CmtSystem::cmt_string_vector& words, |
---|
554 | Project* project, |
---|
555 | const cmt_string& file_name, |
---|
556 | int line_number) |
---|
557 | { |
---|
558 | action (words, project->get_use(), file_name, line_number); |
---|
559 | } |
---|
560 | }; |
---|
561 | |
---|
562 | class KwdMacroAppend : public Kwd |
---|
563 | { |
---|
564 | public: |
---|
565 | void action (const CmtSystem::cmt_string_vector& words, |
---|
566 | Use* use, |
---|
567 | const cmt_string& file_name, |
---|
568 | int line_number) |
---|
569 | { |
---|
570 | Symbol::action (words, CommandMacroAppend, use); |
---|
571 | } |
---|
572 | void action (const CmtSystem::cmt_string_vector& words, |
---|
573 | Project* project, |
---|
574 | const cmt_string& file_name, |
---|
575 | int line_number) |
---|
576 | { |
---|
577 | action (words, project->get_use(), file_name, line_number); |
---|
578 | } |
---|
579 | }; |
---|
580 | |
---|
581 | class KwdMacroRemove : public Kwd |
---|
582 | { |
---|
583 | public: |
---|
584 | void action (const CmtSystem::cmt_string_vector& words, |
---|
585 | Use* use, |
---|
586 | const cmt_string& file_name, |
---|
587 | int line_number) |
---|
588 | { |
---|
589 | Symbol::action (words, CommandMacroRemove, use); |
---|
590 | } |
---|
591 | void action (const CmtSystem::cmt_string_vector& words, |
---|
592 | Project* project, |
---|
593 | const cmt_string& file_name, |
---|
594 | int line_number) |
---|
595 | { |
---|
596 | action (words, project->get_use(), file_name, line_number); |
---|
597 | } |
---|
598 | }; |
---|
599 | |
---|
600 | class KwdMacroRemoveRegexp : public Kwd |
---|
601 | { |
---|
602 | public: |
---|
603 | void action (const CmtSystem::cmt_string_vector& words, |
---|
604 | Use* use, |
---|
605 | const cmt_string& file_name, |
---|
606 | int line_number) |
---|
607 | { |
---|
608 | Symbol::action (words, CommandMacroRemoveRegexp, use); |
---|
609 | } |
---|
610 | void action (const CmtSystem::cmt_string_vector& words, |
---|
611 | Project* project, |
---|
612 | const cmt_string& file_name, |
---|
613 | int line_number) |
---|
614 | |
---|
615 | { |
---|
616 | action (words, project->get_use(), file_name, line_number); |
---|
617 | } |
---|
618 | }; |
---|
619 | |
---|
620 | class KwdMacroRemoveAll : public Kwd |
---|
621 | { |
---|
622 | public: |
---|
623 | void action (const CmtSystem::cmt_string_vector& words, |
---|
624 | Use* use, |
---|
625 | const cmt_string& file_name, |
---|
626 | int line_number) |
---|
627 | { |
---|
628 | Symbol::action (words, CommandMacroRemoveAll, use); |
---|
629 | } |
---|
630 | void action (const CmtSystem::cmt_string_vector& words, |
---|
631 | Project* project, |
---|
632 | const cmt_string& file_name, |
---|
633 | int line_number) |
---|
634 | { |
---|
635 | action (words, project->get_use(), file_name, line_number); |
---|
636 | } |
---|
637 | }; |
---|
638 | |
---|
639 | class KwdMacroRemoveAllRegexp : public Kwd |
---|
640 | { |
---|
641 | public: |
---|
642 | void action (const CmtSystem::cmt_string_vector& words, |
---|
643 | Use* use, |
---|
644 | const cmt_string& file_name, |
---|
645 | int line_number) |
---|
646 | { |
---|
647 | Symbol::action (words, CommandMacroRemoveAllRegexp, use); |
---|
648 | } |
---|
649 | void action (const CmtSystem::cmt_string_vector& words, |
---|
650 | Project* project, |
---|
651 | const cmt_string& file_name, |
---|
652 | int line_number) |
---|
653 | { |
---|
654 | action (words, project->get_use(), file_name, line_number); |
---|
655 | } |
---|
656 | }; |
---|
657 | |
---|
658 | class KwdMakeFragment : public Kwd |
---|
659 | { |
---|
660 | public: |
---|
661 | void action (const CmtSystem::cmt_string_vector& words, |
---|
662 | Use* use, |
---|
663 | const cmt_string& file_name, |
---|
664 | int line_number) |
---|
665 | { |
---|
666 | Fragment::action (words, use); |
---|
667 | } |
---|
668 | void action (const CmtSystem::cmt_string_vector& words, |
---|
669 | Project* project, |
---|
670 | const cmt_string& file_name, |
---|
671 | int line_number) |
---|
672 | {} |
---|
673 | }; |
---|
674 | |
---|
675 | class KwdManager : public Kwd |
---|
676 | { |
---|
677 | public: |
---|
678 | void action (const CmtSystem::cmt_string_vector& words, |
---|
679 | Use* use, |
---|
680 | const cmt_string& file_name, |
---|
681 | int line_number) |
---|
682 | { |
---|
683 | use->manager_action (words); |
---|
684 | } |
---|
685 | void action (const CmtSystem::cmt_string_vector& words, |
---|
686 | Project* project, |
---|
687 | const cmt_string& file_name, |
---|
688 | int line_number) |
---|
689 | {} |
---|
690 | }; |
---|
691 | |
---|
692 | class KwdPackage : public Kwd |
---|
693 | { |
---|
694 | public: |
---|
695 | void action (const CmtSystem::cmt_string_vector& words, |
---|
696 | Use* use, |
---|
697 | const cmt_string& file_name, |
---|
698 | int line_number) |
---|
699 | { |
---|
700 | /* |
---|
701 | if (words.size () > 1) |
---|
702 | { |
---|
703 | if (use == &(Use::current())) |
---|
704 | { |
---|
705 | m_current_package = words[1]; |
---|
706 | build_prefix (m_current_package, m_current_prefix); |
---|
707 | |
---|
708 | if ((use->get_package_name () != "") && |
---|
709 | (use->get_package_name () != m_current_package)) |
---|
710 | { |
---|
711 | if (!m_quiet) |
---|
712 | { |
---|
713 | // cerr << "#CMT> package name mismatch in requirements of " << |
---|
714 | // use->get_package_name () << " " << |
---|
715 | // use->version << " line #" << line_number; |
---|
716 | // cerr << " : " << m_current_package << " versus " << |
---|
717 | // use->get_package_name () << endl; |
---|
718 | } |
---|
719 | } |
---|
720 | |
---|
721 | use->set (m_current_package, |
---|
722 | m_current_version, |
---|
723 | m_current_path, |
---|
724 | "", |
---|
725 | ""); |
---|
726 | |
---|
727 | use->change_path (m_current_path); |
---|
728 | use->style = m_current_style; |
---|
729 | } |
---|
730 | } |
---|
731 | */ |
---|
732 | } |
---|
733 | void action (const CmtSystem::cmt_string_vector& words, |
---|
734 | Project* project, |
---|
735 | const cmt_string& file_name, |
---|
736 | int line_number) |
---|
737 | {} |
---|
738 | }; |
---|
739 | |
---|
740 | class KwdPath : public Kwd |
---|
741 | { |
---|
742 | public: |
---|
743 | void action (const CmtSystem::cmt_string_vector& words, |
---|
744 | Use* use, |
---|
745 | const cmt_string& file_name, |
---|
746 | int line_number) |
---|
747 | { |
---|
748 | Symbol::action (words, CommandPath, use); |
---|
749 | } |
---|
750 | void action (const CmtSystem::cmt_string_vector& words, |
---|
751 | Project* project, |
---|
752 | const cmt_string& file_name, |
---|
753 | int line_number) |
---|
754 | {} |
---|
755 | |
---|
756 | }; |
---|
757 | |
---|
758 | class KwdPathAppend : public Kwd |
---|
759 | { |
---|
760 | public: |
---|
761 | void action (const CmtSystem::cmt_string_vector& words, |
---|
762 | Use* use, |
---|
763 | const cmt_string& file_name, |
---|
764 | int line_number) |
---|
765 | { |
---|
766 | Symbol::action (words, CommandPathAppend, use); |
---|
767 | } |
---|
768 | void action (const CmtSystem::cmt_string_vector& words, |
---|
769 | Project* project, |
---|
770 | const cmt_string& file_name, |
---|
771 | int line_number) |
---|
772 | {} |
---|
773 | }; |
---|
774 | |
---|
775 | class KwdPathPrepend : public Kwd |
---|
776 | { |
---|
777 | public: |
---|
778 | void action (const CmtSystem::cmt_string_vector& words, |
---|
779 | Use* use, |
---|
780 | const cmt_string& file_name, |
---|
781 | int line_number) |
---|
782 | { |
---|
783 | Symbol::action (words, CommandPathPrepend, use); |
---|
784 | } |
---|
785 | void action (const CmtSystem::cmt_string_vector& words, |
---|
786 | Project* project, |
---|
787 | const cmt_string& file_name, |
---|
788 | int line_number) |
---|
789 | {} |
---|
790 | }; |
---|
791 | |
---|
792 | class KwdPathRemove : public Kwd |
---|
793 | { |
---|
794 | public: |
---|
795 | void action (const CmtSystem::cmt_string_vector& words, |
---|
796 | Use* use, |
---|
797 | const cmt_string& file_name, |
---|
798 | int line_number) |
---|
799 | { |
---|
800 | Symbol::action (words, CommandPathRemove, use); |
---|
801 | } |
---|
802 | void action (const CmtSystem::cmt_string_vector& words, |
---|
803 | Project* project, |
---|
804 | const cmt_string& file_name, |
---|
805 | int line_number) |
---|
806 | {} |
---|
807 | }; |
---|
808 | |
---|
809 | class KwdPathRemoveRegexp : public Kwd |
---|
810 | { |
---|
811 | public: |
---|
812 | void action (const CmtSystem::cmt_string_vector& words, |
---|
813 | Use* use, |
---|
814 | const cmt_string& file_name, |
---|
815 | int line_number) |
---|
816 | { |
---|
817 | Symbol::action (words, CommandPathRemoveRegexp, use); |
---|
818 | } |
---|
819 | void action (const CmtSystem::cmt_string_vector& words, |
---|
820 | Project* project, |
---|
821 | const cmt_string& file_name, |
---|
822 | int line_number) |
---|
823 | {} |
---|
824 | }; |
---|
825 | |
---|
826 | class KwdPattern : public Kwd |
---|
827 | { |
---|
828 | public: |
---|
829 | void action (const CmtSystem::cmt_string_vector& words, |
---|
830 | Use* use, |
---|
831 | const cmt_string& file_name, |
---|
832 | int line_number) |
---|
833 | { |
---|
834 | Pattern::action (words, use); |
---|
835 | } |
---|
836 | void action (const CmtSystem::cmt_string_vector& words, |
---|
837 | Project* project, |
---|
838 | const cmt_string& file_name, |
---|
839 | int line_number) |
---|
840 | {} |
---|
841 | }; |
---|
842 | |
---|
843 | class KwdPrivate : public Kwd |
---|
844 | { |
---|
845 | public: |
---|
846 | void action (const CmtSystem::cmt_string_vector& words, |
---|
847 | Use* use, |
---|
848 | const cmt_string& file_name, |
---|
849 | int line_number) |
---|
850 | { |
---|
851 | if (use != &(Use::current ())) |
---|
852 | { |
---|
853 | use->push_scope_section (ScopePrivate); |
---|
854 | } |
---|
855 | } |
---|
856 | void action (const CmtSystem::cmt_string_vector& words, |
---|
857 | Project* project, |
---|
858 | const cmt_string& file_name, |
---|
859 | int line_number) |
---|
860 | {} |
---|
861 | }; |
---|
862 | |
---|
863 | class KwdProject : public Kwd |
---|
864 | { |
---|
865 | public: |
---|
866 | void action (const CmtSystem::cmt_string_vector& words, |
---|
867 | Use* use, |
---|
868 | const cmt_string& file_name, |
---|
869 | int line_number) |
---|
870 | { |
---|
871 | } |
---|
872 | |
---|
873 | void action (const CmtSystem::cmt_string_vector& words, |
---|
874 | Project* project, |
---|
875 | const cmt_string& file_name, |
---|
876 | int line_number) |
---|
877 | { |
---|
878 | } |
---|
879 | }; |
---|
880 | |
---|
881 | class KwdPublic : public Kwd |
---|
882 | { |
---|
883 | public: |
---|
884 | void action (const CmtSystem::cmt_string_vector& words, |
---|
885 | Use* use, |
---|
886 | const cmt_string& file_name, |
---|
887 | int line_number) |
---|
888 | { |
---|
889 | if (use != &(Use::current ())) |
---|
890 | { |
---|
891 | use->push_scope_section (ScopePublic); |
---|
892 | } |
---|
893 | } |
---|
894 | void action (const CmtSystem::cmt_string_vector& words, |
---|
895 | Project* project, |
---|
896 | const cmt_string& file_name, |
---|
897 | int line_number) |
---|
898 | {} |
---|
899 | }; |
---|
900 | |
---|
901 | class KwdSet : public Kwd |
---|
902 | { |
---|
903 | public: |
---|
904 | void action (const CmtSystem::cmt_string_vector& words, |
---|
905 | Use* use, |
---|
906 | const cmt_string& file_name, |
---|
907 | int line_number) |
---|
908 | { |
---|
909 | Symbol::action (words, CommandSet, use); |
---|
910 | } |
---|
911 | void action (const CmtSystem::cmt_string_vector& words, |
---|
912 | Project* project, |
---|
913 | const cmt_string& file_name, |
---|
914 | int line_number) |
---|
915 | {} |
---|
916 | }; |
---|
917 | |
---|
918 | class KwdSetAppend : public Kwd |
---|
919 | { |
---|
920 | public: |
---|
921 | void action (const CmtSystem::cmt_string_vector& words, |
---|
922 | Use* use, |
---|
923 | const cmt_string& file_name, |
---|
924 | int line_number) |
---|
925 | { |
---|
926 | Symbol::action (words, CommandSetAppend, use); |
---|
927 | } |
---|
928 | void action (const CmtSystem::cmt_string_vector& words, |
---|
929 | Project* project, |
---|
930 | const cmt_string& file_name, |
---|
931 | int line_number) |
---|
932 | {} |
---|
933 | }; |
---|
934 | |
---|
935 | class KwdSetPrepend : public Kwd |
---|
936 | { |
---|
937 | public: |
---|
938 | void action (const CmtSystem::cmt_string_vector& words, |
---|
939 | Use* use, |
---|
940 | const cmt_string& file_name, |
---|
941 | int line_number) |
---|
942 | { |
---|
943 | Symbol::action (words, CommandSetPrepend, use); |
---|
944 | } |
---|
945 | void action (const CmtSystem::cmt_string_vector& words, |
---|
946 | Project* project, |
---|
947 | const cmt_string& file_name, |
---|
948 | int line_number) |
---|
949 | {} |
---|
950 | }; |
---|
951 | |
---|
952 | class KwdSetRemove : public Kwd |
---|
953 | { |
---|
954 | public: |
---|
955 | void action (const CmtSystem::cmt_string_vector& words, |
---|
956 | Use* use, |
---|
957 | const cmt_string& file_name, |
---|
958 | int line_number) |
---|
959 | { |
---|
960 | Symbol::action (words, CommandSetRemove, use); |
---|
961 | } |
---|
962 | void action (const CmtSystem::cmt_string_vector& words, |
---|
963 | Project* project, |
---|
964 | const cmt_string& file_name, |
---|
965 | int line_number) |
---|
966 | {} |
---|
967 | }; |
---|
968 | |
---|
969 | class KwdSetRemoveRegexp : public Kwd |
---|
970 | { |
---|
971 | public: |
---|
972 | void action (const CmtSystem::cmt_string_vector& words, |
---|
973 | Use* use, |
---|
974 | const cmt_string& file_name, |
---|
975 | int line_number) |
---|
976 | { |
---|
977 | Symbol::action (words, CommandSetRemoveRegexp, use); |
---|
978 | } |
---|
979 | void action (const CmtSystem::cmt_string_vector& words, |
---|
980 | Project* project, |
---|
981 | const cmt_string& file_name, |
---|
982 | int line_number) |
---|
983 | {} |
---|
984 | }; |
---|
985 | |
---|
986 | class KwdSetupScript : public Kwd |
---|
987 | { |
---|
988 | public: |
---|
989 | void action (const CmtSystem::cmt_string_vector& words, |
---|
990 | Use* use, |
---|
991 | const cmt_string& file_name, |
---|
992 | int line_number) |
---|
993 | { |
---|
994 | Script::action (words, SetupScript, use); |
---|
995 | Symbol::action (words, CommandSetupScript, use); |
---|
996 | } |
---|
997 | void action (const CmtSystem::cmt_string_vector& words, |
---|
998 | Project* project, |
---|
999 | const cmt_string& file_name, |
---|
1000 | int line_number) |
---|
1001 | {} |
---|
1002 | }; |
---|
1003 | |
---|
1004 | class KwdSetupStrategy : public Kwd |
---|
1005 | { |
---|
1006 | public: |
---|
1007 | bool decode (const cmt_string& w, cmt_string& strategy, cmt_string& value) |
---|
1008 | { |
---|
1009 | bool result = true; |
---|
1010 | |
---|
1011 | value = w; |
---|
1012 | Symbol::expand(value); |
---|
1013 | |
---|
1014 | |
---|
1015 | if (value == "config") |
---|
1016 | { |
---|
1017 | strategy = "SetupConfig"; |
---|
1018 | } |
---|
1019 | else if (value == "no_config") |
---|
1020 | { |
---|
1021 | strategy = "SetupConfig"; |
---|
1022 | } |
---|
1023 | else if (value == "root") |
---|
1024 | { |
---|
1025 | strategy = "SetupRoot"; |
---|
1026 | } |
---|
1027 | else if (value == "no_root") |
---|
1028 | { |
---|
1029 | strategy = "SetupRoot"; |
---|
1030 | } |
---|
1031 | else if (value == "cleanup") |
---|
1032 | { |
---|
1033 | strategy = "SetupCleanup"; |
---|
1034 | } |
---|
1035 | else if (value == "no_cleanup") |
---|
1036 | { |
---|
1037 | strategy = "SetupCleanup"; |
---|
1038 | } |
---|
1039 | else |
---|
1040 | { |
---|
1041 | result = false; |
---|
1042 | } |
---|
1043 | |
---|
1044 | return (result); |
---|
1045 | } |
---|
1046 | |
---|
1047 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1048 | Use* use, |
---|
1049 | const cmt_string& file_name, |
---|
1050 | int line_number) |
---|
1051 | { |
---|
1052 | cmt_string cmtpath; |
---|
1053 | cmt_string offset; |
---|
1054 | |
---|
1055 | use->get_cmtpath_and_offset (cmtpath, offset); |
---|
1056 | |
---|
1057 | Project* p = Project::find_by_cmtpath (cmtpath); |
---|
1058 | |
---|
1059 | for (int i = 1; i < words.size (); i++) |
---|
1060 | { |
---|
1061 | const cmt_string& w = words[i]; |
---|
1062 | |
---|
1063 | cmt_string strategy; |
---|
1064 | cmt_string value; |
---|
1065 | |
---|
1066 | bool in_error = false; |
---|
1067 | |
---|
1068 | if (decode (w, strategy, value)) |
---|
1069 | { |
---|
1070 | if (p != 0) p->set_strategy (strategy, value, use->get_package_name ()); |
---|
1071 | } |
---|
1072 | else |
---|
1073 | { |
---|
1074 | in_error = true; |
---|
1075 | |
---|
1076 | CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword"); |
---|
1077 | } |
---|
1078 | } |
---|
1079 | } |
---|
1080 | |
---|
1081 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1082 | Project* project, |
---|
1083 | const cmt_string& file_name, |
---|
1084 | int line_number) |
---|
1085 | { |
---|
1086 | for (int i = 1; i < words.size (); i++) |
---|
1087 | { |
---|
1088 | const cmt_string& w = words[i]; |
---|
1089 | |
---|
1090 | cmt_string strategy; |
---|
1091 | cmt_string value; |
---|
1092 | |
---|
1093 | bool in_error = false; |
---|
1094 | |
---|
1095 | if (decode (w, strategy, value)) |
---|
1096 | { |
---|
1097 | if (project != 0) project->set_strategy (strategy, value, ""); |
---|
1098 | cmt_string s = "setup_strategy "; |
---|
1099 | s += words[i]; |
---|
1100 | s += "\n"; |
---|
1101 | |
---|
1102 | bool no_found = true; |
---|
1103 | int size = project->m_extra_lines.size (); |
---|
1104 | for (int n = 0; n < size; n++) |
---|
1105 | { |
---|
1106 | if (s==project->m_extra_lines[n]) |
---|
1107 | no_found = false; |
---|
1108 | } |
---|
1109 | if (no_found) |
---|
1110 | { |
---|
1111 | cmt_string & buffer = project->m_extra_lines.add(); |
---|
1112 | buffer = s; |
---|
1113 | } |
---|
1114 | } |
---|
1115 | else |
---|
1116 | { |
---|
1117 | in_error = true; |
---|
1118 | |
---|
1119 | CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword"); |
---|
1120 | } |
---|
1121 | } |
---|
1122 | } |
---|
1123 | }; |
---|
1124 | |
---|
1125 | class KwdStructureStrategy : public Kwd |
---|
1126 | { |
---|
1127 | public: |
---|
1128 | bool decode (const cmt_string& w, cmt_string& strategy, cmt_string& value) |
---|
1129 | { |
---|
1130 | bool result = true; |
---|
1131 | |
---|
1132 | value = w; |
---|
1133 | Symbol::expand(value); |
---|
1134 | |
---|
1135 | if (value == "with_version_directory") |
---|
1136 | { |
---|
1137 | strategy = "VersionDirectory"; |
---|
1138 | } |
---|
1139 | else if (value == "without_version_directory") |
---|
1140 | { |
---|
1141 | strategy = "VersionDirectory"; |
---|
1142 | } |
---|
1143 | else |
---|
1144 | { |
---|
1145 | result = false; |
---|
1146 | } |
---|
1147 | |
---|
1148 | return (result); |
---|
1149 | } |
---|
1150 | |
---|
1151 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1152 | Use* use, |
---|
1153 | const cmt_string& file_name, |
---|
1154 | int line_number) |
---|
1155 | { |
---|
1156 | cmt_string cmtpath; |
---|
1157 | cmt_string offset; |
---|
1158 | |
---|
1159 | use->get_cmtpath_and_offset (cmtpath, offset); |
---|
1160 | |
---|
1161 | Project* p = Project::find_by_cmtpath (cmtpath); |
---|
1162 | |
---|
1163 | for (int i = 1; i < words.size (); i++) |
---|
1164 | { |
---|
1165 | const cmt_string& w = words[i]; |
---|
1166 | |
---|
1167 | cmt_string strategy; |
---|
1168 | cmt_string value; |
---|
1169 | |
---|
1170 | bool in_error = false; |
---|
1171 | |
---|
1172 | if (decode (w, strategy, value)) |
---|
1173 | { |
---|
1174 | if (p != 0) p->set_strategy (strategy, value, use->get_package_name ()); |
---|
1175 | } |
---|
1176 | else |
---|
1177 | { |
---|
1178 | in_error = true; |
---|
1179 | |
---|
1180 | CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword"); |
---|
1181 | } |
---|
1182 | } |
---|
1183 | } |
---|
1184 | |
---|
1185 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1186 | Project* project, |
---|
1187 | const cmt_string& file_name, |
---|
1188 | int line_number) |
---|
1189 | { |
---|
1190 | for (int i = 1; i < words.size (); i++) |
---|
1191 | { |
---|
1192 | const cmt_string& w = words[i]; |
---|
1193 | |
---|
1194 | cmt_string strategy; |
---|
1195 | cmt_string value; |
---|
1196 | |
---|
1197 | bool in_error = false; |
---|
1198 | |
---|
1199 | if (decode (w, strategy, value)) |
---|
1200 | { |
---|
1201 | if (project != 0) project->set_strategy (strategy, value, ""); |
---|
1202 | cmt_string s = "structure_strategy "; |
---|
1203 | s += words[i]; |
---|
1204 | s += "\n"; |
---|
1205 | |
---|
1206 | bool no_found = true; |
---|
1207 | int size = project->m_extra_lines.size (); |
---|
1208 | for (int n = 0; n < size; n++) |
---|
1209 | { |
---|
1210 | if (s == project->m_extra_lines[n]) |
---|
1211 | no_found = false; |
---|
1212 | } |
---|
1213 | |
---|
1214 | if (no_found) |
---|
1215 | { |
---|
1216 | cmt_string & buffer = project->m_extra_lines.add(); |
---|
1217 | buffer = s; |
---|
1218 | } |
---|
1219 | } |
---|
1220 | else |
---|
1221 | { |
---|
1222 | in_error = true; |
---|
1223 | |
---|
1224 | CmtError::set (CmtError::syntax_error, "ParseRequirements> bad strategy keyword"); |
---|
1225 | } |
---|
1226 | } |
---|
1227 | } |
---|
1228 | }; |
---|
1229 | |
---|
1230 | class KwdTag : public Kwd |
---|
1231 | { |
---|
1232 | public: |
---|
1233 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1234 | Use* use, |
---|
1235 | const cmt_string& file_name, |
---|
1236 | int line_number) |
---|
1237 | { |
---|
1238 | Tag::action (words, use); |
---|
1239 | } |
---|
1240 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1241 | Project* project, |
---|
1242 | const cmt_string& file_name, |
---|
1243 | int line_number) |
---|
1244 | { |
---|
1245 | action (words, project->get_use(), file_name, line_number); |
---|
1246 | } |
---|
1247 | }; |
---|
1248 | |
---|
1249 | class KwdTagExclude : public Kwd |
---|
1250 | { |
---|
1251 | public: |
---|
1252 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1253 | Use* use, |
---|
1254 | const cmt_string& file_name, |
---|
1255 | int line_number) |
---|
1256 | { |
---|
1257 | Tag::action_exclude (words, use); |
---|
1258 | } |
---|
1259 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1260 | Project* project, |
---|
1261 | const cmt_string& file_name, |
---|
1262 | int line_number) |
---|
1263 | { |
---|
1264 | action (words, project->get_use(), file_name, line_number); |
---|
1265 | } |
---|
1266 | }; |
---|
1267 | |
---|
1268 | class KwdUse : public Kwd |
---|
1269 | { |
---|
1270 | public: |
---|
1271 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1272 | Use* use, |
---|
1273 | const cmt_string& file_name, |
---|
1274 | int line_number) |
---|
1275 | { |
---|
1276 | Use::action (words, use); |
---|
1277 | } |
---|
1278 | |
---|
1279 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1280 | Project* project, |
---|
1281 | const cmt_string& file_name, |
---|
1282 | int line_number) |
---|
1283 | { |
---|
1284 | project->use_action (words[1], words[2]); |
---|
1285 | } |
---|
1286 | }; |
---|
1287 | |
---|
1288 | class KwdVersionStrategy : public Kwd |
---|
1289 | { |
---|
1290 | public: |
---|
1291 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1292 | Use* use, |
---|
1293 | const cmt_string& file_name, |
---|
1294 | int line_number) |
---|
1295 | { |
---|
1296 | cerr << "# Package " << use->get_package_name () << |
---|
1297 | " sets obsolescent version strategy" << endl; |
---|
1298 | } |
---|
1299 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1300 | Project* project, |
---|
1301 | const cmt_string& file_name, |
---|
1302 | int line_number) |
---|
1303 | {} |
---|
1304 | }; |
---|
1305 | |
---|
1306 | class KwdVersion : public Kwd |
---|
1307 | { |
---|
1308 | public: |
---|
1309 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1310 | Use* use, |
---|
1311 | const cmt_string& file_name, |
---|
1312 | int line_number) |
---|
1313 | { |
---|
1314 | } |
---|
1315 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1316 | Project* project, |
---|
1317 | const cmt_string& file_name, |
---|
1318 | int line_number) |
---|
1319 | {} |
---|
1320 | }; |
---|
1321 | |
---|
1322 | class KwdDefault : public Kwd |
---|
1323 | { |
---|
1324 | public: |
---|
1325 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1326 | Use* use, |
---|
1327 | const cmt_string& file_name, |
---|
1328 | int line_number) |
---|
1329 | { |
---|
1330 | /* |
---|
1331 | Unknown keyword : just ignore the line |
---|
1332 | */ |
---|
1333 | if (!Cmt::get_quiet ()) |
---|
1334 | { |
---|
1335 | cerr << "#CMT> bad syntax in requirements of " << use->get_package_name () |
---|
1336 | << " " << use->version << " line #" << line_number; |
---|
1337 | cerr << " [" << words[0] << "...]" << endl; |
---|
1338 | } |
---|
1339 | |
---|
1340 | CmtError::set (CmtError::syntax_error, "ParseRequirements> "); |
---|
1341 | } |
---|
1342 | |
---|
1343 | void action (const CmtSystem::cmt_string_vector& words, |
---|
1344 | Project* project, |
---|
1345 | const cmt_string& file_name, |
---|
1346 | int line_number) |
---|
1347 | {action (words, project->get_use(), file_name, line_number);} |
---|
1348 | }; |
---|
1349 | |
---|
1350 | SyntaxParser& SyntaxParser::instance () |
---|
1351 | { |
---|
1352 | static SyntaxParser p; |
---|
1353 | |
---|
1354 | return (p); |
---|
1355 | } |
---|
1356 | |
---|
1357 | /** |
---|
1358 | * Parse the input file, rejecting comments and |
---|
1359 | * rebuilding complete lines (from sections separated by |
---|
1360 | * \\ characters. |
---|
1361 | * |
---|
1362 | * Each reformatted line is parsed by filter_line |
---|
1363 | */ |
---|
1364 | void SyntaxParser::parse_requirements (const cmt_string& file_name, Use* use) |
---|
1365 | { |
---|
1366 | SyntaxParser& me = instance (); |
---|
1367 | |
---|
1368 | if (use != 0) |
---|
1369 | { |
---|
1370 | cmt_string buffer; |
---|
1371 | |
---|
1372 | use->fill_standard_macros (buffer); |
---|
1373 | |
---|
1374 | AccessMode saved_current_access = Cmt::get_current_access (); |
---|
1375 | Cmt::set_current_access (UserMode); |
---|
1376 | me.do_parse_text (buffer, "", package_context, use, 0); |
---|
1377 | Cmt::set_current_access (saved_current_access); |
---|
1378 | } |
---|
1379 | |
---|
1380 | me.do_parse_requirements (file_name, use); |
---|
1381 | |
---|
1382 | |
---|
1383 | if (use != 0) |
---|
1384 | { |
---|
1385 | // |
---|
1386 | |
---|
1387 | Project* p = use->get_project (); |
---|
1388 | if (p != 0) |
---|
1389 | { |
---|
1390 | Use* p_use = p->get_use(); |
---|
1391 | if (p_use != 0 && p_use != use) |
---|
1392 | { |
---|
1393 | |
---|
1394 | //{ |
---|
1395 | // int size = use->sub_uses.size (); |
---|
1396 | // for (int n = 0; n < size; n++) |
---|
1397 | // { |
---|
1398 | // Use* tuse = use->sub_uses[n]; |
---|
1399 | // cerr << "\tpackage file [" << tuse->get_package_name() << "]" <<p_use->get_package_name()<< endl; |
---|
1400 | // } |
---|
1401 | //} |
---|
1402 | |
---|
1403 | // add the dependency |
---|
1404 | use->add_sub_use (p_use); |
---|
1405 | |
---|
1406 | // add the right extra statements |
---|
1407 | { |
---|
1408 | int size = p->m_extra_lines.size (); |
---|
1409 | for (int n = 0; n < size; n++) |
---|
1410 | { |
---|
1411 | cmt_string& s = p->m_extra_lines[n]; |
---|
1412 | SyntaxParser::parse_requirements_line (s, use); |
---|
1413 | } |
---|
1414 | } |
---|
1415 | |
---|
1416 | // Fill other values |
---|
1417 | use->sub_use_scopes.push_back (use->get_current_scope ()); |
---|
1418 | use->sub_use_auto_imports.push_back (p_use->auto_imports); |
---|
1419 | // cmt_string& request = use->requests.add (); |
---|
1420 | // request = package_name; |
---|
1421 | // request += " "; |
---|
1422 | // request += version; |
---|
1423 | // request += " "; |
---|
1424 | // request += path; |
---|
1425 | |
---|
1426 | // add at the uses level ????? |
---|
1427 | static Use::UsePtrVector& uses = Use::get_ordered_uses (); |
---|
1428 | //const Use& cu = Use::current (); |
---|
1429 | |
---|
1430 | bool found = false; |
---|
1431 | int size = uses.size (); |
---|
1432 | |
---|
1433 | // cerr << "\n size:"<<size<< ":" << endl; |
---|
1434 | for (int n = 0; n < size; n++) |
---|
1435 | { |
---|
1436 | Use* tuse = uses[n]; |
---|
1437 | // cerr << "\tpackage file [" << tuse->get_package_name() << "]" <<p_use->get_package_name()<< endl; |
---|
1438 | if (tuse->get_package_name()==p_use->get_package_name()) |
---|
1439 | found=true; |
---|
1440 | } |
---|
1441 | if (! found) |
---|
1442 | { |
---|
1443 | uses.push_back (p_use); |
---|
1444 | p_use->m_index = uses.size () - 1; |
---|
1445 | } |
---|
1446 | |
---|
1447 | } |
---|
1448 | } |
---|
1449 | use->close_scope_sections (); |
---|
1450 | } |
---|
1451 | } |
---|
1452 | |
---|
1453 | /** |
---|
1454 | */ |
---|
1455 | void SyntaxParser::parse_project_file_text (const cmt_string& text, |
---|
1456 | const cmt_string& file_name, |
---|
1457 | Project* project) |
---|
1458 | { |
---|
1459 | SyntaxParser& me = instance (); |
---|
1460 | me.do_parse_text (text, file_name, project_context, 0, project); |
---|
1461 | } |
---|
1462 | |
---|
1463 | /** |
---|
1464 | * Parse a text, rejecting comments and |
---|
1465 | * rebuilding complete lines (from sections separated by |
---|
1466 | * \\ characters. |
---|
1467 | * |
---|
1468 | * Each reformatted line is parsed by filter_line |
---|
1469 | */ |
---|
1470 | void SyntaxParser::parse_requirements_text (const cmt_string& text, |
---|
1471 | const cmt_string& file_name, |
---|
1472 | Use* use) |
---|
1473 | { |
---|
1474 | SyntaxParser& me = instance (); |
---|
1475 | |
---|
1476 | /** |
---|
1477 | * |
---|
1478 | * We have to preserve m_current_access since it reflects whether |
---|
1479 | * the current cmt action is run in the context of the current package. |
---|
1480 | * (the opposite is when the cmt command specifies the current package |
---|
1481 | * in its arguments -use=... therefore the pwd is NOT the directory |
---|
1482 | * of the current package) |
---|
1483 | * |
---|
1484 | * m_current_access is Developer when pwd = current |
---|
1485 | * User when pwd != current |
---|
1486 | * |
---|
1487 | * Therefore, as soon as we reach a used package, this must be switched to User |
---|
1488 | * |
---|
1489 | * On the other hand, Cmt::scope reflects the status of the public/private |
---|
1490 | * statements. By default, we are in public context when entering a new requirements |
---|
1491 | * file. |
---|
1492 | * |
---|
1493 | */ |
---|
1494 | |
---|
1495 | AccessMode saved_current_access; |
---|
1496 | |
---|
1497 | saved_current_access = Cmt::get_current_access (); |
---|
1498 | |
---|
1499 | if (use == 0) use = &(Use::current ()); |
---|
1500 | |
---|
1501 | if (use != &(Use::current ())) |
---|
1502 | { |
---|
1503 | if (Cmt::get_debug ()) |
---|
1504 | { |
---|
1505 | cout << "parse_requirements_text> set UserMode" << endl; |
---|
1506 | } |
---|
1507 | |
---|
1508 | Cmt::set_current_access (UserMode); |
---|
1509 | } |
---|
1510 | else |
---|
1511 | { |
---|
1512 | if (Cmt::get_debug ()) |
---|
1513 | { |
---|
1514 | cout << "parse_requirements_text> set DeveloperMode" << endl; |
---|
1515 | } |
---|
1516 | |
---|
1517 | Cmt::set_current_access (DeveloperMode); |
---|
1518 | } |
---|
1519 | |
---|
1520 | me.do_parse_text (text, file_name, package_context, use, 0); |
---|
1521 | |
---|
1522 | Cmt::set_current_access (saved_current_access); |
---|
1523 | } |
---|
1524 | |
---|
1525 | /** |
---|
1526 | * Apply the basic parser to one single line : |
---|
1527 | * |
---|
1528 | * o Append to global text if previous back_slash |
---|
1529 | * o Split into words |
---|
1530 | * o Apply the generic Select operator |
---|
1531 | */ |
---|
1532 | void SyntaxParser::parse_requirements_line (const cmt_string& line, |
---|
1533 | Use* use, |
---|
1534 | const cmt_string& file_name, |
---|
1535 | int line_number) |
---|
1536 | { |
---|
1537 | SyntaxParser& me = instance (); |
---|
1538 | me.do_parse_line (line, file_name, line_number, package_context, use, 0); |
---|
1539 | } |
---|
1540 | |
---|
1541 | SyntaxParser::SyntaxParser () |
---|
1542 | { |
---|
1543 | m_keywords.add ("action", new KwdAction ()); |
---|
1544 | m_keywords.add ("alias", new KwdAlias ()); |
---|
1545 | m_keywords.add ("application", new KwdApplication ()); |
---|
1546 | m_keywords.add ("apply_pattern", new KwdApplyPattern ()); |
---|
1547 | m_keywords.add ("apply_tag", new KwdApplyTag ()); |
---|
1548 | m_keywords.add ("author", new KwdAuthor ()); |
---|
1549 | m_keywords.add ("branches", new KwdBranches ()); |
---|
1550 | m_keywords.add ("build_strategy", new KwdBuildStrategy ()); |
---|
1551 | m_keywords.add ("cleanup_script", new KwdCleanupScript ()); |
---|
1552 | m_keywords.add ("cmtpath_pattern", new KwdCmtPathPattern ()); |
---|
1553 | m_keywords.add ("cmtpath_pattern_reverse", new KwdCmtPathPatternRevert ()); |
---|
1554 | m_keywords.add ("document", new KwdDocument ()); |
---|
1555 | m_keywords.add ("end_private", new KwdEndPrivate ()); |
---|
1556 | m_keywords.add ("end_public", new KwdEndPublic ()); |
---|
1557 | m_keywords.add ("ignore_pattern", new KwdIgnorePattern ()); |
---|
1558 | m_keywords.add ("include_dirs", new KwdIncludeDirs ()); |
---|
1559 | m_keywords.add ("include_path", new KwdIncludePath ()); |
---|
1560 | m_keywords.add ("language", new KwdLanguage ()); |
---|
1561 | m_keywords.add ("library", new KwdLibrary ()); |
---|
1562 | m_keywords.add ("macro", new KwdMacro ()); |
---|
1563 | m_keywords.add ("macro+", new KwdMacroAppend ()); |
---|
1564 | m_keywords.add ("macro_prepend", new KwdMacroPrepend ()); |
---|
1565 | m_keywords.add ("macro_append", new KwdMacroAppend ()); |
---|
1566 | m_keywords.add ("macro_remove", new KwdMacroRemove ()); |
---|
1567 | m_keywords.add ("macro_remove_regexp", new KwdMacroRemoveRegexp ()); |
---|
1568 | m_keywords.add ("macro_remove_all", new KwdMacroRemoveAll ()); |
---|
1569 | m_keywords.add ("macro_remove_all_regexp", new KwdMacroRemoveAllRegexp ()); |
---|
1570 | m_keywords.add ("make_fragment", new KwdMakeFragment ()); |
---|
1571 | m_keywords.add ("manager", new KwdManager ()); |
---|
1572 | m_keywords.add ("package", new KwdPackage ()); |
---|
1573 | m_keywords.add ("path", new KwdPath ()); |
---|
1574 | m_keywords.add ("path_append", new KwdPathAppend ()); |
---|
1575 | m_keywords.add ("path_prepend", new KwdPathPrepend ()); |
---|
1576 | m_keywords.add ("path_remove", new KwdPathRemove ()); |
---|
1577 | m_keywords.add ("path_remove_regexp", new KwdPathRemoveRegexp ()); |
---|
1578 | m_keywords.add ("pattern", new KwdPattern ()); |
---|
1579 | m_keywords.add ("public", new KwdPublic ()); |
---|
1580 | m_keywords.add ("private", new KwdPrivate ()); |
---|
1581 | m_keywords.add ("project", new KwdProject ()); |
---|
1582 | m_keywords.add ("set", new KwdSet ()); |
---|
1583 | m_keywords.add ("set_append", new KwdSetAppend ()); |
---|
1584 | m_keywords.add ("set_prepend", new KwdSetPrepend ()); |
---|
1585 | m_keywords.add ("set_remove", new KwdSetRemove ()); |
---|
1586 | m_keywords.add ("set_remove_regexp", new KwdSetRemoveRegexp ()); |
---|
1587 | m_keywords.add ("setup_script", new KwdSetupScript ()); |
---|
1588 | m_keywords.add ("setup_strategy", new KwdSetupStrategy ()); |
---|
1589 | m_keywords.add ("structure_strategy", new KwdStructureStrategy ()); |
---|
1590 | m_keywords.add ("tag", new KwdTag ()); |
---|
1591 | m_keywords.add ("tag_exclude", new KwdTagExclude ()); |
---|
1592 | m_keywords.add ("use", new KwdUse ()); |
---|
1593 | m_keywords.add ("version_strategy", new KwdVersionStrategy ()); |
---|
1594 | m_keywords.add ("version", new KwdVersion ()); |
---|
1595 | |
---|
1596 | m_project_keywords.add ("author", new KwdAuthor()); |
---|
1597 | m_project_keywords.add ("apply_tag", new KwdApplyTag ()); |
---|
1598 | m_project_keywords.add ("build_strategy", new KwdBuildStrategy ()); |
---|
1599 | m_project_keywords.add ("container", new KwdContainer ()); |
---|
1600 | m_project_keywords.add ("macro", new KwdMacro ()); |
---|
1601 | // m_project_keywords.add ("macro+", new KwdMacroAppend ()); |
---|
1602 | // m_project_keywords.add ("macro_prepend", new KwdMacroPrepend ()); |
---|
1603 | // m_project_keywords.add ("macro_append", new KwdMacroAppend ()); |
---|
1604 | //m_project_keywords.add ("macro_remove", new KwdMacroRemove ()); |
---|
1605 | //m_project_keywords.add ("macro_remove_regexp", new KwdMacroRemoveRegexp ()); |
---|
1606 | //m_project_keywords.add ("macro_remove_all", new KwdMacroRemoveAll ()); |
---|
1607 | //m_project_keywords.add ("macro_remove_all_regexp", new KwdMacroRemoveAllRegexp ()); |
---|
1608 | |
---|
1609 | m_project_keywords.add ("project", new KwdProject ()); |
---|
1610 | m_project_keywords.add ("setup_strategy", new KwdSetupStrategy ()); |
---|
1611 | |
---|
1612 | m_project_keywords.add ("tag", new KwdTag ()); |
---|
1613 | //m_project_keywords.add ("tag_exclude", new KwdTagExclude ()); |
---|
1614 | |
---|
1615 | |
---|
1616 | m_project_keywords.add ("structure_strategy", new KwdStructureStrategy ()); |
---|
1617 | m_project_keywords.add ("use", new KwdUse ()); |
---|
1618 | } |
---|
1619 | |
---|
1620 | void SyntaxParser::do_parse_requirements (const cmt_string& file_name, Use* use) |
---|
1621 | { |
---|
1622 | cmt_string actual_file_name = file_name; |
---|
1623 | cmt_string text; |
---|
1624 | |
---|
1625 | CmtError::clear (); |
---|
1626 | |
---|
1627 | if (!CmtSystem::test_file (actual_file_name)) |
---|
1628 | { |
---|
1629 | actual_file_name = ".."; |
---|
1630 | actual_file_name += CmtSystem::file_separator (); |
---|
1631 | actual_file_name += "cmt"; |
---|
1632 | actual_file_name += CmtSystem::file_separator (); |
---|
1633 | actual_file_name += file_name; |
---|
1634 | |
---|
1635 | if (!CmtSystem::test_file (actual_file_name)) |
---|
1636 | { |
---|
1637 | actual_file_name = ".."; |
---|
1638 | actual_file_name += CmtSystem::file_separator (); |
---|
1639 | actual_file_name += "mgr"; |
---|
1640 | actual_file_name += CmtSystem::file_separator (); |
---|
1641 | actual_file_name += file_name; |
---|
1642 | |
---|
1643 | if (!CmtSystem::test_file (actual_file_name)) |
---|
1644 | { |
---|
1645 | return; |
---|
1646 | } |
---|
1647 | } |
---|
1648 | } |
---|
1649 | |
---|
1650 | text.read (actual_file_name); |
---|
1651 | |
---|
1652 | SyntaxParser::parse_requirements_text (text, actual_file_name, use); |
---|
1653 | } |
---|
1654 | |
---|
1655 | /** |
---|
1656 | * Parse a text, rejecting comments and |
---|
1657 | * rebuilding complete lines (from sections separated by |
---|
1658 | * \\ characters. |
---|
1659 | * |
---|
1660 | * Each reformatted line is parsed by filter_line |
---|
1661 | */ |
---|
1662 | void SyntaxParser::do_parse_text (const cmt_string& text, |
---|
1663 | const cmt_string& file_name, |
---|
1664 | ContextType context, |
---|
1665 | Use* use, |
---|
1666 | Project* project) |
---|
1667 | { |
---|
1668 | cmt_string line; |
---|
1669 | int pos; |
---|
1670 | int max_pos; |
---|
1671 | int line_number = 1; |
---|
1672 | |
---|
1673 | if (context == package_context) |
---|
1674 | { |
---|
1675 | if (use == 0) use = &(Use::current ()); |
---|
1676 | } |
---|
1677 | |
---|
1678 | m_filtered_text.erase (0); |
---|
1679 | |
---|
1680 | pos = 0; |
---|
1681 | max_pos = text.size (); |
---|
1682 | |
---|
1683 | for (pos = 0; pos < max_pos; ) |
---|
1684 | { |
---|
1685 | int cr = text.find (pos, "\r\n"); |
---|
1686 | int nl = text.find (pos, '\n'); |
---|
1687 | int first = nl; |
---|
1688 | int length = 1; |
---|
1689 | |
---|
1690 | if (cr != cmt_string::npos) |
---|
1691 | { |
---|
1692 | if (nl == cmt_string::npos) |
---|
1693 | { |
---|
1694 | first = cr; |
---|
1695 | length = 2; |
---|
1696 | } |
---|
1697 | else |
---|
1698 | { |
---|
1699 | first = (nl < cr) ? nl : cr; |
---|
1700 | length = (nl < cr) ? 1 : 2; |
---|
1701 | } |
---|
1702 | } |
---|
1703 | |
---|
1704 | if (first == cmt_string::npos) |
---|
1705 | { |
---|
1706 | text.substr (pos, line); |
---|
1707 | pos = max_pos; |
---|
1708 | } |
---|
1709 | else if (first > pos) |
---|
1710 | { |
---|
1711 | text.substr (pos, first - pos, line); |
---|
1712 | pos = first + length; |
---|
1713 | } |
---|
1714 | else |
---|
1715 | { |
---|
1716 | line.erase (0); |
---|
1717 | pos += length; |
---|
1718 | } |
---|
1719 | |
---|
1720 | do_parse_line (line, file_name, line_number, context, use, project); |
---|
1721 | |
---|
1722 | if ((Cmt::get_action () == action_check_configuration) && CmtError::has_pending_error ()) |
---|
1723 | { |
---|
1724 | //break; |
---|
1725 | } |
---|
1726 | |
---|
1727 | line_number++; |
---|
1728 | } |
---|
1729 | } |
---|
1730 | |
---|
1731 | void SyntaxParser::do_parse_line (const cmt_string& line, |
---|
1732 | const cmt_string& file_name, |
---|
1733 | int line_number, |
---|
1734 | ContextType context, |
---|
1735 | Use* use, |
---|
1736 | Project* project) |
---|
1737 | { |
---|
1738 | int length; |
---|
1739 | int nl; |
---|
1740 | int back_slash; |
---|
1741 | cmt_string temp_line = line; |
---|
1742 | |
---|
1743 | if (temp_line.size () == 0) return; |
---|
1744 | if (temp_line[0] == '#') return; |
---|
1745 | |
---|
1746 | nl = temp_line.find_last_of ('\n'); |
---|
1747 | if (nl != cmt_string::npos) temp_line.erase (nl); |
---|
1748 | |
---|
1749 | length = temp_line.size (); |
---|
1750 | if (length == 0) return; |
---|
1751 | |
---|
1752 | // |
---|
1753 | // We scan the line for handling backslashes. |
---|
1754 | // |
---|
1755 | // o Really terminating backslashes (ie those only followed by spaces/tabs |
---|
1756 | // mean continued line |
---|
1757 | // |
---|
1758 | // |
---|
1759 | |
---|
1760 | bool finished = true; |
---|
1761 | |
---|
1762 | length = temp_line.size (); |
---|
1763 | |
---|
1764 | back_slash = temp_line.find_last_of ('\\'); |
---|
1765 | |
---|
1766 | if (back_slash != cmt_string::npos) |
---|
1767 | { |
---|
1768 | // |
---|
1769 | // This is the last backslash |
---|
1770 | // check if there are only space chars after it |
---|
1771 | // |
---|
1772 | |
---|
1773 | bool at_end = true; |
---|
1774 | |
---|
1775 | for (int i = (back_slash + 1); i < length; i++) |
---|
1776 | { |
---|
1777 | char c = temp_line[i]; |
---|
1778 | if ((c != ' ') && (c != '\t')) |
---|
1779 | { |
---|
1780 | at_end = false; |
---|
1781 | break; |
---|
1782 | } |
---|
1783 | } |
---|
1784 | |
---|
1785 | if (at_end) |
---|
1786 | { |
---|
1787 | temp_line.erase (back_slash); |
---|
1788 | finished = false; |
---|
1789 | } |
---|
1790 | else |
---|
1791 | { |
---|
1792 | // This was not a trailing backslash. |
---|
1793 | finished = true; |
---|
1794 | } |
---|
1795 | } |
---|
1796 | |
---|
1797 | m_filtered_text += temp_line; |
---|
1798 | |
---|
1799 | if (!finished) |
---|
1800 | { |
---|
1801 | // We still need to accumulate forthcoming lines |
---|
1802 | // before parsing the resulting text. |
---|
1803 | return; |
---|
1804 | } |
---|
1805 | |
---|
1806 | /* |
---|
1807 | Here a full line (possibly accumulating several lines |
---|
1808 | ended by backslashes) is parsed : |
---|
1809 | |
---|
1810 | o Special characters are filtered now : |
---|
1811 | |
---|
1812 | <cmt:tab/> \t |
---|
1813 | <cmt:cr/> \r |
---|
1814 | <cmt:lf/> \n |
---|
1815 | |
---|
1816 | o Split into words (a word is a string not containing |
---|
1817 | spaces or enclosed in quotes) |
---|
1818 | |
---|
1819 | o Parse the word array (function Select) |
---|
1820 | |
---|
1821 | */ |
---|
1822 | |
---|
1823 | m_filtered_text.replace_all ("<cmt:tab/>", "\t"); |
---|
1824 | m_filtered_text.replace_all ("<cmt:cr/>", "\r"); |
---|
1825 | m_filtered_text.replace_all ("<cmt:lf/>", "\n"); |
---|
1826 | |
---|
1827 | if (Cmt::get_debug ()) |
---|
1828 | { |
---|
1829 | cout << "parse_requirements_line [" << m_filtered_text << "]" << endl; |
---|
1830 | } |
---|
1831 | |
---|
1832 | static CmtSystem::cmt_string_vector words; |
---|
1833 | |
---|
1834 | CmtSystem::split (m_filtered_text, " \t", words); |
---|
1835 | |
---|
1836 | if (words.size () != 0) |
---|
1837 | { |
---|
1838 | switch (context) |
---|
1839 | { |
---|
1840 | case project_context: |
---|
1841 | do_parse_words (words, file_name, line_number, project); |
---|
1842 | break; |
---|
1843 | case package_context: |
---|
1844 | do_parse_words (words, file_name, line_number, use); |
---|
1845 | break; |
---|
1846 | } |
---|
1847 | } |
---|
1848 | |
---|
1849 | m_filtered_text.erase (0); |
---|
1850 | } |
---|
1851 | |
---|
1852 | void SyntaxParser::do_parse_words (const CmtSystem::cmt_string_vector& words, |
---|
1853 | const cmt_string& file_name, |
---|
1854 | int line_number, |
---|
1855 | Use* use) |
---|
1856 | { |
---|
1857 | CmtError::clear (); |
---|
1858 | |
---|
1859 | if (words.size () == 0) return; |
---|
1860 | |
---|
1861 | const cmt_string& command = words[0]; |
---|
1862 | |
---|
1863 | if (command.size () == 0) return; |
---|
1864 | |
---|
1865 | // |
---|
1866 | // First analyze the syntax |
---|
1867 | // |
---|
1868 | |
---|
1869 | Kwd* keyword = m_keywords.find (command); |
---|
1870 | if (keyword == 0) |
---|
1871 | { |
---|
1872 | /* |
---|
1873 | |
---|
1874 | When the first word of the line is not a keyword, it may be an |
---|
1875 | implicit pattern application. |
---|
1876 | |
---|
1877 | */ |
---|
1878 | |
---|
1879 | Pattern* p = Pattern::find (command); |
---|
1880 | if (p == 0) |
---|
1881 | { |
---|
1882 | CmtError::set (CmtError::syntax_error, "ParseRequirements> "); |
---|
1883 | } |
---|
1884 | else |
---|
1885 | { |
---|
1886 | keyword = m_keywords.find ("apply_pattern"); |
---|
1887 | } |
---|
1888 | } |
---|
1889 | |
---|
1890 | if (CmtError::has_pending_error ()) |
---|
1891 | { |
---|
1892 | if (!Cmt::get_quiet ()) |
---|
1893 | { |
---|
1894 | cerr << "#CMT> bad syntax in requirements of " << use->get_package_name () |
---|
1895 | << " " << use->version |
---|
1896 | << " " << use->specified_path |
---|
1897 | << " line #" << line_number; |
---|
1898 | cerr << " [" << command << " ...]" << endl; |
---|
1899 | } |
---|
1900 | |
---|
1901 | return; |
---|
1902 | } |
---|
1903 | |
---|
1904 | // |
---|
1905 | // Then interpret the action |
---|
1906 | // |
---|
1907 | |
---|
1908 | keyword->action (words, use, file_name, line_number); |
---|
1909 | } |
---|
1910 | |
---|
1911 | void SyntaxParser::do_parse_words (const CmtSystem::cmt_string_vector& words, |
---|
1912 | const cmt_string& file_name, |
---|
1913 | int line_number, |
---|
1914 | Project* project) |
---|
1915 | { |
---|
1916 | CmtError::clear (); |
---|
1917 | |
---|
1918 | if (words.size () == 0) return; |
---|
1919 | |
---|
1920 | const cmt_string& command = words[0]; |
---|
1921 | |
---|
1922 | if (command.size () == 0) return; |
---|
1923 | |
---|
1924 | // |
---|
1925 | // First analyze the syntax |
---|
1926 | // |
---|
1927 | |
---|
1928 | Kwd* keyword = m_project_keywords.find (command); |
---|
1929 | if (keyword == 0) |
---|
1930 | { |
---|
1931 | CmtError::set (CmtError::syntax_error, "ParseRequirements> "); |
---|
1932 | } |
---|
1933 | |
---|
1934 | if (CmtError::has_pending_error ()) |
---|
1935 | { |
---|
1936 | if (!Cmt::get_quiet ()) |
---|
1937 | { |
---|
1938 | cerr << "#CMT> bad syntax in project file of " << project->get_name () |
---|
1939 | << " line #" << line_number; |
---|
1940 | cerr << " [" << command << " ...]" << endl; |
---|
1941 | } |
---|
1942 | |
---|
1943 | return; |
---|
1944 | } |
---|
1945 | |
---|
1946 | // |
---|
1947 | // Then interpret the action |
---|
1948 | // |
---|
1949 | |
---|
1950 | keyword->action (words, project, file_name, line_number); |
---|
1951 | } |
---|