MCPcopy Create free account
hub / github.com/csyonghe/Spire / ReadToken

Function ReadToken

Source/SpireCore/Preprocessor.cpp:1696–1729  ·  view source on GitHub ↗

Read one token using the full preprocessor, with all its behaviors.

Source from the content-addressed store, hash-verified

1694
1695// Read one token using the full preprocessor, with all its behaviors.
1696static 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
1732static void InitializePreprocessor(

Callers 15

ReadIntMethod · 0.85
ReadUIntMethod · 0.85
ReadDoubleMethod · 0.85
ReadWordMethod · 0.85
ReadMethod · 0.85
ReadStringLiteralMethod · 0.85
ParseMethod · 0.85
ReadAllTokensFunction · 0.85
ParseInterfaceMethod · 0.85
ParseShaderMethod · 0.85
ParseTemplateShaderMethod · 0.85

Calls 5

PeekRawTokenFunction · 0.85
AdvanceRawTokenFunction · 0.85
HandleDirectiveFunction · 0.85
IsSkippingFunction · 0.85
AdvanceTokenFunction · 0.85

Tested by

no test coverage detected