From 8463dd24f815fe2b8f25fe9763e0a43023bfbb20 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 23 Dec 2022 00:36:31 +0800 Subject: renaming core to chain and some other changes Some changes: - The core crate is renamed to "chain". - The crate "viz" is added, which will provide layered graph drawing algorithms. - A function is added to convert from a grammar to the regular language of its left-linear closures. - A function is added to convert from a nondeterministic finite automaton to its "null" closure. A null closure is the same automaton with edges added, as if some edges are "null". Whether an edge is null is determined by a function. Combined with the previous change, we can convert a grammar to the regular language of the null closure of its left-linear closures. --- Now it remains to test more grammars and add an Atom trait, before finishing the part about compilations. --- graph/src/error.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'graph/src/error.rs') diff --git a/graph/src/error.rs b/graph/src/error.rs index 2162685..3600005 100644 --- a/graph/src/error.rs +++ b/graph/src/error.rs @@ -1,16 +1,20 @@ #![warn(missing_docs)] //! This file implements the error data type of the graph library. -use std::fmt::{self, Display}; +use core::fmt::{self, Display}; /// The error type for methods of the trait [`Graph`][`super::Graph`]. -#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)] +#[non_exhaustive] pub enum Error { /// The index is out of bounds. /// /// The first component is the index that is out of bounds, and /// the second component is the current length of nodes. IndexOutOfBounds(usize, usize), + /// The graph does not permit duplicate nodes but encounters a + /// repeated node + DuplicatedNode, } impl Display for Error { @@ -19,6 +23,7 @@ impl Display for Error { Error::IndexOutOfBounds(index, len) => { write!(f, "index {index} out of bounds {len} ") } + Error::DuplicatedNode => write!(f, "No duplicate nodes permitted, but found one"), } } } -- cgit v1.2.3-18-g5258