Handle a `#line` directive
| 1507 | |
| 1508 | // Handle a `#line` directive |
| 1509 | static void HandleLineDirective(PreprocessorDirectiveContext* context) |
| 1510 | { |
| 1511 | int line = 0; |
| 1512 | if (PeekTokenType(context) == TokenType::IntLiterial) |
| 1513 | { |
| 1514 | line = StringToInt(AdvanceToken(context).Content); |
| 1515 | } |
| 1516 | else if (PeekTokenType(context) == TokenType::Identifier |
| 1517 | && PeekToken(context).Content == "default") |
| 1518 | { |
| 1519 | AdvanceToken(context); |
| 1520 | |
| 1521 | // TODO(tfoley): reset line numbering here |
| 1522 | return; |
| 1523 | } |
| 1524 | else |
| 1525 | { |
| 1526 | GetSink(context)->diagnose(PeekLoc(context), Diagnostics::expected2TokensInPreprocessorDirective, |
| 1527 | TokenType::IntLiterial, |
| 1528 | "default", |
| 1529 | GetDirectiveName(context)); |
| 1530 | context->parseError = true; |
| 1531 | return; |
| 1532 | } |
| 1533 | |
| 1534 | if (PeekTokenType(context) == TokenType::EndOfFile) |
| 1535 | { |
| 1536 | // TODO(tfoley): set line number, but not file |
| 1537 | return; |
| 1538 | } |
| 1539 | |
| 1540 | String file; |
| 1541 | if (PeekTokenType(context) == TokenType::StringLiterial) |
| 1542 | { |
| 1543 | file = AdvanceToken(context).Content; |
| 1544 | } |
| 1545 | else if (PeekTokenType(context) == TokenType::IntLiterial) |
| 1546 | { |
| 1547 | // Note(tfoley): GLSL allows the "source string" to be indicated by an integer |
| 1548 | // TODO(tfoley): Figure out a better way to handle this, if it matters |
| 1549 | file = AdvanceToken(context).Content; |
| 1550 | } |
| 1551 | else |
| 1552 | { |
| 1553 | Expect(context, TokenType::StringLiterial, Diagnostics::expectedTokenInPreprocessorDirective); |
| 1554 | return; |
| 1555 | } |
| 1556 | |
| 1557 | // TODO(tfoley): set line number and file here |
| 1558 | } |
| 1559 | |
| 1560 | // Handle a `#pragma` directive |
| 1561 | static void HandlePragmaDirective(PreprocessorDirectiveContext* context) |
nothing calls this directly
no test coverage detected