diff options
author | JSDurand <mmemmew@gmail.com> | 2023-01-22 11:49:47 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2023-01-22 11:49:47 +0800 |
commit | e8ea01319b3a9032a3f4f69f65e9ca96562b87b9 (patch) | |
tree | 674e7337dce0b9433b9ddfe745b0cf82f528d3ec /chain/src/atom | |
parent | 973c789dae479dd8383b0f7f9cfa5f167fdf3d38 (diff) |
forest: clone correctly
Now the forest can detect if a node is packed or cloned, and correctly
clones a node in those circumstances. But it still needs to be
tested.
Diffstat (limited to 'chain/src/atom')
-rw-r--r-- | chain/src/atom/default.rs | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/chain/src/atom/default.rs b/chain/src/atom/default.rs index 14b7a9f..e88cfc9 100644 --- a/chain/src/atom/default.rs +++ b/chain/src/atom/default.rs @@ -429,12 +429,6 @@ impl DefaultAtom { GrammarError::IndexOutOfBounds(child, accepting_vec.len()), )?; - if nt == 3 - && nfa.degree(child).map_err(index_out_of_bounds_conversion)? == 0 - { - println!("accepting = {accepting}"); - } - if let Some((_, old_accepting)) = terminals_map.get_mut(&t) { *old_accepting = *old_accepting || accepting; } else { @@ -455,40 +449,13 @@ impl DefaultAtom { } } - if nt == 3 { - println!("map = {terminals_map:?}"); - } - for (t, (set, accepting)) in terminals_map.into_iter() { - let new_index = nfa - .extend(set.into_iter()) - .map_err(index_out_of_bounds_conversion)?; + let new_index = nfa.extend(set).map_err(index_out_of_bounds_conversion)?; if accepting_vec.get(new_index).is_none() { #[cfg(debug_assertions)] assert_eq!(new_index, accepting_vec.len()); - // let mut updated = false; - // let nfa_len = nfa.nodes_len(); - - // 'label_loop: for (label, target_iter) in nfa - // .labels_of(new_index) - // .map_err(|_| GrammarError::IndexOutOfBounds(new_index, nfa_len))? - // { - // if label_is_nullable(*label) { - // for target in target_iter { - // if *accepting_vec - // .get(target) - // .ok_or(GrammarError::IndexOutOfBounds(target, nfa_len))? - // { - // updated = true; - - // break 'label_loop; - // } - // } - // } - // } - accepting_vec.push(accepting); } |