From aac64480aa68dadb87cf9649c04571bf39cff29c Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 21 Jul 2023 11:45:16 +0800 Subject: bump version This bumping of version is insignificant. I just find it notable that I seem to finally obtain a version without trivial bugs. Hooray! --- Cargo.toml | 2 +- chain/src/archive.txt | 103 ++++++++++++++++++++++++++++++++++++++++++ chain/src/item/default/mod.rs | 2 +- src/lib.rs | 3 ++ 4 files changed, 108 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a1409fa..df78aac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rep" -version = "0.1.0" +version = "0.1.1" edition = "2021" authors = ["JSDurand "] description = "Rust, Emacs, and Parsers" diff --git a/chain/src/archive.txt b/chain/src/archive.txt index 79fe6d8..c93b4fe 100644 --- a/chain/src/archive.txt +++ b/chain/src/archive.txt @@ -638,3 +638,106 @@ // } // Ok(()) + +// let parents: Vec<_> = { +// if old_label.clone_index().is_some() { +// let mut parents = self.parents_of(node)?; +// assert_eq!(parents.len(), 1); +// node = parents.next().unwrap().node(); +// } + +// let parents: Vec<_> = self.parents_of(node)?.collect(); + +// let mut result: Vec<(Parent, usize)> = Vec::with_capacity( +// parents +// .iter() +// .map(|parent| { +// self.parents_of(parent.node()) +// .map(|iter| iter.len()) +// .unwrap_or(0) +// }) +// .sum(), +// ); + +// for parent in parents { +// let mut parent_label = self +// .vertex_label(parent.node())? +// .ok_or_else(|| Error::NodeNoLabel(parent.node()))? +// .label(); + +// assert!(get_rule_label(parent_label).is_some()); + +// if self.degree(parent.node())? != 1 { +// dbg!(parent); +// self.print_viz("dbg forest.gv").unwrap(); + +// panic!("assumption fails"); +// } + +// parent_label.set_end_option(end); + +// let parent_label = ForestLabel::from(parent_label); + +// let mut builder = PLGBuilderMut::from_graph_mut(&mut self.graph); + +// let new_parent = builder.add_vertex(parent_label); + +// if let Some(packed) = new_packed { +// builder.add_edge(new_parent, packed, new_label)?; +// } else { +// builder.add_edge(new_parent, new_node, new_label)?; +// } + +// result.extend( +// self.parents_of(parent.node())? +// .map(|parent_parent| (parent_parent, new_parent)), +// ); +// } + +// result +// }; + +// for (parent, new_child) in parents { +// if !completingp { +// if self.has_same_children_until( +// parent.node(), +// parent.node(), +// parent.edge(), +// new_child, +// )? { +// continue; +// } + +// // we don't add a child to parent.edge() here. +// let cloned = self.clone_node(parent.node(), parent.edge(), false)?; + +// let mut builder = PLGBuilderMut::from_graph_mut(&mut self.graph); + +// builder.add_edge(cloned, new_child, new_label)?; +// } else { +// if self.has_same_children_except( +// parent.node(), +// parent.node(), +// parent.edge(), +// new_child, +// )? { +// continue; +// } + +// // we don't add a child to parent.edge() here. +// let cloned = self.clone_node(parent.node(), parent.edge(), false)?; + +// let mut builder = PLGBuilderMut::from_graph_mut(&mut self.graph); + +// builder.add_edge(cloned, new_child, new_label)?; + +// let children_to_add: Vec<_> = builder +// .children_of(parent.node())? +// .skip(parent.edge() + 1) +// .collect(); + +// for child in children_to_add { +// builder.add_edge(cloned, child, new_label)?; +// } +// } +// } diff --git a/chain/src/item/default/mod.rs b/chain/src/item/default/mod.rs index e0e2296..0dc613b 100644 --- a/chain/src/item/default/mod.rs +++ b/chain/src/item/default/mod.rs @@ -1596,7 +1596,7 @@ mod item_test { let atom = DefaultAtom::from_grammar(grammar)?; - // atom.print_nullables(); + atom.print_nullables(); let mut forest: DefaultForest> = DefaultForest::new_leaf_raw( ForestLabel::new(GrammarLabel::new(TNT::Non(0), 0), ForestLabelType::Plain), diff --git a/src/lib.rs b/src/lib.rs index 5412ed7..b7252a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -480,6 +480,9 @@ extern "C" fn parser_parse( match forest { Ok(forest) => { + // use graph::Graph; + // forest.print_viz("test forest.gv").unwrap(); + Box::leak(parser_box); let mut bytes = bytes::forest_to_bytes(&forest); -- cgit v1.2.3-18-g5258