aboutsummaryrefslogtreecommitdiff
path: root/karlc/src/pretty.rs
diff options
context:
space:
mode:
authormetamuffin <yvchraiqi@protonmail.com>2022-06-11 14:32:45 +0200
committermetamuffin <yvchraiqi@protonmail.com>2022-06-11 14:32:45 +0200
commitc2699d114c921ab2ceb1f467b32a26257dddcf3d (patch)
tree0e886d333d944094c8c66905cac36a21cd010405 /karlc/src/pretty.rs
parent9769c17c0b4c271c1cfbe726b19a6d3f9250c7c8 (diff)
downloadkarlender-c2699d114c921ab2ceb1f467b32a26257dddcf3d.tar
karlender-c2699d114c921ab2ceb1f467b32a26257dddcf3d.tar.bz2
karlender-c2699d114c921ab2ceb1f467b32a26257dddcf3d.tar.zst
changing the protocol again
Diffstat (limited to 'karlc/src/pretty.rs')
-rw-r--r--karlc/src/pretty.rs24
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)
+ }
+ }
}
}