2019-01-30 20:17:32 +00:00
|
|
|
use ra_syntax::SmolStr;
|
|
|
|
|
2019-01-30 20:25:02 +00:00
|
|
|
use crate::macros::tt;
|
|
|
|
|
2019-01-30 20:17:32 +00:00
|
|
|
struct MacroRules {
|
|
|
|
rules: Vec<Rule>,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Rule {
|
|
|
|
lhs: TokenTree,
|
|
|
|
rhs: TokenTree,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum TokenTree {
|
|
|
|
Leaf(Leaf),
|
|
|
|
Subtree(Subtree),
|
2019-01-31 07:33:11 +00:00
|
|
|
Repeat(Repeat),
|
2019-01-30 20:17:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum Leaf {
|
|
|
|
Literal(Literal),
|
|
|
|
Punct(Punct),
|
|
|
|
Ident(Ident),
|
|
|
|
Var(Var),
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Subtree {
|
|
|
|
delimiter: Delimiter,
|
|
|
|
token_trees: Vec<TokenTree>,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum Delimiter {
|
|
|
|
Parenthesis,
|
|
|
|
Brace,
|
|
|
|
Bracket,
|
|
|
|
None,
|
|
|
|
}
|
|
|
|
|
2019-01-31 07:33:11 +00:00
|
|
|
struct Repeat {
|
|
|
|
subtree: Subtree,
|
|
|
|
kind: RepeatKind,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum RepeatKind {
|
|
|
|
ZeroOrMore,
|
|
|
|
OneOrMore,
|
|
|
|
ZeroOrOne,
|
|
|
|
}
|
|
|
|
|
2019-01-30 20:17:32 +00:00
|
|
|
struct Literal {
|
|
|
|
text: SmolStr,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Punct {
|
|
|
|
char: char,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Ident {
|
|
|
|
text: SmolStr,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Var {
|
|
|
|
text: SmolStr,
|
|
|
|
}
|
2019-01-30 20:25:02 +00:00
|
|
|
|
|
|
|
fn parse(tt: tt::TokenTree) -> MacroRules {
|
|
|
|
MacroRules { rules: Vec::new() }
|
|
|
|
}
|