Skip to content

Commit

Permalink
Factor out NamedParseResult.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Nov 12, 2016
1 parent eef10d0 commit 68abb24
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/libsyntax/ext/tt/macro_parser.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)> {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 68abb24

Please sign in to comment.