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