diff options
author | Aleksey Kladov <[email protected]> | 2019-01-30 20:17:32 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-31 20:23:30 +0000 |
commit | ca327f35addd2be36f2463f28c7fc044e5f7cf55 (patch) | |
tree | af26d590d503069a58ca3c5130c435716c33568a /crates/ra_hir/src/macros | |
parent | 6846ac2a166fd8bae1374895179eb452fe62da86 (diff) |
add macro by example ide
Diffstat (limited to 'crates/ra_hir/src/macros')
-rw-r--r-- | crates/ra_hir/src/macros/mbe.rs | 50 |
1 files changed, 50 insertions, 0 deletions
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 | } | ||