mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 12:44:40 +00:00
add macro by example ide
This commit is contained in:
parent
6846ac2a16
commit
ca327f35ad
@ -1,5 +1,7 @@
|
||||
#[allow(unused)]
|
||||
mod tt;
|
||||
#[allow(unused)]
|
||||
mod mbe;
|
||||
|
||||
/// Machinery for macro expansion.
|
||||
///
|
||||
|
50
crates/ra_hir/src/macros/mbe.rs
Normal file
50
crates/ra_hir/src/macros/mbe.rs
Normal file
@ -0,0 +1,50 @@
|
||||
use ra_syntax::SmolStr;
|
||||
|
||||
struct MacroRules {
|
||||
rules: Vec<Rule>,
|
||||
}
|
||||
|
||||
struct Rule {
|
||||
lhs: TokenTree,
|
||||
rhs: TokenTree,
|
||||
}
|
||||
|
||||
enum TokenTree {
|
||||
Leaf(Leaf),
|
||||
Subtree(Subtree),
|
||||
}
|
||||
|
||||
enum Leaf {
|
||||
Literal(Literal),
|
||||
Punct(Punct),
|
||||
Ident(Ident),
|
||||
Var(Var),
|
||||
}
|
||||
|
||||
struct Subtree {
|
||||
delimiter: Delimiter,
|
||||
token_trees: Vec<TokenTree>,
|
||||
}
|
||||
|
||||
enum Delimiter {
|
||||
Parenthesis,
|
||||
Brace,
|
||||
Bracket,
|
||||
None,
|
||||
}
|
||||
|
||||
struct Literal {
|
||||
text: SmolStr,
|
||||
}
|
||||
|
||||
struct Punct {
|
||||
char: char,
|
||||
}
|
||||
|
||||
struct Ident {
|
||||
text: SmolStr,
|
||||
}
|
||||
|
||||
struct Var {
|
||||
text: SmolStr,
|
||||
}
|
Loading…
Reference in New Issue
Block a user