Read one token using the full preprocessor, with all its behaviors.
| 1694 | |
| 1695 | // Read one token using the full preprocessor, with all its behaviors. |
| 1696 | static Token ReadToken(Preprocessor* preprocessor) |
| 1697 | { |
| 1698 | for (;;) |
| 1699 | { |
| 1700 | // Look at the next raw token in the input. |
| 1701 | Token const& token = PeekRawToken(preprocessor); |
| 1702 | |
| 1703 | // If we have a directive (`#` at start of line) then handle it |
| 1704 | if ((token.Type == TokenType::Pound) && (token.flags & TokenFlag::AtStartOfLine)) |
| 1705 | { |
| 1706 | // Skip the `#` |
| 1707 | AdvanceRawToken(preprocessor); |
| 1708 | |
| 1709 | // Create a context for parsing the directive |
| 1710 | PreprocessorDirectiveContext directiveContext; |
| 1711 | directiveContext.preprocessor = preprocessor; |
| 1712 | directiveContext.parseError = false; |
| 1713 | |
| 1714 | // Parse and handle the directive |
| 1715 | HandleDirective(&directiveContext); |
| 1716 | continue; |
| 1717 | } |
| 1718 | |
| 1719 | // otherwise, if we are currently in a skipping mode, then skip tokens |
| 1720 | if (IsSkipping(preprocessor)) |
| 1721 | { |
| 1722 | AdvanceRawToken(preprocessor); |
| 1723 | continue; |
| 1724 | } |
| 1725 | |
| 1726 | // otherwise read a token, which may involve macro expansion |
| 1727 | return AdvanceToken(preprocessor); |
| 1728 | } |
| 1729 | } |
| 1730 | |
| 1731 | // intialize a preprocessor context, using the given sink for errros |
| 1732 | static void InitializePreprocessor( |
no test coverage detected