summaryrefslogtreecommitdiff
path: root/chain
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2023-07-21 11:42:02 +0800
committerJSDurand <mmemmew@gmail.com>2023-07-21 11:42:02 +0800
commit5bb59bb5b944c380f762858e1662a2a17f41677c (patch)
tree517cdb1197c88e7c84b7e77613de6436eaf08e5b /chain
parent88052521eba5721809c472aab5bfae8a95e00956 (diff)
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.
Diffstat (limited to 'chain')
-rw-r--r--chain/src/atom/default.rs27
1 files 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<S: AsRef<str>>(&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(())
}