aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_macros/src/tt.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_macros/src/tt.rs')
-rw-r--r--crates/ra_macros/src/tt.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/crates/ra_macros/src/tt.rs b/crates/ra_macros/src/tt.rs
new file mode 100644
index 000000000..364eed9e6
--- /dev/null
+++ b/crates/ra_macros/src/tt.rs
@@ -0,0 +1,45 @@
1use smol_str::SmolStr;
2
3#[derive(Debug)]
4pub enum TokenTree {
5 Leaf(Leaf),
6 Subtree(Subtree),
7}
8impl_froms!(TokenTree: Leaf, Subtree);
9
10#[derive(Debug)]
11pub enum Leaf {
12 Literal(Literal),
13 Punct(Punct),
14 Ident(Ident),
15}
16impl_froms!(Leaf: Literal, Punct, Ident);
17
18#[derive(Debug)]
19pub struct Subtree {
20 pub delimiter: Delimiter,
21 pub token_trees: Vec<TokenTree>,
22}
23
24#[derive(Clone, Copy, Debug)]
25pub enum Delimiter {
26 Parenthesis,
27 Brace,
28 Bracket,
29 None,
30}
31
32#[derive(Debug)]
33pub struct Literal {
34 pub text: SmolStr,
35}
36
37#[derive(Debug)]
38pub struct Punct {
39 pub char: char,
40}
41
42#[derive(Debug)]
43pub struct Ident {
44 pub text: SmolStr,
45}