Add exactly equal operator (==)
This commit is contained in:
parent
70dfe88dff
commit
92e9f17ade
3 changed files with 8 additions and 0 deletions
|
@ -42,6 +42,10 @@ pub fn div(a: &Literal, b: &Literal) -> Result<Literal, Error> {
|
||||||
Ok(Literal::from(a / b))
|
Ok(Literal::from(a / b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn exact(a: &Literal, b: &Literal) -> Result<Literal, Error> {
|
||||||
|
Ok(Literal::from(a == b))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn equal(a: &Literal, b: &Literal) -> Result<Literal, Error> {
|
pub fn equal(a: &Literal, b: &Literal) -> Result<Literal, Error> {
|
||||||
match a {
|
match a {
|
||||||
Literal::None => Ok(Literal::from(b.is_none() == true)),
|
Literal::None => Ok(Literal::from(b.is_none() == true)),
|
||||||
|
|
|
@ -77,6 +77,7 @@ impl dbs::Process for Expression {
|
||||||
Operator::Mul => fnc::operate::mul(&l, &r),
|
Operator::Mul => fnc::operate::mul(&l, &r),
|
||||||
Operator::Div => fnc::operate::div(&l, &r),
|
Operator::Div => fnc::operate::div(&l, &r),
|
||||||
Operator::Equal => fnc::operate::equal(&l, &r),
|
Operator::Equal => fnc::operate::equal(&l, &r),
|
||||||
|
Operator::Exact => fnc::operate::exact(&l, &r),
|
||||||
Operator::NotEqual => fnc::operate::not_equal(&l, &r),
|
Operator::NotEqual => fnc::operate::not_equal(&l, &r),
|
||||||
Operator::AllEqual => fnc::operate::all_equal(&l, &r),
|
Operator::AllEqual => fnc::operate::all_equal(&l, &r),
|
||||||
Operator::AnyEqual => fnc::operate::any_equal(&l, &r),
|
Operator::AnyEqual => fnc::operate::any_equal(&l, &r),
|
||||||
|
|
|
@ -19,6 +19,7 @@ pub enum Operator {
|
||||||
Dec, // -=
|
Dec, // -=
|
||||||
//
|
//
|
||||||
Equal, // =
|
Equal, // =
|
||||||
|
Exact, // ==
|
||||||
NotEqual, // !=
|
NotEqual, // !=
|
||||||
AllEqual, // *=
|
AllEqual, // *=
|
||||||
AnyEqual, // ?=
|
AnyEqual, // ?=
|
||||||
|
@ -64,6 +65,7 @@ impl fmt::Display for Operator {
|
||||||
Operator::Inc => write!(f, "+="),
|
Operator::Inc => write!(f, "+="),
|
||||||
Operator::Dec => write!(f, "-="),
|
Operator::Dec => write!(f, "-="),
|
||||||
Operator::Equal => write!(f, "="),
|
Operator::Equal => write!(f, "="),
|
||||||
|
Operator::Exact => write!(f, "=="),
|
||||||
Operator::NotEqual => write!(f, "!="),
|
Operator::NotEqual => write!(f, "!="),
|
||||||
Operator::AllEqual => write!(f, "*="),
|
Operator::AllEqual => write!(f, "*="),
|
||||||
Operator::AnyEqual => write!(f, "?="),
|
Operator::AnyEqual => write!(f, "?="),
|
||||||
|
@ -111,6 +113,7 @@ pub fn operator(i: &str) -> IResult<&str, Operator> {
|
||||||
)),
|
)),
|
||||||
alt((
|
alt((
|
||||||
map(tag("="), |_| Operator::Equal),
|
map(tag("="), |_| Operator::Equal),
|
||||||
|
map(tag("=="), |_| Operator::Exact),
|
||||||
map(tag("!="), |_| Operator::NotEqual),
|
map(tag("!="), |_| Operator::NotEqual),
|
||||||
map(tag("*="), |_| Operator::AllEqual),
|
map(tag("*="), |_| Operator::AllEqual),
|
||||||
map(tag("?="), |_| Operator::AnyEqual),
|
map(tag("?="), |_| Operator::AnyEqual),
|
||||||
|
|
Loading…
Reference in a new issue