diff --git a/src/parser.rs b/src/parser.rs index 65299db..ef0406c 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -17,9 +17,10 @@ pub enum ParseResult { Err(String) } +type Tokens<'a> = Iter<'a,Token>; + macro_rules! expect { ($tok:expr, $tokens:expr) => ( if !expect_token($tok, $tokens) { - println!("yo hitting"); return ParseResult::Err(format!("Expected {:?}", $tok)); }) } @@ -36,7 +37,7 @@ pub fn parse(input: Vec) -> ParseResult { return ParseResult::Err("Bad parse".to_string()); } -fn expect_token(tok: Token, tokens: &mut Iter) -> bool { +fn expect_token(tok: Token, tokens: &mut Tokens) -> bool { if let Some(n) = tokens.next() { let next = (*n).clone(); return match (tok, next) { @@ -55,7 +56,7 @@ fn expect_token(tok: Token, tokens: &mut Iter) -> bool { return false; } -fn let_expression<'a>(input: &mut Iter) -> ParseResult { +fn let_expression(input: &mut Tokens) -> ParseResult { expect!(Identifier("let".to_string()), input); if let Some(&Identifier(ref name)) = input.next() { if let Some(&Identifier(ref s)) = input.next() {