forked from extern/nushell
help operators
refactor (#13307)
# Description Refactors `help operators` so that its output is always up to date with the parser. # User-Facing Changes - The order of output rows for `help operators` was changed. - `not` is now listed as a boolean operator instead of a comparison operator. - Edited some of the descriptions for the operators.
This commit is contained in:
@ -27,42 +27,9 @@ impl Expression {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn precedence(&self) -> usize {
|
||||
pub fn precedence(&self) -> u8 {
|
||||
match &self.expr {
|
||||
Expr::Operator(operator) => {
|
||||
use super::operator::*;
|
||||
// Higher precedence binds tighter
|
||||
|
||||
match operator {
|
||||
Operator::Math(Math::Pow) => 100,
|
||||
Operator::Math(Math::Multiply)
|
||||
| Operator::Math(Math::Divide)
|
||||
| Operator::Math(Math::Modulo)
|
||||
| Operator::Math(Math::FloorDivision) => 95,
|
||||
Operator::Math(Math::Plus) | Operator::Math(Math::Minus) => 90,
|
||||
Operator::Bits(Bits::ShiftLeft) | Operator::Bits(Bits::ShiftRight) => 85,
|
||||
Operator::Comparison(Comparison::NotRegexMatch)
|
||||
| Operator::Comparison(Comparison::RegexMatch)
|
||||
| Operator::Comparison(Comparison::StartsWith)
|
||||
| Operator::Comparison(Comparison::EndsWith)
|
||||
| Operator::Comparison(Comparison::LessThan)
|
||||
| Operator::Comparison(Comparison::LessThanOrEqual)
|
||||
| Operator::Comparison(Comparison::GreaterThan)
|
||||
| Operator::Comparison(Comparison::GreaterThanOrEqual)
|
||||
| Operator::Comparison(Comparison::Equal)
|
||||
| Operator::Comparison(Comparison::NotEqual)
|
||||
| Operator::Comparison(Comparison::In)
|
||||
| Operator::Comparison(Comparison::NotIn)
|
||||
| Operator::Math(Math::Append) => 80,
|
||||
Operator::Bits(Bits::BitAnd) => 75,
|
||||
Operator::Bits(Bits::BitXor) => 70,
|
||||
Operator::Bits(Bits::BitOr) => 60,
|
||||
Operator::Boolean(Boolean::And) => 50,
|
||||
Operator::Boolean(Boolean::Xor) => 45,
|
||||
Operator::Boolean(Boolean::Or) => 40,
|
||||
Operator::Assignment(_) => 10,
|
||||
}
|
||||
}
|
||||
Expr::Operator(operator) => operator.precedence(),
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user