| Crates.io | filter-expr |
| lib.rs | filter-expr |
| version | 0.1.15 |
| created_at | 2025-12-23 01:15:07.669712+00 |
| updated_at | 2026-01-23 07:06:09.011075+00 |
| description | A library for parsing the filter expression. |
| homepage | |
| repository | https://github.com/PeterlitsZo/filter-expr |
| max_upload_size | |
| id | 2000557 |
| size | 64,787 |
NOTE: This library is still under development.
A library for parsing the filter expression.
use filter_expr::{FilterExpr, SimpleContext};
let f = FilterExpr::parse("name = 'John' AND age > 18").unwrap();
assert_eq!(f.expr(), Some(Expr::and_([
Expr::eq_(Expr::field_("name"), Expr::str_("John")),
Expr::gt_(Expr::field_("age"), Expr::i64_(18)),
])));
You can evaluate it by yourself or use the filter-expr-evaler crate.
<filter> = <expr> | <empty>
<empty> =
<expr> = <or_test> ('OR' <or_test>)*
<or_test> = <and_test> ('AND' <and_test>)*
<and_test> = ['NOT'] <comparison>
<comparison> = <primary> <operator> <comparison>
| <primary>
<primary> = <func-call>
| <method-call>
| <value>
<operator> = '=' | '>' | '<' | '>=' | '<=' | '!=' | 'IN'
<func-call> = <ident> '(' [<value> (',' <value>)* ','?] ')'
<method-call> = <value> '.' <ident> '(' [<value> (',' <value>)* ','?] ')'
<value> = <str>
| <i64>
| <f64>
| <bool>
| <null>
| <ident>
| <array>
| '(' <expr> ')'
<array> = '[' [<value> (',' <value>)* ','?] ']'