Used checked next in require
This commit is contained in:
parent
77c201476b
commit
04b44fb01e
|
@ -120,11 +120,10 @@ impl<'source> Parser<'source> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Require next item to be equal with expected one
|
/// Require next item to be equal with expected one
|
||||||
fn require(&mut self, expected: Token) -> Result<(), Error> {
|
fn require(&mut self, required: Token) -> Result<(), Error> {
|
||||||
match self.lexer.next() {
|
match self.checked_next()? {
|
||||||
Some(t) if t == expected => Ok(()),
|
t if t == required => Ok(()),
|
||||||
Some(t) => Err(Error::new(ErrorKind::UnexpectedToken(t), self.lexer.span())),
|
t => Err(Error::new(ErrorKind::UnexpectedToken(t), self.lexer.span())),
|
||||||
None => Err(Error::unexpected_eof(self.lexer.span().start)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue