mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
add macro by example ide
This commit is contained in:
parent
6846ac2a16
commit
ca327f35ad
2 changed files with 52 additions and 0 deletions
|
@ -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 a new issue