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