aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_macros/src/mbe_expander.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_macros/src/mbe_expander.rs')
-rw-r--r--crates/ra_macros/src/mbe_expander.rs25
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 @@
1use rustc_hash::FxHashMap;
2use smol_str::SmolStr;
3
1use crate::{mbe, tt}; 4use crate::{mbe, tt};
2 5
3pub fn exapnd(rules: &mbe::MacroRules, input: tt::Subtree) -> Option<tt::Subtree> { 6pub 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
10fn 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)]
16struct Bindings {
17 inner: FxHashMap<SmolStr, tt::TokenTree>,
18}
19
20fn match_lhs(pattern: &mbe::TokenTree, input: &tt::Subtree) -> Option<Bindings> {
21 Some(Bindings::default())
22}
23
24fn expand_rhs(template: &mbe::TokenTree, bindings: &Bindings) -> Option<tt::Subtree> {
25 None
5} 26}