remove the ! syntax for the not

This commit is contained in:
Irevoire 2021-11-09 16:47:54 +01:00
parent 73df873f44
commit 519d6b2bf3
No known key found for this signature in database
GPG Key ID: 7A6A970C96104F1B
2 changed files with 5 additions and 7 deletions

View File

@ -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<FilterCondition> {
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<FilterCondition> {
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)

View File

@ -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)]