Skip to content

Commit

Permalink
refactor: added three functions of the basic validation logic (template)
Browse files Browse the repository at this point in the history
  • Loading branch information
m62624 committed Sep 9, 2023
1 parent 4cb01bf commit e786d39
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ where
R: CalculateValueRules<'a, C>,
C: IntoSpecificCaptureType<'a>,
{
let mut temp_stack: VecDeque<(&R::RuleType, CaptureData<C>)> = VecDeque::new();
if let Some(mut frame) = stack.pop_front() {}
// let mut temp_stack: Stack<'a, R, C> = VecDeque::new();
// if let Some(mut frame) = stack.pop_front() {}
NextStep::Finish
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ where
R: CalculateValueRules<'a, C>,
C: IntoSpecificCaptureType<'a>,
{
let mut temp_stack: VecDeque<(&R::RuleType, CaptureData<C>)> = VecDeque::new();
if let Some(mut frame) = stack.pop_front() {}
// let mut temp_stack: Stack<'a, R, C> = VecDeque::new();
// if let Some(mut frame) = stack.pop_front() {}
NextStep::Finish
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ where
R: CalculateValueRules<'a, C>,
C: IntoSpecificCaptureType<'a>,
{
if let Some(mut frame) = stack.pop_front() {}

// if let Some(mut frame) = stack.pop_front() {}
NextStep::Finish
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ where
R: CalculateValueRules<'a, C>,
C: IntoSpecificCaptureType<'a>,
{
let mut temp_stack: Option<VecDeque<(&R::RuleType, CaptureData<C>)>> = Some(VecDeque::new());
if let Some(mut frame) = stack.pop_front() {}
// let mut temp_stack: Option<Stack<'a, R, C>> = Some(VecDeque::new());
// if let Some(mut frame) = stack.pop_front() {}
NextStep::Finish
}
45 changes: 19 additions & 26 deletions flexible_inspect_rs/src/rules/runner/context_match/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod at_least_one_rule_for_all_matches;
mod at_least_one_rule_for_at_least_one_match;
// =======================================================
use super::*;
use crate::rules::traits::RuleBase;
use crate::rules::{next::NextStep, traits::CalculateValueRules, CaptureData};
pub use all_rules_for_all_matches::all_rules_for_all_matches;
pub use all_rules_for_at_least_one_match::all_rules_for_at_least_one_match;
Expand All @@ -15,38 +14,32 @@ use log::{debug, error, info, trace};
use std::collections::{HashMap, HashSet, VecDeque};
use std::fmt::Debug;

#[derive(Debug)]
pub struct FrameStack<'a, R, C>
pub type Stack<'a, R: CalculateValueRules<'a, C>, C: IntoSpecificCaptureType<'a>> =
VecDeque<(R::RuleType, CaptureData<'a, C>)>;

pub fn part_one<'a, R, C, F>(func: F, temp_stack: Option<Stack<'a, R, C>>) -> NextStep
where
R: CalculateValueRules<'a, C>,
C: IntoSpecificCaptureType<'a>,
C: IntoSpecificCaptureType<'a> + 'a,
F: FnMut(Stack<'a, R, C>) -> NextStep,
{
rule: &'a R::RuleType,
capture: CaptureData<'a, C>,
NextStep::Finish
}

impl<'a, R, C> FrameStack<'a, R, C>
pub fn part_two<'a, R, C, F>(func: F, temp_stack: Option<Stack<'a, R, C>>) -> NextStep
where
R: CalculateValueRules<'a, C>,
C: IntoSpecificCaptureType<'a>,
C: IntoSpecificCaptureType<'a> + 'a,
F: FnMut(Stack<'a, R, C>) -> NextStep,
{
pub fn new(rule: &'a R::RuleType, capture: CaptureData<'a, C>) -> Self {
Self { rule, capture }
}
NextStep::Finish
}

// pub fn rules_in_category_regexset<'a, R, C, F>(
// // get a unique stack of one root rule, necessary to bypass the recursion constraint
// frame: FrameStack<'a, R, C>,
// callback: F,
// ) -> NextStep
// where
// R: CalculateValueRules<'a, C>,
// C: IntoSpecificCaptureType<'a>,
// F: FnOnce(FrameStack<'a, R, C>) -> NextStep,
// {
// if let Some(simple_rules) = frame.rule.get_simple_rules() {
// return callback(frame);
// }
// NextStep::Finish
// }
pub fn part_three<'a, R, C, F>(func: F, temp_stack: Option<Stack<'a, R, C>>) -> NextStep
where
R: CalculateValueRules<'a, C>,
C: IntoSpecificCaptureType<'a> + 'a,
F: FnMut(Stack<'a, R, C>) -> NextStep,
{
NextStep::Finish
}

0 comments on commit e786d39

Please sign in to comment.