From cfefceabf989d81a53ec5d6cd4f96a2db1919201 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 9 Sep 2017 01:27:15 -0700 Subject: [PATCH] More infra Don't want EOF after all --- src/schala_lang/parsing.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/schala_lang/parsing.rs b/src/schala_lang/parsing.rs index 1ca16c4..3516067 100644 --- a/src/schala_lang/parsing.rs +++ b/src/schala_lang/parsing.rs @@ -25,7 +25,6 @@ pub enum TokenType { Identifier(Rc), Keyword(Kw), - EOF, Error(String), } @@ -287,8 +286,12 @@ impl Parser { Parser { tokens: input.into_iter().peekable() } } - fn peek(&mut self) -> TokenType { - self.tokens.peek().map(|ref t| { t.token_type.clone() }).unwrap_or(TokenType::EOF) + fn peek(&mut self) -> Option { + self.tokens.peek().map(|ref t| { t.token_type.clone() }) + } + + fn next(&mut self) -> Option { + self.tokens.next().map(|ref t| { t.token_type.clone() }) } fn program(&mut self) -> ParseResult {