more expand boilerplate

This commit is contained in:
Aleksey Kladov 2019-01-31 13:59:39 +03:00
parent d2a1e07150
commit 2def5b4e6f
3 changed files with 5 additions and 4 deletions

1
Cargo.lock generated
View file

@ -1022,6 +1022,7 @@ dependencies = [
name = "ra_macros" name = "ra_macros"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"smol_str 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "smol_str 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View file

@ -5,5 +5,5 @@ version = "0.1.0"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"] authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
[dependencies] [dependencies]
rustc_hash = "1.0.0" rustc-hash = "1.0.0"
smol_str = "0.1.9" smol_str = "0.1.9"

View file

@ -8,7 +8,7 @@ pub fn exapnd(rules: &mbe::MacroRules, input: &tt::Subtree) -> Option<tt::Subtre
} }
fn expand_rule(rule: &mbe::Rule, input: &tt::Subtree) -> Option<tt::Subtree> { fn expand_rule(rule: &mbe::Rule, input: &tt::Subtree) -> Option<tt::Subtree> {
let bidings = match_lhs(&rule.lhs, input)?; let bindings = match_lhs(&rule.lhs, input)?;
expand_rhs(&rule.rhs, &bindings) expand_rhs(&rule.rhs, &bindings)
} }
@ -17,10 +17,10 @@ struct Bindings {
inner: FxHashMap<SmolStr, tt::TokenTree>, inner: FxHashMap<SmolStr, tt::TokenTree>,
} }
fn match_lhs(pattern: &mbe::TokenTree, input: &tt::Subtree) -> Option<Bindings> { fn match_lhs(pattern: &mbe::Subtree, input: &tt::Subtree) -> Option<Bindings> {
Some(Bindings::default()) Some(Bindings::default())
} }
fn expand_rhs(template: &mbe::TokenTree, bindings: &Bindings) -> Option<tt::Subtree> { fn expand_rhs(template: &mbe::Subtree, bindings: &Bindings) -> Option<tt::Subtree> {
None None
} }