More infra

Don't want EOF after all
This commit is contained in:
greg 2017-09-09 01:27:15 -07:00
parent ea08f8cab8
commit cfefceabf9

View File

@ -25,7 +25,6 @@ pub enum TokenType {
Identifier(Rc<String>),
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<TokenType> {
self.tokens.peek().map(|ref t| { t.token_type.clone() })
}
fn next(&mut self) -> Option<TokenType> {
self.tokens.next().map(|ref t| { t.token_type.clone() })
}
fn program(&mut self) -> ParseResult<AST> {