lexer: rename peek to peek_buf

This commit is contained in:
Evan Shaw 2022-09-15 09:22:53 +12:00
parent ebd3798a24
commit 4cb19078c4

View File

@ -122,7 +122,7 @@ impl Lexer {
} }
fn scripting(&mut self) -> Result<Token, LexerError> { fn scripting(&mut self) -> Result<Token, LexerError> {
let kind = match self.peek() { let kind = match self.peek_buf() {
[b'@', ..] => { [b'@', ..] => {
self.next(); self.next();
self.col += 1; self.col += 1;
@ -310,7 +310,7 @@ impl Lexer {
let mut buffer = vec![b'/']; let mut buffer = vec![b'/'];
while self.current.is_some() { while self.current.is_some() {
match self.peek() { match self.peek_buf() {
[b'*', b'/', ..] => { [b'*', b'/', ..] => {
self.col += 2; self.col += 2;
buffer.extend_from_slice(b"*/"); buffer.extend_from_slice(b"*/");
@ -732,12 +732,12 @@ impl Lexer {
self.state = state; self.state = state;
} }
fn peek(&self) -> &[u8] { fn peek_buf(&self) -> &[u8] {
&self.chars[self.cursor..] &self.chars[self.cursor..]
} }
fn try_read(&self, search: &'static [u8]) -> bool { fn try_read(&self, search: &'static [u8]) -> bool {
self.peek().starts_with(search) self.peek_buf().starts_with(search)
} }
fn skip(&mut self, count: usize) { fn skip(&mut self, count: usize) {