rust-analyzer/crates/ra_hir/src/macros/mbe.rs

51 lines
566 B
Rust
Raw Normal View History

2019-01-30 20:17:32 +00:00
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,
}