mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
Factor out NamedParseResult.
This commit is contained in:
parent
eef10d0b5b
commit
68abb24e8d
@ -143,6 +143,8 @@ pub struct MatcherPos {
|
||||
sp_lo: BytePos,
|
||||
}
|
||||
|
||||
pub type NamedParseResult = ParseResult<HashMap<Ident, Rc<NamedMatch>>>;
|
||||
|
||||
pub fn count_names(ms: &[TokenTree]) -> usize {
|
||||
ms.iter().fold(0, |count, elt| {
|
||||
count + match *elt {
|
||||
@ -200,8 +202,7 @@ pub enum NamedMatch {
|
||||
MatchedNonterminal(Rc<Nonterminal>)
|
||||
}
|
||||
|
||||
fn nameize(ms: &[TokenTree], res: &[Rc<NamedMatch>])
|
||||
-> ParseResult<HashMap<Ident, Rc<NamedMatch>>> {
|
||||
fn nameize(ms: &[TokenTree], res: &[Rc<NamedMatch>]) -> NamedParseResult {
|
||||
fn n_rec(m: &TokenTree, res: &[Rc<NamedMatch>],
|
||||
ret_val: &mut HashMap<Ident, Rc<NamedMatch>>, idx: &mut usize)
|
||||
-> Result<(), (syntax_pos::Span, String)> {
|
||||
@ -265,8 +266,6 @@ pub fn parse_failure_msg(tok: Token) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
pub type NamedParseResult = ParseResult<HashMap<Ident, Rc<NamedMatch>>>;
|
||||
|
||||
/// Perform a token equality check, ignoring syntax context (that is, an
|
||||
/// unhygienic comparison)
|
||||
pub fn token_name_eq(t1 : &Token, t2 : &Token) -> bool {
|
||||
|
Loading…
Reference in New Issue
Block a user