Merge pull request #2563 from rleungx/allow-underscore

allow underscore in macro_rules!
This commit is contained in:
Seiichi Uchida 2018-03-28 12:41:51 +09:00 committed by GitHub
commit 0f55350c7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 1 deletions

View file

@ -460,7 +460,7 @@ fn replace_names(input: &str) -> Option<(String, HashMap<String, String>)> {
} else if c == '(' && cur_name.is_empty() {
// FIXME: Support macro def with repeat.
return None;
} else if c.is_alphanumeric() {
} else if c.is_alphanumeric() || c == '_' {
cur_name.push(c);
}
}

View file

@ -168,3 +168,23 @@ macro_rules! add_message_to_notes {
}
}}
}
// #2560
macro_rules! binary {
($_self:ident,$expr:expr, $lhs:expr,$func:ident) => {
while $_self.matched($expr) {
let op = $_self.get_binary_op()?;
let rhs = Box::new($_self.$func()?);
$lhs = Spanned {
span: $lhs.get_span().to(rhs.get_span()),
value: Expression::Binary {
lhs: Box::new($lhs),
op,
rhs,
},
}
}
};
}

View file

@ -200,3 +200,23 @@ macro_rules! add_message_to_notes {
}
}};
}
// #2560
macro_rules! binary {
($_self:ident, $expr:expr, $lhs:expr, $func:ident) => {
while $_self.matched($expr) {
let op = $_self.get_binary_op()?;
let rhs = Box::new($_self.$func()?);
$lhs = Spanned {
span: $lhs.get_span().to(rhs.get_span()),
value: Expression::Binary {
lhs: Box::new($lhs),
op,
rhs,
},
}
}
};
}