diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/macros.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/macros/mbe.rs | 50 |
2 files changed, 52 insertions, 0 deletions
diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs index 5ad5cf51f..6190b2c08 100644 --- a/crates/ra_hir/src/macros.rs +++ b/crates/ra_hir/src/macros.rs | |||
@@ -1,5 +1,7 @@ | |||
1 | #[allow(unused)] | 1 | #[allow(unused)] |
2 | mod tt; | 2 | mod tt; |
3 | #[allow(unused)] | ||
4 | mod mbe; | ||
3 | 5 | ||
4 | /// Machinery for macro expansion. | 6 | /// Machinery for macro expansion. |
5 | /// | 7 | /// |
diff --git a/crates/ra_hir/src/macros/mbe.rs b/crates/ra_hir/src/macros/mbe.rs new file mode 100644 index 000000000..5c1771a15 --- /dev/null +++ b/crates/ra_hir/src/macros/mbe.rs | |||
@@ -0,0 +1,50 @@ | |||
1 | use ra_syntax::SmolStr; | ||
2 | |||
3 | struct MacroRules { | ||
4 | rules: Vec<Rule>, | ||
5 | } | ||
6 | |||
7 | struct Rule { | ||
8 | lhs: TokenTree, | ||
9 | rhs: TokenTree, | ||
10 | } | ||
11 | |||
12 | enum TokenTree { | ||
13 | Leaf(Leaf), | ||
14 | Subtree(Subtree), | ||
15 | } | ||
16 | |||
17 | enum Leaf { | ||
18 | Literal(Literal), | ||
19 | Punct(Punct), | ||
20 | Ident(Ident), | ||
21 | Var(Var), | ||
22 | } | ||
23 | |||
24 | struct Subtree { | ||
25 | delimiter: Delimiter, | ||
26 | token_trees: Vec<TokenTree>, | ||
27 | } | ||
28 | |||
29 | enum Delimiter { | ||
30 | Parenthesis, | ||
31 | Brace, | ||
32 | Bracket, | ||
33 | None, | ||
34 | } | ||
35 | |||
36 | struct Literal { | ||
37 | text: SmolStr, | ||
38 | } | ||
39 | |||
40 | struct Punct { | ||
41 | char: char, | ||
42 | } | ||
43 | |||
44 | struct Ident { | ||
45 | text: SmolStr, | ||
46 | } | ||
47 | |||
48 | struct Var { | ||
49 | text: SmolStr, | ||
50 | } | ||