Parse a predicate expression string into a compiled `RlsPredicate`. Grammar: ```text expr = or_expr or_expr = and_expr ("OR" and_expr) and_expr = atom ("AND" atom) atom = comparison | contains | intersects | "NOT" atom | "(" expr ")" comparison = field_ref op value_ref contains = value_ref "CONTAINS" value_ref intersects = value_ref "INTERSECTS" value_ref field_ref = identifier |
(input: &str)
| 21 | /// value_ref = literal | field_ref |
| 22 | /// ``` |
| 23 | pub fn parse_predicate(input: &str) -> Result<RlsPredicate, PredicateParseError> { |
| 24 | let tokens = tokenize(input)?; |
| 25 | let mut pos = 0; |
| 26 | let result = parse_or_expr(&tokens, &mut pos)?; |
| 27 | if pos < tokens.len() { |
| 28 | return Err(PredicateParseError::UnexpectedToken { |
| 29 | token: tokens[pos].clone(), |
| 30 | position: pos, |
| 31 | }); |
| 32 | } |
| 33 | Ok(result) |
| 34 | } |
| 35 | |
| 36 | /// Predicate parse errors. |
| 37 | #[derive(Debug, Clone, thiserror::Error)] |