From d4a24eef7fd410c147de201d776089e0601317d5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 12 Jun 2020 00:48:18 +0200 Subject: 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. --- src/fexpr/mod.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/fexpr/mod.rs') 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>; +trait DurationProducer = filters::values::Producer; + lalrpop_mod!(#[allow(clippy::all)] pub grammar, "/fexpr/grammar.rs"); #[derive(Debug)] -- cgit v1.2.3 From e23af286b81f4c9df0e0ca9d71113caeb909cb0f Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 12 Jun 2020 13:21:35 +0200 Subject: implement count(player: ...) construct --- src/fexpr/mod.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/fexpr/mod.rs') diff --git a/src/fexpr/mod.rs b/src/fexpr/mod.rs index 1738e44..f765acf 100644 --- a/src/fexpr/mod.rs +++ b/src/fexpr/mod.rs @@ -13,6 +13,7 @@ use thiserror::Error; trait DateProducer = filters::values::Producer>; trait DurationProducer = filters::values::Producer; +trait CountProducer = filters::values::Producer; lalrpop_mod!(#[allow(clippy::all)] pub grammar, "/fexpr/grammar.rs"); -- cgit v1.2.3 From a8481afdac21b8b846d5fe159678972a879b11c0 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 12 Jun 2020 13:44:19 +0200 Subject: add a comment about the trait aliases --- src/fexpr/mod.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/fexpr/mod.rs') diff --git a/src/fexpr/mod.rs b/src/fexpr/mod.rs index f765acf..5d12051 100644 --- a/src/fexpr/mod.rs +++ b/src/fexpr/mod.rs @@ -11,6 +11,8 @@ use itertools::Itertools; use lalrpop_util::{lalrpop_mod, lexer::Token, ParseError}; use thiserror::Error; +// Lalrpop chokes on the associated type specification (it doesn't expect the =), so we need to +// define those aliases here in Rust and then import and use them in the grammar. trait DateProducer = filters::values::Producer>; trait DurationProducer = filters::values::Producer; trait CountProducer = filters::values::Producer; -- cgit v1.2.3