diff options
Diffstat (limited to 'crates/ra_macros/src/tt.rs')
-rw-r--r-- | crates/ra_macros/src/tt.rs | 45 |
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 @@ | |||
1 | use smol_str::SmolStr; | ||
2 | |||
3 | #[derive(Debug)] | ||
4 | pub enum TokenTree { | ||
5 | Leaf(Leaf), | ||
6 | Subtree(Subtree), | ||
7 | } | ||
8 | impl_froms!(TokenTree: Leaf, Subtree); | ||
9 | |||
10 | #[derive(Debug)] | ||
11 | pub enum Leaf { | ||
12 | Literal(Literal), | ||
13 | Punct(Punct), | ||
14 | Ident(Ident), | ||
15 | } | ||
16 | impl_froms!(Leaf: Literal, Punct, Ident); | ||
17 | |||
18 | #[derive(Debug)] | ||
19 | pub struct Subtree { | ||
20 | pub delimiter: Delimiter, | ||
21 | pub token_trees: Vec<TokenTree>, | ||
22 | } | ||
23 | |||
24 | #[derive(Clone, Copy, Debug)] | ||
25 | pub enum Delimiter { | ||
26 | Parenthesis, | ||
27 | Brace, | ||
28 | Bracket, | ||
29 | None, | ||
30 | } | ||
31 | |||
32 | #[derive(Debug)] | ||
33 | pub struct Literal { | ||
34 | pub text: SmolStr, | ||
35 | } | ||
36 | |||
37 | #[derive(Debug)] | ||
38 | pub struct Punct { | ||
39 | pub char: char, | ||
40 | } | ||
41 | |||
42 | #[derive(Debug)] | ||
43 | pub struct Ident { | ||
44 | pub text: SmolStr, | ||
45 | } | ||