- Timestamp:
- Mar 20, 2012 6:40:23 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/VBoxTpG.cpp
r40555 r40556 290 290 291 291 /** 292 * Get's the C word starting at the current position minus one. 293 * 294 * @returns Pointer to the word on success and the stream position advanced to 295 * the end of it. 296 * NULL on failure, stream position normally unchanged. 297 * @param pStream The stream to get the C word from. 298 * @param pcchWord Where to return the word length. 299 */ 300 const char *ScmStreamCGetWordM1(PSCMSTREAM pStream, size_t *pcchWord) 301 { 302 /* Check stream state. */ 303 AssertReturn(!pStream->fWriteOrRead, false); 304 AssertReturn(RT_SUCCESS(pStream->rc), false); 305 AssertReturn(pStream->fFullyLineated, false); 306 307 /* Get the number of chars left on the line and locate the current char. */ 308 size_t const iLine = pStream->iLine; 309 size_t const cchLeft = pStream->paLines[iLine].cch + pStream->paLines[iLine].off - (pStream->off - 1); 310 const char *psz = &pStream->pch[pStream->off - 1]; 311 312 /* Is it a leading C character. */ 313 if (!RT_C_IS_ALPHA(*psz) && !*psz == '_') 314 return NULL; 315 316 /* Find the end of the word. */ 317 char ch; 318 size_t off = 1; 319 while ( off < cchLeft 320 && ( (ch = psz[off]) == '_' 321 || RT_C_IS_ALNUM(ch))) 322 off++; 323 324 pStream->off += off - 1; 325 *pcchWord = off; 326 return psz; 327 } 328 329 330 /** 292 331 * Parser error with line and position. 293 332 * … … 440 479 441 480 442 481 /** 482 * Skips spaces and comments. 483 * 484 * @returns Same as ScmStreamCGetWord 485 * @param pStrm The stream.. 486 * @param pcchWord Where to return the length. 487 */ 488 static const char *parseGetNextCWord(PSCMSTREAM pStrm, size_t *pcchWord) 489 { 490 if (parseSkipSpacesAndComments(pStrm) != RTEXITCODE_SUCCESS) 491 return NULL; 492 return ScmStreamCGetWord(pStrm, pcchWord); 493 } 494 495 496 /** 497 * Parses a D probe statement. 498 * 499 * @returns Suitable exit code, errors message already written on failure. 500 * @param pStrm The stream. 501 */ 502 static RTEXITCODE parseProbe(PSCMSTREAM pStrm, PVTGPROVIDER pProv) 503 { 504 /* 505 * Next up is a name followed by an opening parenthesis. 506 */ 507 size_t cchProbe; 508 const char *pszProbe = parseGetNextCWord(pStrm, &cchProbe); 509 if (!pszProbe) 510 return parseError(pStrm, 1, "Expected a probe name starting with an alphabetical character"); 511 unsigned ch = parseGetNextNonSpaceNonCommentCh(pStrm); 512 if (ch != '(') 513 return parseError(pStrm, 1, "Expected '(' after the probe name"); 514 515 /* 516 * Create a probe instance. 517 */ 518 PVTGPROBE pProbe = (PVTGPROBE)RTMemAllocZ(sizeof(*pProbe)); 519 if (!pProbe) 520 return parseError(pStrm, 0, "Out of memory"); 521 RTListAppend(&pProv->ProbeHead, &pProbe->ListEntry); 522 pProbe->pszName = RTStrCacheEnterN(g_hStrCache, pszProbe, cchProbe); 523 if (!pProbe->pszName) 524 return parseError(pStrm, 0, "Out of memory"); 525 #if 0 526 /* 527 * Parse loop. 528 */ 529 char *pszArg = NULL; 530 for (;;) 531 { 532 ch = parseGetNextNonSpaceNonCommentCh(pStrm); 533 RTEXITCODE rcExit; 534 switch (ch) 535 { 536 case ')': 537 case ',': 538 { 539 if (pszType) 540 { 541 } 542 size_t off = ScmStreamTell(pStrm); 543 if () 544 { 545 } 546 547 ch = parseGetNextNonSpaceNonCommentCh(pStrm); 548 if (ch == ';') 549 return RTEXITCODE_SUCCESS; 550 rcExit = parseErrorAbs(pStrm, off, "Expected ';'"); 551 break; 552 } 553 554 default: 555 { 556 size_t cchWord; 557 const char *pszWord = ScmStreamCGetWordM1(pStrm, &cchWord); 558 if (!pszWord) 559 else 560 rcExit = parseError(pStrm, 0, "Expected argument"); 561 break; 562 } 563 564 case '*': 565 if (pszArg) 566 int rc = RTStrAAppendExN(&pszArg, 2, " "); 567 } 568 else 569 rcExit = parseError(pStrm, 0, "Expected argument"); 570 571 case ~(unsigned)0: 572 rcExit = parseError(pStrm, 0, "Missing closing ')' on probe"); 573 break; 574 575 default: 576 rcExit = parseError(pStrm, 1, "Unexpected character"); 577 break; 578 } 579 if (rcExit != RTEXITCODE_SUCCESS) 580 return rcExit; 581 } 582 #endif 583 return parseError(pStrm, 0, "probe todo"); 584 } 585 586 /** 587 * Parses a D provider statement. 588 * 589 * @returns Suitable exit code, errors message already written on failure. 590 * @param pStrm The stream. 591 */ 443 592 static RTEXITCODE parseProvider(PSCMSTREAM pStrm) 444 593 { 445 594 /* 446 * Next up is a name followed by a curly bracket. Ignore comment .s595 * Next up is a name followed by a curly bracket. Ignore comments. 447 596 */ 448 597 RTEXITCODE rcExit = parseSkipSpacesAndComments(pStrm); … … 466 615 if (!pProv) 467 616 return parseError(pStrm, 0, "Out of memory"); 617 RTListInit(&pProv->ProbeHead); 468 618 RTListAppend(&g_ProviderHead, &pProv->ListEntry); 469 619 pProv->pszName = RTStrCacheEnterN(g_hStrCache, pszName, cchName); … … 481 631 case 'p': 482 632 if (ScmStreamCMatchingWordM1(pStrm, RT_STR_TUPLE("probe"))) 483 r eturn parseError(pStrm, 5, "probe parsing not implemented");633 rcExit = parseProbe(pStrm, pProv); 484 634 else 485 r eturnparseError(pStrm, 1, "Unexpected character");635 rcExit = parseError(pStrm, 1, "Unexpected character"); 486 636 break; 487 637 … … 490 640 size_t off = ScmStreamTell(pStrm); 491 641 ch = parseGetNextNonSpaceNonCommentCh(pStrm); 492 if (ch != ';') 493 return parseErrorAbs(pStrm, off, "Expected ';'"); 494 return RTEXITCODE_SUCCESS; 642 if (ch == ';') 643 return RTEXITCODE_SUCCESS; 644 rcExit = parseErrorAbs(pStrm, off, "Expected ';'"); 645 break; 495 646 } 496 647 497 648 case ~(unsigned)0: 498 return parseError(pStrm, 0, "Missing closing '}' on provider"); 649 rcExit = parseError(pStrm, 0, "Missing closing '}' on provider"); 650 break; 499 651 500 652 default: 501 return parseError(pStrm, 1, "Unexpected character"); 653 rcExit = parseError(pStrm, 1, "Unexpected character"); 654 break; 502 655 } 656 if (rcExit != RTEXITCODE_SUCCESS) 657 return rcExit; 503 658 } 504 659 }
Note:
See TracChangeset
for help on using the changeset viewer.