From c2699d114c921ab2ceb1f467b32a26257dddcf3d Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 11 Jun 2022 14:32:45 +0200 Subject: changing the protocol again --- karlc/src/pretty.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'karlc/src/pretty.rs') diff --git a/karlc/src/pretty.rs b/karlc/src/pretty.rs index bf9cf20..abd5f96 100644 --- a/karlc/src/pretty.rs +++ b/karlc/src/pretty.rs @@ -7,10 +7,14 @@ pub fn indent(s: &str) -> String { pub fn fmt_condition(c: &Condition) -> String { match c { Condition::From(_) => todo!(), - Condition::Or(_) => todo!(), + Condition::Or(cs) => cs + .iter() + .map(|e| format!("{{ {} }}", fmt_condition(e))) + .reduce(|a, b| format!("{} ∨ {}", a, b)) + .unwrap_or("never".to_string()), Condition::And(cs) => cs .iter() - .map(|e| fmt_condition(e)) + .map(|e| format!("{{ {} }}", fmt_condition(e))) .reduce(|a, b| format!("{} ∧ {}", a, b)) .unwrap_or("never".to_string()), Condition::Invert(_) => todo!(), @@ -26,10 +30,16 @@ pub fn fmt_condition(c: &Condition) -> String { } } Condition::Range { - prop: _, - min: _, - max: _, - modulus: _, - } => todo!(), + prop, + min, + max, + modulus, + } => { + if let Some(m) = modulus { + format!("{} < {:?} < {} (mod {})", min, prop, max, m) + } else { + format!("{} < {:?} < {}", min, prop, max) + } + } } } -- cgit v1.2.3-70-g09d2