Simplify parsing by expecting the tokens stream will never be exhausted.

This commit is contained in:
Stephen Chung
2020-04-23 13:24:24 +08:00
parent a4bf572d5a
commit 5aaaa7be3b
3 changed files with 91 additions and 103 deletions

View File

@@ -991,6 +991,8 @@ impl<'a> TokenIterator<'a> {
}
('~', _) => return Some((Token::PowerOf, pos)),
('\0', _) => panic!("should not be EOF"),
(ch, _) if ch.is_whitespace() => (),
(ch, _) => return Some((Token::LexError(Box::new(LERR::UnexpectedChar(ch))), pos)),
}