pub fn scan_directives(
source: &str,
tokens: &[CppTokenData],
) -> Vec<SpannedDirective>Expand description
Read every directive in a file, in source order.
Read from the token stream, not from the tree, because the rule is a rule about lines: a # begins
a directive when it is the first token of its logical line. A splice is not a newline —
LineContinuation is a token kind of its own — which is what keeps #define F(a) \ continued on the
next line from starting a second directive at the # of a stringized parameter.
A directive’s span is the one the tree gives it: from the # through the trivia that follows its
last token, up to the next token that is not trivia. That trailing trivia (the newline, blank lines,
the comment before the following line) belongs to the span because the parser attaches it to the
directive it just finished, and a consumer asking for “the text of this directive” has always got it.