pub(super) fn transcribe<'a>(
    cx: &ExtCtxt<'a>,
    interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
    src: &Delimited,
    src_span: DelimSpan,
    transparency: Transparency
) -> PResult<'a, TokenStream>
Expand description

This can do Macro-By-Example transcription.

  • interp is 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.
  • src is 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.