[−][src]Function syntax::ext::tt::transcribe::transcribe
pub fn transcribe(
cx: &ExtCtxt,
interp: &FxHashMap<Ident, Rc<NamedMatch>>,
src: Vec<TokenTree>
) -> TokenStream
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.