From ca327f35addd2be36f2463f28c7fc044e5f7cf55 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 30 Jan 2019 23:17:32 +0300 Subject: add macro by example ide --- crates/ra_hir/src/macros.rs | 2 ++ crates/ra_hir/src/macros/mbe.rs | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 crates/ra_hir/src/macros/mbe.rs 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 @@ #[allow(unused)] mod tt; +#[allow(unused)] +mod mbe; /// Machinery for macro expansion. /// 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 @@ +use ra_syntax::SmolStr; + +struct MacroRules { + rules: Vec, +} + +struct Rule { + lhs: TokenTree, + rhs: TokenTree, +} + +enum TokenTree { + Leaf(Leaf), + Subtree(Subtree), +} + +enum Leaf { + Literal(Literal), + Punct(Punct), + Ident(Ident), + Var(Var), +} + +struct Subtree { + delimiter: Delimiter, + token_trees: Vec, +} + +enum Delimiter { + Parenthesis, + Brace, + Bracket, + None, +} + +struct Literal { + text: SmolStr, +} + +struct Punct { + char: char, +} + +struct Ident { + text: SmolStr, +} + +struct Var { + text: SmolStr, +} -- cgit v1.2.3