add macro by example ide

This commit is contained in:
Aleksey Kladov 2019-01-30 23:17:32 +03:00
parent 6846ac2a16
commit ca327f35ad
2 changed files with 52 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#[allow(unused)]
mod tt;
#[allow(unused)]
mod mbe;
/// Machinery for macro expansion.
///

View 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,
}