From bbff61f71a5e04f3cb69dbed8885c8eb3300260d Mon Sep 17 00:00:00 2001 From: elvis Date: Wed, 18 Jun 2025 11:28:04 +0200 Subject: [PATCH] Print methods --- src/main.rs | 88 +++++---- src/rsprocess/grammar.lalrpop | 10 +- src/rsprocess/mod.rs | 1 + src/rsprocess/perpetual.rs | 0 src/rsprocess/structure.rs | 55 +++--- src/rsprocess/transitions.rs | 14 +- src/rsprocess/translator.rs | 330 ++++++++++++++++++++++++++++++++-- 7 files changed, 415 insertions(+), 83 deletions(-) create mode 100644 src/rsprocess/perpetual.rs diff --git a/src/main.rs b/src/main.rs index 8b43ce3..a3cfdc3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ mod rsprocess; use lalrpop_util::lalrpop_mod; -use std::rc::Rc; +use rsprocess::translator::WithTranslator; +// use std::rc::Rc; // use std::io; fn main() -> Result<(), Box> { @@ -51,19 +52,19 @@ fn main() -> Result<(), Box> { // let process = grammar::ContextParser::new().parse(&mut translator, "[]").unwrap(); // let sys = rsprocess::structure::RSsystem::from(Rc::new(*env), - // rsprocess::structure::RSset::from(vec![translator.convert("a"), - // translator.convert("b")]), + // rsprocess::structure::RSset::from(vec![translator.encode("a"), + // translator.encode("b")]), // *process, // Rc::new(vec![ // rsprocess::structure::RSreaction::from( - // rsprocess::structure::RSset::from(vec![translator.convert("a")]), - // rsprocess::structure::RSset::from(vec![translator.convert("c")]), - // rsprocess::structure::RSset::from(vec![translator.convert("a")]) + // rsprocess::structure::RSset::from(vec![translator.encode("a")]), + // rsprocess::structure::RSset::from(vec![translator.encode("c")]), + // rsprocess::structure::RSset::from(vec![translator.encode("a")]) // ), // rsprocess::structure::RSreaction::from( - // rsprocess::structure::RSset::from(vec![translator.convert("b")]), - // rsprocess::structure::RSset::from(vec![translator.convert("d")]), - // rsprocess::structure::RSset::from(vec![translator.convert("b")]) + // rsprocess::structure::RSset::from(vec![translator.encode("b")]), + // rsprocess::structure::RSset::from(vec![translator.encode("d")]), + // rsprocess::structure::RSset::from(vec![translator.encode("b")]) // ) // ])); @@ -79,14 +80,14 @@ fn main() -> Result<(), Box> { // *process, // Rc::new(vec![ // rsprocess::structure::RSreaction::from( - // rsprocess::structure::RSset::from(vec![translator.convert("a")]), - // rsprocess::structure::RSset::from(vec![translator.convert("c")]), - // rsprocess::structure::RSset::from(vec![translator.convert("a")]) + // rsprocess::structure::RSset::from(vec![translator.encode("a")]), + // rsprocess::structure::RSset::from(vec![translator.encode("c")]), + // rsprocess::structure::RSset::from(vec![translator.encode("a")]) // ), // rsprocess::structure::RSreaction::from( - // rsprocess::structure::RSset::from(vec![translator.convert("b")]), - // rsprocess::structure::RSset::from(vec![translator.convert("d")]), - // rsprocess::structure::RSset::from(vec![translator.convert("b")]) + // rsprocess::structure::RSset::from(vec![translator.encode("b")]), + // rsprocess::structure::RSset::from(vec![translator.encode("d")]), + // rsprocess::structure::RSset::from(vec![translator.encode("b")]) // ) // ])); @@ -103,14 +104,14 @@ fn main() -> Result<(), Box> { // *process, // Rc::new(vec![ // rsprocess::structure::RSreaction::from( - // rsprocess::structure::RSset::from(vec![translator.convert("a")]), - // rsprocess::structure::RSset::from(vec![translator.convert("c")]), - // rsprocess::structure::RSset::from(vec![translator.convert("a")]) + // rsprocess::structure::RSset::from(vec![translator.encode("a")]), + // rsprocess::structure::RSset::from(vec![translator.encode("c")]), + // rsprocess::structure::RSset::from(vec![translator.encode("a")]) // ), // rsprocess::structure::RSreaction::from( - // rsprocess::structure::RSset::from(vec![translator.convert("b")]), - // rsprocess::structure::RSset::from(vec![translator.convert("d")]), - // rsprocess::structure::RSset::from(vec![translator.convert("b")]) + // rsprocess::structure::RSset::from(vec![translator.encode("b")]), + // rsprocess::structure::RSset::from(vec![translator.encode("d")]), + // rsprocess::structure::RSset::from(vec![translator.encode("b")]) // ) // ])); @@ -122,24 +123,33 @@ fn main() -> Result<(), Box> { // } // ------------------------------------------------------------------------- - let env = grammar::EnvironmentParser::new().parse(&mut translator, "[]").unwrap(); - let process = grammar::ContextParser::new().parse(&mut translator, "[({a}.nil + {b}.nil),({c}.nil + {d}.nil)]").unwrap(); + // let env = grammar::EnvironmentParser::new().parse(&mut translator, "[]").unwrap(); + // let process = grammar::ContextParser::new().parse(&mut translator, "[({a}.nil + {b}.nil),({c}.nil + {d}.nil)]").unwrap(); - let sys = rsprocess::structure::RSsystem::from(Rc::new(*env), - rsprocess::structure::RSset::from(vec![]), - *process, - Rc::new(vec![ - rsprocess::structure::RSreaction::from( - rsprocess::structure::RSset::from(vec![translator.convert("a")]), - rsprocess::structure::RSset::from(vec![translator.convert("c")]), - rsprocess::structure::RSset::from(vec![translator.convert("a")]) - ), - rsprocess::structure::RSreaction::from( - rsprocess::structure::RSset::from(vec![translator.convert("b")]), - rsprocess::structure::RSset::from(vec![translator.convert("d")]), - rsprocess::structure::RSset::from(vec![translator.convert("b")]) - ) - ])); - println!("{:?}", rsprocess::transitions::run_separated(&sys)); + // let sys = rsprocess::structure::RSsystem::from(Rc::new(*env), + // rsprocess::structure::RSset::from(vec![]), + // *process, + // Rc::new(vec![ + // rsprocess::structure::RSreaction::from( + // rsprocess::structure::RSset::from(vec![translator.encode("a")]), + // rsprocess::structure::RSset::from(vec![translator.encode("c")]), + // rsprocess::structure::RSset::from(vec![translator.encode("a")]) + // ), + // rsprocess::structure::RSreaction::from( + // rsprocess::structure::RSset::from(vec![translator.encode("b")]), + // rsprocess::structure::RSset::from(vec![translator.encode("d")]), + // rsprocess::structure::RSset::from(vec![translator.encode("b")]) + // ) + // ])); + // println!("{:?}", rsprocess::transitions::run_separated(&sys)); + + // ------------------------------------------------------------------------- + + let tmp = rsprocess::structure::RSreaction::from( + rsprocess::structure::RSset::from(vec![translator.encode("a"), translator.encode("c")]), + rsprocess::structure::RSset::from(vec![translator.encode("c")]), + rsprocess::structure::RSset::from(vec![translator.encode("a")]) + ); + println!("{}", WithTranslator::from_RSreaction(&translator, &tmp)); Ok(()) } diff --git a/src/rsprocess/grammar.lalrpop b/src/rsprocess/grammar.lalrpop index 0371079..0f94e0d 100644 --- a/src/rsprocess/grammar.lalrpop +++ b/src/rsprocess/grammar.lalrpop @@ -33,9 +33,9 @@ pub Set: RSset = { Set_of_entities: RSset = { "{" "}" => RSset::from(vec![]), - "{" "}" => RSset::from(vec![translator.convert(t)]), + "{" "}" => RSset::from(vec![translator.encode(t)]), "{" > "}" => - RSset::from(t.into_iter().map(|t| translator.convert(t)).collect::>()) + RSset::from(t.into_iter().map(|t| translator.encode(t)).collect::>()) }; // ----- ContextParser ----- @@ -61,14 +61,14 @@ CTX_process: RSprocess = { RSprocess::EntitySet{ entities: c, next_process: Rc::new(k) }, "(" ")" => k, "(" > ")" => - RSprocess::Summation{ children: k.into_iter().map(|k| Rc::new(k)).collect::>() }, + RSprocess::Summation{ children: k.into_iter().map(Rc::new).collect::>() }, "<" ">" "." => RSprocess::WaitEntity{ repeat: n, repeated_process: Rc::new(k1), next_process: Rc::new(k)}, "nil" => RSprocess::Nill, => - RSprocess::RecursiveIdentifier{ identifier: translator.convert(identifier) } + RSprocess::RecursiveIdentifier{ identifier: translator.encode(identifier) } }; // ----- EnvironmentParser ----- @@ -79,7 +79,7 @@ pub Environment: Box = { Env_term: (IdType, RSprocess) = { "=" => - (translator.convert(identifier), k) + (translator.encode(identifier), k) }; // ----- AssertParser ----- diff --git a/src/rsprocess/mod.rs b/src/rsprocess/mod.rs index ab7a2bf..ce489ff 100644 --- a/src/rsprocess/mod.rs +++ b/src/rsprocess/mod.rs @@ -3,3 +3,4 @@ pub mod structure; pub mod support_structures; pub mod classical; pub mod transitions; +pub mod perpetual; diff --git a/src/rsprocess/perpetual.rs b/src/rsprocess/perpetual.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/rsprocess/structure.rs b/src/rsprocess/structure.rs index 0dda472..7380495 100644 --- a/src/rsprocess/structure.rs +++ b/src/rsprocess/structure.rs @@ -73,6 +73,10 @@ impl RSset { .collect(); RSset { identifiers: res } } + + pub fn hashset(&self) -> &HashSet { + &self.identifiers + } } @@ -167,21 +171,21 @@ impl RSprocess { } #[derive(Clone, Debug)] -pub struct RSChoices { +pub struct RSchoices { context_moves: Vec<(Rc, Rc)> } -impl RSChoices { +impl RSchoices { pub fn new() -> Self { - RSChoices{ context_moves: vec![] } + RSchoices{ context_moves: vec![] } } pub fn new_not_empty() -> Self { - RSChoices{ context_moves: vec![(Rc::new(RSset::new()), + RSchoices{ context_moves: vec![(Rc::new(RSset::new()), Rc::new(RSprocess::Nill))] } } - pub fn append(&mut self, a: &mut RSChoices) { + pub fn append(&mut self, a: &mut RSchoices) { self.context_moves.append(&mut a.context_moves); } @@ -192,7 +196,7 @@ impl RSChoices { .map(|(c1, _)| (Rc::clone(c1), Rc::clone(&a))).collect::>(); } - pub fn shuffle(&mut self, choices: RSChoices) { + pub fn shuffle(&mut self, choices: RSchoices) { match (self.context_moves.is_empty(), choices.context_moves.is_empty()){ (true, true) => {} (true, false) => { self.context_moves = choices.context_moves } @@ -211,9 +215,13 @@ impl RSChoices { } } } + + pub fn iter(&self) -> std::slice::Iter<'_, (Rc, Rc)> { + self.context_moves.iter() + } } -impl IntoIterator for RSChoices { +impl IntoIterator for RSchoices { type Item = (Rc, Rc); type IntoIter = std::vec::IntoIter; @@ -222,21 +230,22 @@ impl IntoIterator for RSChoices { } } -impl From<[(Rc, Rc); N]> for RSChoices { + +impl From<[(Rc, Rc); N]> for RSchoices { fn from(arr: [(Rc, Rc); N]) -> Self { - RSChoices{context_moves: arr.to_vec()} + RSchoices{context_moves: arr.to_vec()} } } -impl From<&[(Rc, Rc)]> for RSChoices { +impl From<&[(Rc, Rc)]> for RSchoices { fn from(arr: &[(Rc, Rc)]) -> Self { - RSChoices{context_moves: arr.to_vec()} + RSchoices{context_moves: arr.to_vec()} } } -impl From, Rc)>> for RSChoices { +impl From, Rc)>> for RSchoices { fn from(arr: Vec<(Rc, Rc)>) -> Self { - RSChoices{context_moves: arr} + RSchoices{context_moves: arr} } } @@ -256,6 +265,10 @@ impl RSenvironment { pub fn get(&self, k: IdType) -> Option<&RSprocess> { self.definitions.get(&k) } + + pub fn iter(&self) -> std::collections::hash_map::Iter<'_, u32, RSprocess> { + self.definitions.iter() + } } impl From<[(IdType, RSprocess); N]> for RSenvironment { @@ -329,14 +342,14 @@ impl RSsystem { // ----------------------------------------------------------------------------- #[derive(Clone, Debug)] pub struct RSlabel { - available_entities: RSset, - context: RSset, - t: RSset, /// union of available_entities and context - reactants: RSset, - reactantsi: RSset, - inihibitors: RSset, - ireactants: RSset, - products: RSset, + pub available_entities: RSset, + pub context: RSset, + pub t: RSset, /// union of available_entities and context + pub reactants: RSset, + pub reactantsi: RSset, + pub inihibitors: RSset, + pub ireactants: RSset, + pub products: RSset, } impl RSlabel { diff --git a/src/rsprocess/transitions.rs b/src/rsprocess/transitions.rs index 1251381..0aa6040 100644 --- a/src/rsprocess/transitions.rs +++ b/src/rsprocess/transitions.rs @@ -1,15 +1,15 @@ #![allow(dead_code)] -use super::structure::{RSChoices, RSenvironment, RSlabel, RSprocess, RSset, RSsystem}; +use super::structure::{RSchoices, RSenvironment, RSlabel, RSprocess, RSset, RSsystem}; use super::support_structures::TransitionsIterator; use std::rc::Rc; pub fn unfold( environment: &RSenvironment, context_process: &RSprocess, -) -> Result { +) -> Result { match context_process { - RSprocess::Nill => Ok(RSChoices::new()), + RSprocess::Nill => Ok(RSchoices::new()), RSprocess::RecursiveIdentifier { identifier } => { let newprocess = environment.get(*identifier); if let Some(newprocess) = newprocess { @@ -21,7 +21,7 @@ pub fn unfold( RSprocess::EntitySet { entities, next_process, - } => Ok(RSChoices::from(vec![( + } => Ok(RSchoices::from(vec![( Rc::new(entities.clone()), Rc::clone(next_process), )])), @@ -54,7 +54,7 @@ pub fn unfold( } RSprocess::Summation { children } => { // short-circuits with try_fold. - children.iter().try_fold(RSChoices::new(), |mut acc, x| { + children.iter().try_fold(RSchoices::new(), |mut acc, x| { match unfold(environment, x) { Ok(mut choices) => { acc.append(&mut choices); @@ -67,12 +67,12 @@ pub fn unfold( RSprocess::NondeterministicChoice { children } => { // short-circuits with try_fold. if children.is_empty() { - Ok(RSChoices::from(vec![( + Ok(RSchoices::from(vec![( Rc::new(RSset::new()), Rc::new(RSprocess::Nill), )])) } else { - children.iter().try_fold(RSChoices::new(), |mut acc, x| { + children.iter().try_fold(RSchoices::new(), |mut acc, x| { acc.shuffle(unfold(environment, x)?); Ok(acc) }) diff --git a/src/rsprocess/translator.rs b/src/rsprocess/translator.rs index 20a520c..44d5cf5 100644 --- a/src/rsprocess/translator.rs +++ b/src/rsprocess/translator.rs @@ -1,5 +1,4 @@ // translate and keeps track of strings - use std::collections::HashMap; pub type IdType = u32; @@ -7,23 +6,332 @@ pub type IdType = u32; #[derive(Clone, Debug)] pub struct Translator { strings: HashMap, - last_id: IdType + reverse: HashMap, + last_id: IdType, } impl Translator { pub fn new() -> Self { - Translator { strings: HashMap::new(), last_id: 0 } + Translator { + strings: HashMap::new(), + reverse: HashMap::new(), + last_id: 0, + } } - - } impl Translator { - pub fn convert(&mut self, s: impl Into) -> IdType { - *(self.strings.entry(s.into()).or_insert( - {self.last_id += 1; - self.last_id - } - )) + pub fn encode(&mut self, s: impl Into) -> IdType { + let s = s.into(); + let id = *(self.strings.entry(s.clone()).or_insert({ + self.last_id += 1; + self.last_id + })); + self.reverse.insert(id, s.clone()); + id + } + + pub fn decode(&self, el: IdType) -> String { + // TODO maybe find more efficient method?? + self.reverse.get(&el) + .map(|x| x.to_string()) + .unwrap_or(String::from("Not Found")) } } + +// ----------------------------------------------------------------------------- +use super::structure::{ + RSassert, RSassertOp, RSchoices, RSenvironment, RSlabel, RSprocess, RSreaction, RSset, + RSsystem, RSBHML, +}; +use std::fmt; + +#[allow(clippy::large_enum_variant)] +#[allow(clippy::upper_case_acronyms)] +#[derive(Clone, Debug)] +pub enum WithTranslator<'a> { + RSset { + translator: &'a Translator, + set: &'a RSset, + }, + RSreaction { + translator: &'a Translator, + reaction: &'a RSreaction, + }, + RSprocess { + translator: &'a Translator, + process: &'a RSprocess, + }, + RSchoices { + translator: &'a Translator, + choices: &'a RSchoices, + }, + RSenvironment { + translator: &'a Translator, + environment: &'a RSenvironment, + }, + RSsystem { + translator: &'a Translator, + system: &'a RSsystem, + }, + RSlabel { + translator: &'a Translator, + label: &'a RSlabel, + }, + RSassertOp { + translator: &'a Translator, + assert_op: &'a RSassertOp, + }, + RSassert { + translator: &'a Translator, + assert: &'a RSassert, + }, + RSBHML { + translator: &'a Translator, + bhml: &'a RSBHML, + }, +} + +macro_rules! from_RS { + ($name:ident, $type:ty, $dataname:ident, $type2: ident) => { + pub fn $name(translator: &'a Translator, $dataname: &'a $type) -> Self { + WithTranslator::$type2 { translator, $dataname } + } + }; +} + +#[allow(non_snake_case)] +#[allow(dead_code)] +impl<'a> WithTranslator<'a> { + from_RS!(from_RSset, RSset, set, RSset); + + from_RS!(from_RSreaction, RSreaction, reaction, RSreaction); + + from_RS!(from_RSprocess, RSprocess, process, RSprocess); + + from_RS!(from_RSchoices, RSchoices, choices, RSchoices); + + from_RS!(from_RSenvironment, RSenvironment, environment, RSenvironment); + + from_RS!(from_RSsystem, RSsystem, system, RSsystem); + + from_RS!(from_RSlabel, RSlabel, label, RSlabel); + + from_RS!(from_RSassertOp, RSassertOp, assert_op, RSassertOp); + + from_RS!(from_RSassert, RSassert, assert, RSassert); + + from_RS!(from_RSBHML, RSBHML, bhml, RSBHML); +} + + +// ----------------------------------------------------------------------------- +// Printing functions +// ----------------------------------------------------------------------------- + +fn print_set(f: &mut fmt::Formatter, translator: &Translator, set: &RSset) -> fmt::Result { + write!(f, "{{")?; + let mut it = set.hashset().iter().peekable(); + while let Some(el) = it.next() { + if it.peek().is_none() { + write!(f, "{}", translator.decode(*el))?; + } else { + write!(f, "{}, ", translator.decode(*el))?; + } + } + write!(f, "}}") +} + +fn print_reaction(f: &mut fmt::Formatter, translator: &Translator, reaction: &RSreaction) -> fmt::Result { + write!(f, "(r: {}, i: {}, p: {})", + WithTranslator::from_RSset(translator, reaction.reactants()), + WithTranslator::from_RSset(translator, reaction.inihibitors()), + WithTranslator::from_RSset(translator, reaction.products())) +} + +fn print_process(f: &mut fmt::Formatter, translator: &Translator, process: &RSprocess) -> fmt::Result { + use super::structure::RSprocess::*; + match process { + Nill => { + write!(f, "[Nill]") + }, + RecursiveIdentifier{ identifier } => { + write!(f, "[{}]", translator.decode(*identifier)) + }, + EntitySet{ entities, + next_process } => { + write!(f, "[entities: {}, next_process: {}]", + WithTranslator::from_RSset(translator, entities), + WithTranslator::from_RSprocess(translator, next_process) + ) + }, + WaitEntity{ repeat, + repeated_process, + next_process } => { + write!(f, "[repeat: {repeat}, repeated_process: {}, next_process: {}]", + WithTranslator::from_RSprocess(translator, repeated_process), + WithTranslator::from_RSprocess(translator, next_process) + ) + }, + Summation{ children } => { + write!(f, "[")?; + let mut it = children.iter().peekable(); + while let Some(child) = it.next() { + if it.peek().is_none() { + write!(f, "{}", + WithTranslator::from_RSprocess(translator, child) + )?; + } else { + write!(f, "{} + ", + WithTranslator::from_RSprocess(translator, child) + )?; + } + } + write!(f, "]") + }, + NondeterministicChoice{ children } => { + write!(f, "[")?; + let mut it = children.iter().peekable(); + while let Some(child) = it.next() { + if it.peek().is_none() { + write!(f, "{}", + WithTranslator::from_RSprocess(translator, child) + )?; + } else { + write!(f, "{}, ", + WithTranslator::from_RSprocess(translator, child) + )?; + } + } + write!(f, "]") + } + } +} + +fn print_choices(f: &mut fmt::Formatter, translator: &Translator, choices: &RSchoices) -> fmt::Result { + write!(f, "[")?; + let mut it = choices.iter().peekable(); + while let Some(el) = it.next() { + if it.peek().is_none() { + write!(f, "[set: {}, process: {}]", + WithTranslator::from_RSset(translator, &el.0), + WithTranslator::from_RSprocess(translator, &el.1))?; + } else { + write!(f, "[set: {}, process: {}], ", + WithTranslator::from_RSset(translator, &el.0), + WithTranslator::from_RSprocess(translator, &el.1))?; + } + } + write!(f, "]") +} + +fn print_environment(f: &mut fmt::Formatter, translator: &Translator, environment: &RSenvironment) -> fmt::Result { + write!(f, "{{env:")?; + let mut it = environment.iter().peekable(); + while let Some(el) = it.next() { + if it.peek().is_none() { + write!(f, "({} -> {})", + translator.decode(*el.0), + WithTranslator::from_RSprocess(translator, el.1) + )?; + } else { + write!(f, "({} -> {}), ", + translator.decode(*el.0), + WithTranslator::from_RSprocess(translator, el.1) + )?; + } + } + write!(f, "}}") +} + +fn print_system(f: &mut fmt::Formatter, translator: &Translator, system: &RSsystem) -> fmt::Result { + write!(f, "[delta: {}, available_entities: {}, context_process: {}, reaction_rules: [", + WithTranslator::from_RSenvironment(translator, system.get_delta()), + WithTranslator::from_RSset(translator, system.get_available_entities()), + WithTranslator::from_RSprocess(translator, system.get_context_process()) + )?; + let mut it = system.get_reaction_rules().iter().peekable(); + while let Some(el) = it.next() { + if it.peek().is_none() { + write!(f, "{}", + WithTranslator::from_RSreaction(translator, el) + )?; + } else { + write!(f, "{}, ", + WithTranslator::from_RSreaction(translator, el) + )?; + } + } + write!(f, "] ]") +} + +fn print_label(f: &mut fmt::Formatter, translator: &Translator, label: &RSlabel) -> fmt::Result { + write!(f, "{{available_entities: {}, context: {}, t: {}, reactants: {}, reactantsi: {}, inihibitors: {}, ireactants: {}, products: {}}}", + WithTranslator::from_RSset(translator, &label.available_entities), + WithTranslator::from_RSset(translator, &label.context), + WithTranslator::from_RSset(translator, &label.t), + WithTranslator::from_RSset(translator, &label.reactants), + WithTranslator::from_RSset(translator, &label.reactantsi), + WithTranslator::from_RSset(translator, &label.inihibitors), + WithTranslator::from_RSset(translator, &label.ireactants), + WithTranslator::from_RSset(translator, &label.products), + ) +} + +fn print_assert_op(f: &mut fmt::Formatter, _translator: &Translator, assert_op: &RSassertOp) -> fmt::Result { + use super::structure::RSassertOp::*; + match assert_op { + InW => {write!(f, "InW")}, + InR => {write!(f, "InR")}, + InI => {write!(f, "InI")}, + InP => {write!(f, "InP")}, + } +} + +#[allow(unused_variables)] +fn print_assert(f: &mut fmt::Formatter, translator: &Translator, assert: &RSassert) -> fmt::Result { + todo!() +} + +#[allow(unused_variables)] +fn print_bhml(f: &mut fmt::Formatter, translator: &Translator, bhml: &RSBHML) -> fmt::Result { + todo!() +} + +impl<'a> fmt::Display for WithTranslator<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + WithTranslator::RSset{translator, set} => { + print_set(f, translator, set) + }, + WithTranslator::RSreaction { translator, reaction } => { + print_reaction(f, translator, reaction) + }, + WithTranslator::RSprocess { translator, process } => { + print_process(f, translator, process) + }, + WithTranslator::RSchoices { translator, choices } => { + print_choices(f, translator, choices) + }, + WithTranslator::RSenvironment { translator, environment } => { + print_environment(f, translator, environment) + }, + WithTranslator::RSsystem { translator, system } => { + print_system(f, translator, system) + }, + WithTranslator::RSlabel { translator, label } => { + print_label(f, translator, label) + }, + WithTranslator::RSassertOp { translator, assert_op } => { + print_assert_op(f, translator, assert_op) + }, + WithTranslator::RSassert { translator, assert } => { + print_assert(f, translator, assert) + }, + WithTranslator::RSBHML { translator, bhml } => { + print_bhml(f, translator, bhml) + } + } + } +} +