Skip to content

Commit

Permalink
Removed some warnings in moos parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgagner committed Apr 10, 2024
1 parent fa88281 commit 1de9c79
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 38 deletions.
41 changes: 5 additions & 36 deletions moos-parser/src/moos/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ use crate::lexers::{scan_bool, scan_float, scan_integer, Location};

use core::cmp::max;
use core::str;
use core::str::{CharIndices, ParseBoolError};
use core::str::CharIndices;
use lalrpop_util::ErrorRecovery;
use std::collections::{HashMap, VecDeque};
use std::iter::{Chain, Repeat, Skip};
use std::num::{ParseFloatError, ParseIntError};
use tracing::{debug, error, info, trace, warn};
use tracing::trace;

pub type Spanned<Token, Loc, Error> = Result<(Loc, Token, Loc), Error>;
pub type TokenQueue<'input> = VecDeque<Spanned<Token<'input>, Location, MoosParseError<'input>>>;
Expand Down Expand Up @@ -178,36 +177,6 @@ impl<'input> Lexer<'input> {
None
}

/**
* Drop the unhandled string from an the previous index to the current index
* of a string.
*
* # Parameters:
* * `index`: Current index
*/
#[inline]
fn drop_unhandled_string(&mut self, index: usize) -> Option<(usize, &'input str)> {
let result = if let Some(prev_i) = self.previous_index {
let start_index = prev_i;
let unhandled = &self.input[start_index..index];
if unhandled.is_empty() {
None
} else {
Some((start_index, unhandled))
}
} else {
None
};

if index > 0 {
self.previous_index = self.get_safe_index(index);
} else {
self.previous_index = None;
}

return result;
}

#[inline]
fn _handle_new_line(&mut self, i: usize) {
self.token_queue
Expand Down Expand Up @@ -317,7 +286,7 @@ impl<'input> Lexer<'input> {
);
}

fn tokenize_macro(&mut self, i: usize) {
fn tokenize_macro(&mut self, _i: usize) {
// If its not the start of the line, it can't be a macro.
if !self.start_of_line {
return;
Expand All @@ -332,7 +301,7 @@ impl<'input> Lexer<'input> {

// TODO: We should only skip lines that start with known macros

while let Some(((i, c), (_ii, cc))) = self.iter.find(|&((_i, c), (_ii, cc))| c == '\n') {
while let Some(((i, c), (_ii, _cc))) = self.iter.find(|&((_i, c), (_ii, _cc))| c == '\n') {
match c {
'\n' => {
// Setting the previous index to drop previous tokens
Expand Down Expand Up @@ -520,7 +489,7 @@ impl<'input> Lexer<'input> {

while let Some(((ii, cc), (_iii, _ccc))) = self
.iter
.find(|&((_ii, cc), (_iii, ccc))| cc == '\n' || cc == '}')
.find(|&((_ii, cc), (_iii, _ccc))| cc == '\n' || cc == '}')
{
if cc == '\n' {
// Partial Variable
Expand Down
2 changes: 0 additions & 2 deletions moos-parser/src/moos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ pub mod error;
pub mod lexer;
pub mod tree;

use lalrpop_util::ErrorRecovery;

// lalrpop_mod!(
// #[allow(clippy::all, dead_code, unused_imports, unused_mut)]
// pub moos "moos/moos.rs"
Expand Down

0 comments on commit 1de9c79

Please sign in to comment.