diff options
Diffstat (limited to 'crates/ra_macros/src')
-rw-r--r-- | crates/ra_macros/src/mbe_expander.rs | 25 |
1 files changed, 23 insertions, 2 deletions
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 | } |