diff options
Diffstat (limited to 'karlc/src/pretty.rs')
-rw-r--r-- | karlc/src/pretty.rs | 24 |
1 files changed, 17 insertions, 7 deletions
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) + } + } } } |