diff options
author | Aleksey Kladov <[email protected]> | 2019-01-30 20:02:27 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-31 20:23:30 +0000 |
commit | b8f56f89c64f65b5a7d9c75f81597c28fba63b48 (patch) | |
tree | fbd24d2039f6bcad922210d7a3dd6bdc1f29b3c3 | |
parent | 1bf47d43db631e096a0125b596fccad021ce6c2c (diff) |
start token tree module
-rw-r--r-- | crates/ra_hir/src/macros.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir/src/macros/token_tree.rs | 36 |
2 files changed, 39 insertions, 0 deletions
diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs index 7ca34d434..9aa706836 100644 --- a/crates/ra_hir/src/macros.rs +++ b/crates/ra_hir/src/macros.rs | |||
@@ -1,3 +1,6 @@ | |||
1 | #[allow(unused)] | ||
2 | mod token_tree; | ||
3 | |||
1 | /// Machinery for macro expansion. | 4 | /// Machinery for macro expansion. |
2 | /// | 5 | /// |
3 | /// One of the more complicated things about macros is managing the source code | 6 | /// One of the more complicated things about macros is managing the source code |
diff --git a/crates/ra_hir/src/macros/token_tree.rs b/crates/ra_hir/src/macros/token_tree.rs new file mode 100644 index 000000000..7026ce3b3 --- /dev/null +++ b/crates/ra_hir/src/macros/token_tree.rs | |||
@@ -0,0 +1,36 @@ | |||
1 | use ra_syntax::SmolStr; | ||
2 | |||
3 | enum TokenTree { | ||
4 | Leaf(Leaf), | ||
5 | Subtree(Subtree), | ||
6 | } | ||
7 | |||
8 | enum Leaf { | ||
9 | Literal(Literal), | ||
10 | Punct(Punct), | ||
11 | Ident(Ident), | ||
12 | } | ||
13 | |||
14 | struct Subtree { | ||
15 | delimiter: Delimiter, | ||
16 | token_trees: Vec<TokenTree>, | ||
17 | } | ||
18 | |||
19 | enum Delimiter { | ||
20 | Parenthesis, | ||
21 | Brace, | ||
22 | Bracket, | ||
23 | None, | ||
24 | } | ||
25 | |||
26 | struct Literal { | ||
27 | text: SmolStr, | ||
28 | } | ||
29 | |||
30 | struct Punct { | ||
31 | char: char, | ||
32 | } | ||
33 | |||
34 | struct Ident { | ||
35 | text: SmolStr, | ||
36 | } | ||