mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 21:47:04 +00:00
more expand boilerplate
This commit is contained in:
parent
09a8d75351
commit
d2a1e07150
@ -5,4 +5,5 @@ version = "0.1.0"
|
||||
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
rustc_hash = "1.0.0"
|
||||
smol_str = "0.1.9"
|
||||
|
@ -1,5 +1,26 @@
|
||||
use rustc_hash::FxHashMap;
|
||||
use smol_str::SmolStr;
|
||||
|
||||
use crate::{mbe, tt};
|
||||
|
||||
pub fn exapnd(rules: &mbe::MacroRules, input: tt::Subtree) -> Option<tt::Subtree> {
|
||||
Some(input)
|
||||
pub fn exapnd(rules: &mbe::MacroRules, input: &tt::Subtree) -> Option<tt::Subtree> {
|
||||
rules.rules.iter().find_map(|it| expand_rule(it, input))
|
||||
}
|
||||
|
||||
fn expand_rule(rule: &mbe::Rule, input: &tt::Subtree) -> Option<tt::Subtree> {
|
||||
let bidings = match_lhs(&rule.lhs, input)?;
|
||||
expand_rhs(&rule.rhs, &bindings)
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct Bindings {
|
||||
inner: FxHashMap<SmolStr, tt::TokenTree>,
|
||||
}
|
||||
|
||||
fn match_lhs(pattern: &mbe::TokenTree, input: &tt::Subtree) -> Option<Bindings> {
|
||||
Some(Bindings::default())
|
||||
}
|
||||
|
||||
fn expand_rhs(template: &mbe::TokenTree, bindings: &Bindings) -> Option<tt::Subtree> {
|
||||
None
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user