From 519d6b2bf3081ace12a8cbf9ac369831b2df7fc6 Mon Sep 17 00:00:00 2001 From: Irevoire Date: Tue, 9 Nov 2021 16:47:54 +0100 Subject: [PATCH] remove the `!` syntax for the not --- filter-parser/src/lib.rs | 10 ++++------ filter-parser/src/value.rs | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/filter-parser/src/lib.rs b/filter-parser/src/lib.rs index 3e34e4d96..ed36b1bf4 100644 --- a/filter-parser/src/lib.rs +++ b/filter-parser/src/lib.rs @@ -5,7 +5,7 @@ //! expression = or //! or = and (~ "OR" ~ and) //! and = not (~ "AND" not)* -//! not = ("NOT" | "!") not | primary +//! not = ("NOT" ~ not) | primary //! primary = (WS* ~ "(" expression ")" ~ WS*) | geoRadius | condition | to //! condition = value ("==" | ">" ...) value //! to = value value TO value @@ -169,13 +169,11 @@ fn parse_and(input: Span) -> IResult { Ok((input, expr)) } -/// not = ("NOT" | "!") not | primary +/// not = ("NOT" ~ not) | primary /// We can have multiple consecutive not, eg: `NOT NOT channel = mv`. -/// If we parse a `NOT` or `!` we MUST parse something behind. +/// If we parse a `NOT` we MUST parse something behind. fn parse_not(input: Span) -> IResult { - alt((map(preceded(alt((tag("!"), tag("NOT"))), cut(parse_not)), |e| e.negate()), parse_primary))( - input, - ) + alt((map(preceded(tag("NOT"), cut(parse_not)), |e| e.negate()), parse_primary))(input) } /// geoRadius = WS* ~ "_geoRadius(float ~ "," ~ float ~ "," float) diff --git a/filter-parser/src/value.rs b/filter-parser/src/value.rs index b9d929ab0..936305837 100644 --- a/filter-parser/src/value.rs +++ b/filter-parser/src/value.rs @@ -70,7 +70,7 @@ fn is_value_component(c: char) -> bool { } fn is_syntax_component(c: char) -> bool { - c.is_whitespace() || ['(', ')', '=', '<', '>', '!'].contains(&c) + c.is_whitespace() || ['(', ')', '=', '<', '>'].contains(&c) } #[cfg(test)]