Usefulness

Struct Usefulness 

Source
pub struct Usefulness { /* private fields */ }
Expand description

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

Implementations§

Source§

impl Usefulness

Source

pub fn new(grammar: &Cfg) -> Self

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(&mut self, syms: impl 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

pub fn all_reachable(&self) -> bool

Checks whether all rules in the grammar are reachable.

Source

pub fn usefulness<'r>(&self, rule: &'r CfgRule) -> UsefulnessForRule<'r>

Get the usefulness of the given rule.

Source

pub fn useless_rules<'a, 'g>( &'a self, grammar: &'g Cfg, ) -> impl Iterator<Item = UsefulnessForRule<'g>> + 'a
where 'g: 'a,

Returns an iterator over the grammar’s useless rules.

Source

pub fn remove_useless_rules(&self, grammar: &mut Cfg)

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

Auto Trait Implementations§

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.