Math operators (#1601)

* Add some math operations

* WIP for adding compound expressions

* precedence parsing

* paren expressions

* better lhs handling

* add compound comparisons and shorthand lefthand parsing

* Add or comparison and shorthand paths
This commit is contained in:
Jonathan Turner
2020-04-18 13:50:58 +12:00
committed by GitHub
parent 52d2d2b888
commit 7974e09eeb
21 changed files with 721 additions and 193 deletions

View File

@@ -2,7 +2,7 @@ use crate::data::value::compare_values;
use crate::data::TaggedListBuilder;
use chrono::{DateTime, NaiveDate, Utc};
use nu_errors::ShellError;
use nu_protocol::hir::CompareOperator;
use nu_protocol::hir::Operator;
use nu_protocol::{Primitive, TaggedDictBuilder, UntaggedValue, Value};
use nu_source::{SpannedItem, Tag, Tagged, TaggedItem};
use nu_value_ext::{get_data_by_key, ValueExt};
@@ -317,7 +317,7 @@ pub fn map_max(
let right = &acc.value;
if let Ok(is_greater_than) =
compare_values(CompareOperator::GreaterThan, left, right)
compare_values(Operator::GreaterThan, left, right)
{
if is_greater_than {
value.clone()
@@ -336,9 +336,7 @@ pub fn map_max(
let left = &value.value;
let right = &max.value;
if let Ok(is_greater_than) =
compare_values(CompareOperator::GreaterThan, left, right)
{
if let Ok(is_greater_than) = compare_values(Operator::GreaterThan, left, right) {
if is_greater_than {
value
} else {