From 5bb59bb5b944c380f762858e1662a2a17f41677c Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 21 Jul 2023 11:42:02 +0800 Subject: chain/atom/default: add a function to print virtual nodes. * chain/src/atom/default.rs (print_virtual): Previously printing virtual nodes is done inside the function `print_nfa`; now this is decoupled and thus more flexible. --- chain/src/atom/default.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/chain/src/atom/default.rs b/chain/src/atom/default.rs index 85d652f..e156178 100644 --- a/chain/src/atom/default.rs +++ b/chain/src/atom/default.rs @@ -131,25 +131,24 @@ impl DefaultAtom { println!(); } + /// Print virtual nodes. + pub fn print_virtual(&self) { + println!("printing virtual nodes of the atom:"); + + for (vn, node) in self.virtual_nodes.iter() { + println!("[{}]^{{({})}}: {}", vn.s, vn.t, node); + } + + println!(); + } + /// Print the underlying NFA. pub fn print_nfa>(&self, filename: S) -> Result<(), std::io::Error> { self.nfa.print_viz(filename.as_ref())?; - let nullables: Vec<_> = self - .accepting_vec - .iter() - .enumerate() - .filter_map(|(index, pred)| if *pred { Some(index) } else { None }) - .collect(); - - if !nullables.is_empty() { - println!("nullables: {nullables:?}"); - } + self.print_nullables(); - println!("printing virtual nodes:"); - for (vn, node) in self.virtual_nodes.iter() { - println!("[{}]^{{({})}}: {}", vn.s, vn.t, node); - } + self.print_virtual(); Ok(()) } -- cgit v1.2.3-18-g5258