Function rustc_expand::mbe::quoted::parse_sep_and_kleene_op

source ·
fn parse_sep_and_kleene_op<'a>(
    input: &mut impl Iterator<Item = &'a TokenTree>,
    span: Span,
    sess: &Session
) -> (Option<Token>, KleeneToken)
Expand description

Attempt to parse a single Kleene star, possibly with a separator.

For example, in a pattern such as $(a),*, a is the pattern to be repeated, , is the separator, and * is the Kleene operator. This function is specifically concerned with parsing the last two tokens of such a pattern: namely, the optional separator and the Kleene operator itself. Note that here we are parsing the macro itself, rather than trying to match some stream of tokens in an invocation of a macro.

This function will take some input iterator input corresponding to span and a parsing session sess. If the next one (or possibly two) tokens in input correspond to a Kleene operator and separator, then a tuple with (separator, KleeneOp) is returned. Otherwise, an error with the appropriate span is emitted to sess and a dummy value is returned.