From c22cc3b348bdcb446fb0e44070da36fdf6b05800 Mon Sep 17 00:00:00 2001 From: tslil Date: Sat, 21 Mar 2026 08:49:35 +0000 Subject: big rework to support evaluation of selection functions, WiP --- rprt-engine/src/evaluate.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 rprt-engine/src/evaluate.rs (limited to 'rprt-engine/src/evaluate.rs') diff --git a/rprt-engine/src/evaluate.rs b/rprt-engine/src/evaluate.rs new file mode 100644 index 0000000..f6fee8a --- /dev/null +++ b/rprt-engine/src/evaluate.rs @@ -0,0 +1,43 @@ +use crate::{ + expression::Composite, + selection::{Selection, VectoriseError}, + selection_functions::{evaluate_selection_function, SFError}, + state::{EditorState, StateResult}, +}; + +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum EvaluationError { + #[error("{0}")] + SelectionFunctionError(VectoriseError), + #[error("Not yet implemented {0}")] + UnimplementedError(&'static str), +} + +pub fn evaluate( + es: &EditorState, + comp: Composite, + left: Option, + right: Option, +) -> Result { + match comp { + Composite::SelectionFunction { + func, + search_mod, + result_transform, + } => { + let sel = + evaluate_selection_function(es, func, search_mod, result_transform, left, right) + .map_err(EvaluationError::SelectionFunctionError)?; + Ok((sel, Vec::new())) + } + Composite::TextFunction { func, swapped } => { + Err(EvaluationError::UnimplementedError("text function")) + } + Composite::Hook { kind, left, right } => Err(EvaluationError::UnimplementedError("hook")), + Composite::Train2 { f, g } => Err(EvaluationError::UnimplementedError("train2")), + Composite::Train3 { f, g, h } => Err(EvaluationError::UnimplementedError("train3")), + Composite::Group { operations } => Err(EvaluationError::UnimplementedError("group")), + } +} -- cgit v1.2.3