pub struct PathExpr { /* private fields */ }Expand description
A canonical regular expression over graph-property Steps.
Construction normalizes exclusion lists, flattens associative sequences, and flattens, sorts, and deduplicates alternatives. This is structural canonicalization, not full language minimization: distributively equivalent expressions may still compile to different (but language-equivalent) automata. The durable alternative order is atom, sequence, alternative, star, plus, optional; atom kinds are forward, reverse, forward-except, reverse-except, with payloads ordered lexicographically.
use triblespace_paths::{PathExpr, Step};
let parent = [1; 16];
let sibling = [2; 16];
let expression = PathExpr::from(Step::Forward(parent))
.plus()
.or(PathExpr::from(Step::Forward(sibling)).inverse());
let automaton = expression.compile();
assert_eq!(automaton.initial_states().collect::<Vec<_>>(), vec![0]);Implementations§
Source§impl PathExpr
impl PathExpr
Sourcepub fn then(self, next: impl Into<Self>) -> Self
pub fn then(self, next: impl Into<Self>) -> Self
Concatenates this expression with next.
Nested sequences are flattened without reordering their operands.
Sourcepub fn or(self, alternative: impl Into<Self>) -> Self
pub fn or(self, alternative: impl Into<Self>) -> Self
Forms the set union of this expression and alternative.
Nested alternatives are flattened, sorted by an explicit stable node order, and deduplicated.
Sourcepub fn inverse(self) -> Self
pub fn inverse(self) -> Self
Reverses path direction.
Inversion flips every atomic step, reverses sequence order, distributes through alternatives, and preserves repetition operators.
Sourcepub fn is_nullable(&self) -> bool
pub fn is_nullable(&self) -> bool
Whether this expression accepts the empty path.
Sourcepub fn compile(&self) -> Automaton
pub fn compile(&self) -> Automaton
Compiles to a fixed epsilon-free position automaton.
Atomic occurrences are numbered deterministically in canonical-tree
order. State zero is the sole initial state; every other state denotes
the most recently consumed atomic occurrence. The construction is
output-sensitive in the expression and generated follow relation;
ordered-set maintenance may add logarithmic factors. It introduces no
epsilon transitions or determinization step.
§Panics
Panics if the expression contains u32::MAX atomic occurrences. Such
an expression cannot be represented by StateId.
Trait Implementations§
impl Eq for PathExpr
Source§impl Ord for PathExpr
impl Ord for PathExpr
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for PathExpr
impl PartialOrd for PathExpr
impl StructuralPartialEq for PathExpr
Auto Trait Implementations§
impl Freeze for PathExpr
impl RefUnwindSafe for PathExpr
impl Send for PathExpr
impl Sync for PathExpr
impl Unpin for PathExpr
impl UnsafeUnpin for PathExpr
impl UnwindSafe for PathExpr
Blanket Implementations§
impl<T> ArchiveOwner for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more