Function rustc_expand::mbe::quoted::parse

source ·
pub(super) fn parse(
    input: &TokenStream,
    parsing_patterns: bool,
    sess: &Session,
    node_id: NodeId,
    features: &Features,
    edition: Edition,
) -> Vec<TokenTree>
Expand description

Takes a tokenstream::TokenStream and returns a Vec<self::TokenTree>. Specifically, this takes a generic TokenStream, such as is used in the rest of the compiler, and returns a collection of TokenTree for use in parsing a macro.

§Parameters

  • input: a token stream to read from, the contents of which we are parsing.
  • parsing_patterns: parse can be used to parse either the “patterns” or the “body” of a macro. Both take roughly the same form except that:
    • In a pattern, metavars are declared with their “matcher” type. For example $var:expr or $id:ident. In this example, expr and ident are “matchers”. They are not present in the body of a macro rule – just in the pattern.
    • Metavariable expressions are only valid in the “body”, not the “pattern”.
  • sess: the parsing session. Any errors will be emitted to this session.
  • node_id: the NodeId of the macro we are parsing.
  • features: language features so we can do feature gating.

§Returns

A collection of self::TokenTree. There may also be some errors emitted to sess.