summaryrefslogtreecommitdiff
path: root/chain/src/item/genins.rs
diff options
context:
space:
mode:
Diffstat (limited to 'chain/src/item/genins.rs')
-rw-r--r--chain/src/item/genins.rs28
1 files changed, 20 insertions, 8 deletions
diff --git a/chain/src/item/genins.rs b/chain/src/item/genins.rs
index 97d7ba9..a2bb22c 100644
--- a/chain/src/item/genins.rs
+++ b/chain/src/item/genins.rs
@@ -142,8 +142,6 @@ pub fn virtual_generate_fragment(
Ok(result)
}
-// TODO: Refactor `insert_item`.
-
impl DefaultForest<ForestLabel<GrammarLabel>> {
/// Insert an item derivation forest into a recording forest.
///
@@ -252,8 +250,24 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
atom.borrow(),
)?;
- self.print_viz(&format!("pos {pos} {tnt_string} {num} stage 1.gv"))
- .unwrap();
+ /// A cute little macro to produce compact representations
+ /// of Parents, Virtual nodes, or empty.
+ macro_rules! pavi_to_short_str {
+ ($pavi:ident) => {
+ match $pavi {
+ PaVi::Parent(node, edge) => format!("{node} {edge}"),
+ PaVi::Virtual(nt, t, node) => format!("{nt} {t} {node}"),
+ PaVi::Empty => "ε".to_string(),
+ }
+ };
+ }
+
+ self.print_viz(&format!(
+ "pos {pos} {tnt_string} {num} stage 1 {}, {}.gv",
+ pavi_to_short_str!(true_source),
+ pavi_to_short_str!(pavi)
+ ))
+ .unwrap();
// Ensure the last node in the PaVi is a terminal or a
// non-terminal node, as an extra safety guard during
@@ -296,10 +310,6 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
}
}
- // TODO: Print each and every step.
-
- // TODO: Refactor this.
-
let is_empty_segment = pavi.is_empty();
let mut parents: Vec<Parent> = {
@@ -602,6 +612,8 @@ impl DefaultForest<ForestLabel<GrammarLabel>> {
Ok(result)
}
+ // REVIEW: Is this function really correct?
+
/// Perform extra reductions.
///
/// To be precise, this function first splones the bottom node,