Browse Source

Fix warnings

github-actions
Garrit Franke 3 years ago
parent
commit
5253ced2af
  1. 10
      src/lexer/cursor.rs
  2. 7
      src/lexer/mod.rs

10
src/lexer/cursor.rs

@ -6,7 +6,6 @@ use std::str::Chars;
/// Next characters can be peeked via `nth_char` method,
/// and position can be shifted forward via `bump` method.
pub(crate) struct Cursor<'a> {
initial_length: usize,
pos: &'a mut Position,
len: usize,
chars: Chars<'a>,
@ -16,13 +15,8 @@ pub(crate) struct Cursor<'a> {
pub(crate) const EOF_CHAR: char = '\0';
impl<'a> Cursor<'a> {
pub(crate) fn new(
input: &'a str,
initial_len: usize,
position: &'a mut Position,
) -> Cursor<'a> {
pub(crate) fn new(input: &'a str, position: &'a mut Position) -> Cursor<'a> {
Cursor {
initial_length: initial_len,
len: input.len(),
chars: input.chars(),
#[cfg(debug_assertions)]
@ -74,7 +68,7 @@ impl<'a> Cursor<'a> {
}
pub(crate) fn pos(&self) -> Position {
let mut p = self.pos.clone();
let p = self.pos.clone();
p
}

7
src/lexer/mod.rs

@ -102,7 +102,6 @@ pub enum Keyword {
/// Creates an iterator that produces tokens from the input string.
pub fn tokenize(mut input: &str) -> Vec<Token> {
let initial_length = input.len();
let mut pos = Position {
raw: usize::MAX,
line: 1,
@ -112,7 +111,7 @@ pub fn tokenize(mut input: &str) -> Vec<Token> {
if input.is_empty() {
return None;
}
let token = first_token(input, initial_length, &mut pos);
let token = first_token(input, &mut pos);
input = &input[token.len..];
Some(token)
})
@ -120,9 +119,9 @@ pub fn tokenize(mut input: &str) -> Vec<Token> {
}
/// Parses the first token from the provided input string.
pub fn first_token(input: &str, initial_len: usize, pos: &mut Position) -> Token {
pub fn first_token(input: &str, pos: &mut Position) -> Token {
debug_assert!(!input.is_empty());
Cursor::new(input, initial_len, pos).advance_token()
Cursor::new(input, pos).advance_token()
}
pub fn is_whitespace(c: char) -> bool {

Loading…
Cancel
Save