pub struct Usefulness<G> { /* private fields */ }
Expand description

Contains the information about usefulness of the grammar’s rules. Useful rules are both reachable and productive.

Implementations§

source§

impl<'a, G> Usefulness<&'a mut G>where G: RuleContainer + Default, for<'b> &'b G: RuleContainerRef<'b, Target = G>, for<'b> &'b mut G: RuleContainerMut<'b, Target = G>,

source

pub fn new(grammar: &'a mut G) -> Usefulness<&'a mut G>

Analyzes usefulness of the grammar’s rules. In particular, it checks for reachable and productive symbols.

source

pub fn productivity(&self, sym: Symbol) -> bool

Checks whether a symbol is productive. Can be used to determine the precise reason of a rule’s unproductiveness.

source

pub fn reachable<Sr>(self, syms: Sr) -> Selfwhere Sr: AsRef<[Symbol]>,

Sets symbol reachability. Takes an array of reachable symbols.

source

pub fn all_useful(&self) -> bool

Checks whether all rules in the grammar are useful.

source

pub fn all_productive(&self) -> bool

Checks whether all rules in the grammar are productive.

source§

impl<'a, G> Usefulness<&'a mut G>where G: RuleContainer + Default, &'a G: RuleContainerRef<'a, Target = G>, &'a mut G: RuleContainerMut<'a, Target = G>,

source

pub fn useless_rules( &'a self ) -> UselessRules<'a, G, <&'a G as RuleContainerRef<'a>>::Rules>

Returns an iterator over the grammar’s useless rules.

source

pub fn remove_useless_rules(&mut self)

Removes useless rules. The language represented by the grammar doesn’t change.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.