Files
rust/crates/ra_hir/src/macros/tt.rs

46 lines
747 B
Rust
Raw Normal View History

2019-01-30 23:02:27 +03:00
use ra_syntax::SmolStr;
2019-01-31 11:09:19 +03:00
#[derive(Debug)]
2019-01-30 23:25:02 +03:00
pub(crate) enum TokenTree {
2019-01-30 23:02:27 +03:00
Leaf(Leaf),
Subtree(Subtree),
}
2019-01-30 23:58:52 +03:00
impl_froms!(TokenTree: Leaf, Subtree);
2019-01-30 23:02:27 +03:00
2019-01-31 11:09:19 +03:00
#[derive(Debug)]
2019-01-30 23:25:02 +03:00
pub(crate) enum Leaf {
2019-01-30 23:02:27 +03:00
Literal(Literal),
Punct(Punct),
Ident(Ident),
}
2019-01-30 23:58:52 +03:00
impl_froms!(Leaf: Literal, Punct, Ident);
2019-01-30 23:02:27 +03:00
2019-01-31 11:09:19 +03:00
#[derive(Debug)]
2019-01-30 23:25:02 +03:00
pub(crate) struct Subtree {
2019-01-30 23:58:52 +03:00
pub(crate) delimiter: Delimiter,
pub(crate) token_trees: Vec<TokenTree>,
2019-01-30 23:02:27 +03:00
}
2019-01-31 11:09:19 +03:00
#[derive(Debug)]
2019-01-30 23:25:02 +03:00
pub(crate) enum Delimiter {
2019-01-30 23:02:27 +03:00
Parenthesis,
Brace,
Bracket,
None,
}
2019-01-31 11:09:19 +03:00
#[derive(Debug)]
2019-01-30 23:25:02 +03:00
pub(crate) struct Literal {
2019-01-30 23:58:52 +03:00
pub(crate) text: SmolStr,
2019-01-30 23:02:27 +03:00
}
2019-01-31 11:09:19 +03:00
#[derive(Debug)]
2019-01-30 23:25:02 +03:00
pub(crate) struct Punct {
2019-01-30 23:58:52 +03:00
pub(crate) char: char,
2019-01-30 23:02:27 +03:00
}
2019-01-31 11:09:19 +03:00
#[derive(Debug)]
2019-01-30 23:25:02 +03:00
pub(crate) struct Ident {
2019-01-30 23:58:52 +03:00
pub(crate) text: SmolStr,
2019-01-30 23:02:27 +03:00
}