diff options
-rw-r--r-- | crates/ra_macros/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_macros/src/mbe_expander.rs | 25 |
2 files changed, 24 insertions, 2 deletions
diff --git a/crates/ra_macros/Cargo.toml b/crates/ra_macros/Cargo.toml index b4fdbfd18..21c128442 100644 --- a/crates/ra_macros/Cargo.toml +++ b/crates/ra_macros/Cargo.toml | |||
@@ -5,4 +5,5 @@ version = "0.1.0" | |||
5 | authors = ["Aleksey Kladov <[email protected]>"] | 5 | authors = ["Aleksey Kladov <[email protected]>"] |
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | rustc_hash = "1.0.0" | ||
8 | smol_str = "0.1.9" | 9 | smol_str = "0.1.9" |
diff --git a/crates/ra_macros/src/mbe_expander.rs b/crates/ra_macros/src/mbe_expander.rs index 426229659..9436baa28 100644 --- a/crates/ra_macros/src/mbe_expander.rs +++ b/crates/ra_macros/src/mbe_expander.rs | |||
@@ -1,5 +1,26 @@ | |||
1 | use rustc_hash::FxHashMap; | ||
2 | use smol_str::SmolStr; | ||
3 | |||
1 | use crate::{mbe, tt}; | 4 | use crate::{mbe, tt}; |
2 | 5 | ||
3 | pub fn exapnd(rules: &mbe::MacroRules, input: tt::Subtree) -> Option<tt::Subtree> { | 6 | pub fn exapnd(rules: &mbe::MacroRules, input: &tt::Subtree) -> Option<tt::Subtree> { |
4 | Some(input) | 7 | rules.rules.iter().find_map(|it| expand_rule(it, input)) |
8 | } | ||
9 | |||
10 | fn expand_rule(rule: &mbe::Rule, input: &tt::Subtree) -> Option<tt::Subtree> { | ||
11 | let bidings = match_lhs(&rule.lhs, input)?; | ||
12 | expand_rhs(&rule.rhs, &bindings) | ||
13 | } | ||
14 | |||
15 | #[derive(Debug, Default)] | ||
16 | struct Bindings { | ||
17 | inner: FxHashMap<SmolStr, tt::TokenTree>, | ||
18 | } | ||
19 | |||
20 | fn match_lhs(pattern: &mbe::TokenTree, input: &tt::Subtree) -> Option<Bindings> { | ||
21 | Some(Bindings::default()) | ||
22 | } | ||
23 | |||
24 | fn expand_rhs(template: &mbe::TokenTree, bindings: &Bindings) -> Option<tt::Subtree> { | ||
25 | None | ||
5 | } | 26 | } |