aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-30 20:17:32 +0000
committerAleksey Kladov <[email protected]>2019-01-31 20:23:30 +0000
commitca327f35addd2be36f2463f28c7fc044e5f7cf55 (patch)
treeaf26d590d503069a58ca3c5130c435716c33568a /crates/ra_hir/src
parent6846ac2a166fd8bae1374895179eb452fe62da86 (diff)
add macro by example ide
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/macros.rs2
-rw-r--r--crates/ra_hir/src/macros/mbe.rs50
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)]
2mod tt; 2mod tt;
3#[allow(unused)]
4mod 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 @@
1use ra_syntax::SmolStr;
2
3struct MacroRules {
4 rules: Vec<Rule>,
5}
6
7struct Rule {
8 lhs: TokenTree,
9 rhs: TokenTree,
10}
11
12enum TokenTree {
13 Leaf(Leaf),
14 Subtree(Subtree),
15}
16
17enum Leaf {
18 Literal(Literal),
19 Punct(Punct),
20 Ident(Ident),
21 Var(Var),
22}
23
24struct Subtree {
25 delimiter: Delimiter,
26 token_trees: Vec<TokenTree>,
27}
28
29enum Delimiter {
30 Parenthesis,
31 Brace,
32 Bracket,
33 None,
34}
35
36struct Literal {
37 text: SmolStr,
38}
39
40struct Punct {
41 char: char,
42}
43
44struct Ident {
45 text: SmolStr,
46}
47
48struct Var {
49 text: SmolStr,
50}