From 5213dd327fed8482875f72a4eb45d76fe0ff07e4 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 22 Jul 2015 03:42:21 -0700 Subject: [PATCH] Change type to peekable --- src/parser.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index ef0406c..66c0e05 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,4 +1,5 @@ use std::slice::Iter; +use std::iter::Peekable; use tokenizer::{Token}; use tokenizer::Token::*; @@ -17,7 +18,7 @@ pub enum ParseResult { Err(String) } -type Tokens<'a> = Iter<'a,Token>; +type Tokens<'a> = Peekable>; macro_rules! expect { ($tok:expr, $tokens:expr) => ( if !expect_token($tok, $tokens) { @@ -27,7 +28,7 @@ macro_rules! expect { pub fn parse(input: Vec) -> ParseResult { - let mut tokens = input.iter(); + let mut tokens: Tokens = input.iter().peekable(); if let ParseResult::Ok(ast) = let_expression(&mut tokens) { expect!(EOF, &mut tokens);