Cycles

Struct Cycles 

Source
pub struct Cycles<G: Borrow<Cfg>> { /* private fields */ }
Expand description

Provides information about cycles among unit derivations in the grammar. There are two ways of pruning cycles.

Implementations§

Source§

impl<G: Borrow<Cfg>> Cycles<G>

Source

pub fn new(grammar: G) -> Self

Analyzes the grammar’s cycles.

Source

pub fn cycle_free(&mut self) -> bool

Checks whether the grammar is cycle-free.

Source

pub fn classify(&self) -> impl Iterator<Item = (&CfgRule, bool)> + '_

Iterates over rules that participate in a cycle.

Source

pub fn cycle_participants( &self, get_cyclical: bool, ) -> impl Iterator<Item = &CfgRule> + '_

Iterates over rules that participate in a cycle.

Source§

impl<G: BorrowMut<Cfg>> Cycles<G>

Source

pub fn remove_cycles(&mut self)

Removes all rules that participate in a cycle. Doesn’t preserve the language represented by the grammar.

Source

pub fn rewrite_cycles(&mut self)

Rewrites all rules that participate in a cycle. Preserves the language represented by the grammar.

Auto Trait Implementations§

§

impl<G> Freeze for Cycles<G>
where G: Freeze,

§

impl<G> RefUnwindSafe for Cycles<G>
where G: RefUnwindSafe,

§

impl<G> Send for Cycles<G>
where G: Send,

§

impl<G> Sync for Cycles<G>
where G: Sync,

§

impl<G> Unpin for Cycles<G>
where G: Unpin,

§

impl<G> UnwindSafe for Cycles<G>
where G: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.