Changeset 40555 in vbox
- Timestamp:
- Mar 20, 2012 6:21:37 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 76948
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/VBoxTpG.cpp
r40554 r40555 318 318 } 319 319 320 321 /** 322 * Parser error with line and position. 323 * 324 * @returns RTEXITCODE_FAILURE. 325 * @param pStrm The stream. 326 * @param cb The offset from the current position to the 327 * point of failure. 328 * @param pszMsg The message to display. 329 */ 330 static RTEXITCODE parseErrorAbs(PSCMSTREAM pStrm, size_t off, const char *pszMsg) 331 { 332 ScmStreamSeekAbsolute(pStrm, off); 333 return parseError(pStrm, 0, pszMsg); 334 } 335 320 336 /** 321 337 * Handles a C++ one line comment. … … 390 406 391 407 408 /** 409 * Skips spaces and comments, returning the next character. 410 * 411 * @returns Next non-space-non-comment character. ~(unsigned)0 on EOF or 412 * failure. 413 * @param pStrm The stream. 414 */ 415 static unsigned parseGetNextNonSpaceNonCommentCh(PSCMSTREAM pStrm) 416 { 417 unsigned ch; 418 while ((ch = ScmStreamGetCh(pStrm)) != ~(unsigned)0) 419 { 420 if (!RT_C_IS_SPACE(ch) && ch != '/') 421 return ch; 422 if (ch == '/') 423 { 424 ch = ScmStreamGetCh(pStrm); 425 RTEXITCODE rcExit; 426 if (ch == '*') 427 rcExit = parseMultiLineComment(pStrm); 428 else if (ch == '/') 429 rcExit = parseOneLineComment(pStrm); 430 else 431 rcExit = parseError(pStrm, 2, "Unexpected character"); 432 if (rcExit != RTEXITCODE_SUCCESS) 433 return ~(unsigned)0; 434 } 435 } 436 437 parseError(pStrm, 0, "Unexpected end of file"); 438 return ~(unsigned)0; 439 } 440 441 392 442 393 443 static RTEXITCODE parseProvider(PSCMSTREAM pStrm) … … 406 456 return parseError(pStrm, 1, "A provider name cannot end with digit"); 407 457 408 rcExit = parseSkipSpacesAndComments(pStrm); 409 if (rcExit != RTEXITCODE_SUCCESS) 410 return parseError(pStrm, 1, "Expected a provider name starting with an alphabetical character"); 411 unsigned ch = ScmStreamGetCh(pStrm); 458 unsigned ch = parseGetNextNonSpaceNonCommentCh(pStrm); 412 459 if (ch != '{') 413 460 return parseError(pStrm, 1, "Expected '{' after the provider name"); … … 421 468 RTListAppend(&g_ProviderHead, &pProv->ListEntry); 422 469 pProv->pszName = RTStrCacheEnterN(g_hStrCache, pszName, cchName); 423 if ( pProv->pszName)470 if (!pProv->pszName) 424 471 return parseError(pStrm, 0, "Out of memory"); 425 472 426 473 /* 427 * Next up is a brace474 * Parse loop. 428 475 */ 429 430 431 return parseError(pStrm, 0, "'provider' not implemented"); 476 for (;;) 477 { 478 ch = parseGetNextNonSpaceNonCommentCh(pStrm); 479 switch (ch) 480 { 481 case 'p': 482 if (ScmStreamCMatchingWordM1(pStrm, RT_STR_TUPLE("probe"))) 483 return parseError(pStrm, 5, "probe parsing not implemented"); 484 else 485 return parseError(pStrm, 1, "Unexpected character"); 486 break; 487 488 case '}': 489 { 490 size_t off = ScmStreamTell(pStrm); 491 ch = parseGetNextNonSpaceNonCommentCh(pStrm); 492 if (ch != ';') 493 return parseErrorAbs(pStrm, off, "Expected ';'"); 494 return RTEXITCODE_SUCCESS; 495 } 496 497 case ~(unsigned)0: 498 return parseError(pStrm, 0, "Missing closing '}' on provider"); 499 500 default: 501 return parseError(pStrm, 1, "Unexpected character"); 502 } 503 } 432 504 } 433 505
Note:
See TracChangeset
for help on using the changeset viewer.