rust-analyzer/crates/ra_macros/src/tt.rs

46 lines
675 B
Rust
Raw Normal View History

2019-01-31 10:40:05 +00:00
use smol_str::SmolStr;
2019-01-30 20:02:27 +00:00
2019-01-31 08:09:19 +00:00
#[derive(Debug)]
2019-01-31 10:40:05 +00:00
pub enum TokenTree {
2019-01-30 20:02:27 +00:00
Leaf(Leaf),
Subtree(Subtree),
}
2019-01-30 20:58:52 +00:00
impl_froms!(TokenTree: Leaf, Subtree);
2019-01-30 20:02:27 +00:00
2019-01-31 08:09:19 +00:00
#[derive(Debug)]
2019-01-31 10:40:05 +00:00
pub enum Leaf {
2019-01-30 20:02:27 +00:00
Literal(Literal),
Punct(Punct),
Ident(Ident),
}
2019-01-30 20:58:52 +00:00
impl_froms!(Leaf: Literal, Punct, Ident);
2019-01-30 20:02:27 +00:00
2019-01-31 08:09:19 +00:00
#[derive(Debug)]
2019-01-31 10:40:05 +00:00
pub struct Subtree {
pub delimiter: Delimiter,
pub token_trees: Vec<TokenTree>,
2019-01-30 20:02:27 +00:00
}
2019-01-31 10:32:40 +00:00
#[derive(Clone, Copy, Debug)]
2019-01-31 10:40:05 +00:00
pub enum Delimiter {
2019-01-30 20:02:27 +00:00
Parenthesis,
Brace,
Bracket,
None,
}
2019-01-31 08:09:19 +00:00
#[derive(Debug)]
2019-01-31 10:40:05 +00:00
pub struct Literal {
pub text: SmolStr,
2019-01-30 20:02:27 +00:00
}
2019-01-31 08:09:19 +00:00
#[derive(Debug)]
2019-01-31 10:40:05 +00:00
pub struct Punct {
pub char: char,
2019-01-30 20:02:27 +00:00
}
2019-01-31 08:09:19 +00:00
#[derive(Debug)]
2019-01-31 10:40:05 +00:00
pub struct Ident {
pub text: SmolStr,
2019-01-30 20:02:27 +00:00
}