Expand description
mbe
(short for Macro By Example) crate contains code for handling
macro_rules
macros. It uses TokenTree
(from tt
package) as the
interface, although it contains some code to bridge SyntaxNode
s and
TokenTree
s as well!
The tests for this functionality live in another crate:
hir_def::macro_expansion_tests::mbe
.
Structs§
- This struct contains AST for a single
macro_rules
definition. What might be very confusing is that AST has almost exactly the same shape astt::TokenTree
, but there’s a crucial difference: in macro rules,$ident
and$()*
have special meaning (seeVar
andRepeat
data structures)
Enums§
- Parse the whole of the input as a given syntactic construct.
Constants§
Traits§
Functions§
- Split token tree with separate expr: $($e:expr)SEP*
- Convert a string to a
TokenTree
. The spans of the subtree will be anchored to the provided anchor with the given context. - Convert a string to a
TokenTree
. The passed span will be used for all spans of the produced subtree. - Converts a syntax tree to a
tt::Subtree
using the provided span map to populate the subtree’s spans. - Converts a syntax tree to a
tt::Subtree
using the provided span map to populate the subtree’s spans. Additionally using the append and remove parameters, the additional tokens can be injected or hidden from the output. - Converts a
tt::Subtree
back to aSyntaxNode
. The producedSpanMap
contains a mapping from the syntax nodes offsets to the subtree’s spans.
Type Aliases§
- Index of the matched macro arm on successful expansion.