Scanner - Moved is_at_end()

This commit is contained in:
Emmanuel BENOîT 2022-12-30 18:21:17 +01:00
parent 8bdfbe59de
commit 5af93af827

View file

@ -81,6 +81,11 @@ impl Scanner {
}
}
/// Check whether the end of the input has been reached.
fn is_at_end(&self) -> bool {
self.current >= self.len
}
/// Advance to the next character and return it.
fn advance(&mut self) -> char {
let ch = self.cur_char();
@ -105,11 +110,6 @@ impl Scanner {
self.source.chars().nth(self.current).unwrap()
}
/// Check whether the end of the input has been reached.
fn is_at_end(&self) -> bool {
self.current >= self.len
}
/// Add a token to the output.
fn add_token(&mut self, token_type: TokenType) {
let lexeme = self