diff options
author | JSDurand <mmemmew@gmail.com> | 2023-07-18 16:22:56 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2023-07-18 16:22:56 +0800 |
commit | 0fa0622a24dbdf0c2bd0fbf6bedf4cad5ed8d311 (patch) | |
tree | 351d49489cc3c621a30f298986ed9a23668db982 /chain/src | |
parent | 5a5f7e5be9498af219a36401b1d2a13b553402e8 (diff) |
chain/src/atom/default.rs: Add function to print nullables
* chain/src/atom/default.rs (print_nullables): This functions prints
the nullables nodes of an atomic language. This is useful whe
designing unit tests, as it enables us to know which rule positions
are considered accepting by the underlying testing atomic language.
Diffstat (limited to 'chain/src')
-rw-r--r-- | chain/src/atom/default.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/chain/src/atom/default.rs b/chain/src/atom/default.rs index 317090e..bd71c1c 100644 --- a/chain/src/atom/default.rs +++ b/chain/src/atom/default.rs @@ -115,6 +115,22 @@ impl DefaultAtom { )?) } + /// Print nullable nodes. + pub(crate) fn print_nullables(&self) { + print!("printing nullables for the atom: "); + + for nullable in self + .accepting_vec + .iter() + .enumerate() + .filter_map(|(index, pred)| (*pred).then(|| index)) + { + print!("{nullable}, "); + } + + 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())?; |