aboutsummaryrefslogtreecommitdiff
path: root/src/fexpr/mod.rs
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2020-06-12 00:48:18 +0200
committerDaniel <kingdread@gmx.de>2020-06-12 00:48:18 +0200
commitd4a24eef7fd410c147de201d776089e0601317d5 (patch)
tree8311b261c20d6d5f2d817f63e2cf4a3b213cdd34 /src/fexpr/mod.rs
parent1fb3d3259d23410f8bf9879f64de880a11e4f876 (diff)
downloadraidgrep-d4a24eef7fd410c147de201d776089e0601317d5.tar.gz
raidgrep-d4a24eef7fd410c147de201d776089e0601317d5.tar.bz2
raidgrep-d4a24eef7fd410c147de201d776089e0601317d5.zip
initial work on comparison based filters
This enables filters such as -time > 2020-01-01 -time < 2020-02-03 ... for time and duration, and later possibly also for more things (such as a COUNT(...) construct). This work tries to integrate them into the existing filter system as seamless as possible, by providing a Comparator which implements LogFilter. The "type checking" is done at parse time, so nonsensical comparisons like -time > 12s flat out give a parse error. This however might be changed to a more dynamic system with run-time type checking, in which case we could do away with the type parameter on Producer and simply work with a generic Value. The comparator would then return an error if two non-identical types would be compared. Note that the system does not support arithmetic expressions, only simple comparisons to constant values.
Diffstat (limited to 'src/fexpr/mod.rs')
-rw-r--r--src/fexpr/mod.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/fexpr/mod.rs b/src/fexpr/mod.rs
index c6a3a39..1738e44 100644
--- a/src/fexpr/mod.rs
+++ b/src/fexpr/mod.rs
@@ -11,6 +11,9 @@ use itertools::Itertools;
use lalrpop_util::{lalrpop_mod, lexer::Token, ParseError};
use thiserror::Error;
+trait DateProducer = filters::values::Producer<Output = chrono::DateTime<chrono::Utc>>;
+trait DurationProducer = filters::values::Producer<Output = chrono::Duration>;
+
lalrpop_mod!(#[allow(clippy::all)] pub grammar, "/fexpr/grammar.rs");
#[derive(Debug)]