rename previous to peek previous

This commit is contained in:
Josh Thomas 2024-10-16 09:33:21 -05:00
parent 52eea54ed7
commit 74ea421ee6
2 changed files with 3 additions and 7 deletions

View file

@ -239,12 +239,8 @@ impl<'a> Scanner for Lexer<'a> {
self.item_at(self.state.current + 1)
}
fn previous(&self) -> Result<Self::Item, Self::Error> {
if self.state.current > 0 {
self.item_at(self.state.current - 1)
} else {
Err(LexerError::AtBeginningOfInput)
}
fn peek_previous(&self) -> Result<Self::Item, Self::Error> {
self.item_at(self.state.current - 1)
}
fn item_at(&self, index: usize) -> Result<Self::Item, Self::Error> {

View file

@ -23,7 +23,7 @@ pub trait Scanner {
fn advance(&mut self) -> Result<Self::Item, Self::Error>;
fn peek(&self) -> Result<Self::Item, Self::Error>;
fn peek_next(&self) -> Result<Self::Item, Self::Error>;
fn previous(&self) -> Result<Self::Item, Self::Error>;
fn peek_previous(&self) -> Result<Self::Item, Self::Error>;
fn item_at(&self, index: usize) -> Result<Self::Item, Self::Error>;
fn is_at_end(&self) -> bool;
}