mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Fix clippy warnings
This commit is contained in:
parent
90fd900b8f
commit
17a435c7a6
1 changed files with 24 additions and 27 deletions
|
@ -12,15 +12,15 @@ use std::iter::Peekable;
|
||||||
|
|
||||||
/// Represents one of the binary comparison operators for strings, integers, or files
|
/// Represents one of the binary comparison operators for strings, integers, or files
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Op {
|
pub enum Operator {
|
||||||
StringOp(OsString),
|
String(OsString),
|
||||||
IntOp(OsString),
|
Int(OsString),
|
||||||
FileOp(OsString),
|
File(OsString),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents one of the unary test operators for strings or files
|
/// Represents one of the unary test operators for strings or files
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum UnaryOp {
|
pub enum UnaryOperator {
|
||||||
StrlenOp(OsString),
|
StrlenOp(OsString),
|
||||||
FiletestOp(OsString),
|
FiletestOp(OsString),
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ pub enum Symbol {
|
||||||
Bang,
|
Bang,
|
||||||
BoolOp(OsString),
|
BoolOp(OsString),
|
||||||
Literal(OsString),
|
Literal(OsString),
|
||||||
Op(Op),
|
Op(Operator),
|
||||||
UnaryOp(UnaryOp),
|
UnaryOp(UnaryOperator),
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,13 +47,13 @@ impl Symbol {
|
||||||
"(" => Symbol::LParen,
|
"(" => Symbol::LParen,
|
||||||
"!" => Symbol::Bang,
|
"!" => Symbol::Bang,
|
||||||
"-a" | "-o" => Symbol::BoolOp(s),
|
"-a" | "-o" => Symbol::BoolOp(s),
|
||||||
"=" | "==" | "!=" => Symbol::Op(Op::StringOp(s)),
|
"=" | "==" | "!=" => Symbol::Op(Operator::String(s)),
|
||||||
"-eq" | "-ge" | "-gt" | "-le" | "-lt" | "-ne" => Symbol::Op(Op::IntOp(s)),
|
"-eq" | "-ge" | "-gt" | "-le" | "-lt" | "-ne" => Symbol::Op(Operator::Int(s)),
|
||||||
"-ef" | "-nt" | "-ot" => Symbol::Op(Op::FileOp(s)),
|
"-ef" | "-nt" | "-ot" => Symbol::Op(Operator::File(s)),
|
||||||
"-n" | "-z" => Symbol::UnaryOp(UnaryOp::StrlenOp(s)),
|
"-n" | "-z" => Symbol::UnaryOp(UnaryOperator::StrlenOp(s)),
|
||||||
"-b" | "-c" | "-d" | "-e" | "-f" | "-g" | "-G" | "-h" | "-k" | "-L" | "-O"
|
"-b" | "-c" | "-d" | "-e" | "-f" | "-g" | "-G" | "-h" | "-k" | "-L" | "-O"
|
||||||
| "-p" | "-r" | "-s" | "-S" | "-t" | "-u" | "-w" | "-x" => {
|
| "-p" | "-r" | "-s" | "-S" | "-t" | "-u" | "-w" | "-x" => {
|
||||||
Symbol::UnaryOp(UnaryOp::FiletestOp(s))
|
Symbol::UnaryOp(UnaryOperator::FiletestOp(s))
|
||||||
}
|
}
|
||||||
_ => Symbol::Literal(s),
|
_ => Symbol::Literal(s),
|
||||||
},
|
},
|
||||||
|
@ -74,11 +74,11 @@ impl Symbol {
|
||||||
Symbol::Bang => OsString::from("!"),
|
Symbol::Bang => OsString::from("!"),
|
||||||
Symbol::BoolOp(s)
|
Symbol::BoolOp(s)
|
||||||
| Symbol::Literal(s)
|
| Symbol::Literal(s)
|
||||||
| Symbol::Op(Op::StringOp(s))
|
| Symbol::Op(Operator::String(s))
|
||||||
| Symbol::Op(Op::IntOp(s))
|
| Symbol::Op(Operator::Int(s))
|
||||||
| Symbol::Op(Op::FileOp(s))
|
| Symbol::Op(Operator::File(s))
|
||||||
| Symbol::UnaryOp(UnaryOp::StrlenOp(s))
|
| Symbol::UnaryOp(UnaryOperator::StrlenOp(s))
|
||||||
| Symbol::UnaryOp(UnaryOp::FiletestOp(s)) => s,
|
| Symbol::UnaryOp(UnaryOperator::FiletestOp(s)) => s,
|
||||||
Symbol::None => panic!(),
|
Symbol::None => panic!(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -373,18 +373,15 @@ impl Parser {
|
||||||
self.stack.push(token.into_literal());
|
self.stack.push(token.into_literal());
|
||||||
|
|
||||||
// EXPR → str OP str
|
// EXPR → str OP str
|
||||||
match self.peek() {
|
if let Symbol::Op(_) = self.peek() {
|
||||||
Symbol::Op(_) => {
|
let op = self.next_token();
|
||||||
let op = self.next_token();
|
|
||||||
|
|
||||||
match self.next_token() {
|
match self.next_token() {
|
||||||
Symbol::None => panic!("missing argument after {:?}", op),
|
Symbol::None => panic!("missing argument after {:?}", op),
|
||||||
token => self.stack.push(token.into_literal()),
|
token => self.stack.push(token.into_literal()),
|
||||||
}
|
|
||||||
|
|
||||||
self.stack.push(op);
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
|
self.stack.push(op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue