fn parse(
input: &TokenStream,
part: RulePart,
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.part: whether we’re parsing 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:expror$id:ident. In this example,exprandidentare “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”.
- In a pattern, metavars are declared with their “matcher” type. For example
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.