[−][src]Function rustc_expand::mbe::transcribe::transcribe
pub(in mbe) fn transcribe<'a>(
cx: &ExtCtxt<'a>,
interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
src: Vec<TokenTree>,
transparency: Transparency
) -> PResult<'a, TokenStream>
This can do Macro-By-Example transcription.
interpis a map of meta-variables to the tokens (non-terminals) they matched in the invocation. We are assuming we already know there is a match.srcis the RHS of the MBE, that is, the "example" we are filling in.
For example,
macro_rules! foo { ($id:ident) => { println!("{}", stringify!($id)); } } foo!(bar);
interp would contain $id => bar and src would contain println!("{}", stringify!($id));.
transcribe would return a TokenStream containing println!("{}", stringify!(bar));.
Along the way, we do some additional error checking.