discover_template_lists

Function discover_template_lists 

Source
fn discover_template_lists<'a>(
    tokens: &mut Vec<((Token<'a>, Span), &'a str)>,
    source: &'a str,
    input: &'a str,
    ignore_doc_comments: bool,
)
Expand description

Produce at least one token, distinguishing template lists from other uses of < and >.

Consume one or more tokens from input and store them in tokens, updating input to refer to the remaining text. Apply WGSL’s template list discovery algorithm to decide what sort of tokens < and > characters in the input actually represent.

Store the tokens in tokens in the reverse of the order they appear in the text, such that the caller can pop from the end of the vector to see the tokens in textual order.

The tokens vector must be empty on entry. The idea is for the caller to use it as a buffer of unconsumed tokens, and call this function to refill it when it’s empty.

The source argument must be the whole original source code, used to compute spans.

If ignore_doc_comments is true, then doc comments are returned as Token::Trivia, like ordinary comments.