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,
impl<'a, G> Usefulness<&'a mut G>where
G: RuleContainer,
Sourcepub fn new(grammar: &'a mut G) -> Usefulness<&'a mut G>
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.
Sourcepub fn productivity(&self, sym: Symbol) -> bool
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.
Sourcepub fn reachable<Sr>(self, syms: Sr) -> Self
pub fn reachable<Sr>(self, syms: Sr) -> Self
Sets symbol reachability. Takes an array of reachable symbols.
Sourcepub fn all_useful(&self) -> bool
pub fn all_useful(&self) -> bool
Checks whether all rules in the grammar are useful.
Sourcepub fn all_productive(&self) -> bool
pub fn all_productive(&self) -> bool
Checks whether all rules in the grammar are productive.
Sourcepub fn all_reachable(&self) -> bool
pub fn all_reachable(&self) -> bool
Checks whether all rules in the grammar are reachable.
pub fn rule_usefulness(&self, rule: RuleRef<'_>) -> RuleUsefulness
Sourcepub fn useless_rules(
&'a self,
) -> UselessRules<'a, G, impl Iterator<Item = RuleRef<'a>>> ⓘ
pub fn useless_rules( &'a self, ) -> UselessRules<'a, G, impl Iterator<Item = RuleRef<'a>>> ⓘ
Returns an iterator over the grammar’s useless rules.
Source§impl<'a, G> Usefulness<&'a mut G>where
G: RuleContainer,
impl<'a, G> Usefulness<&'a mut G>where
G: RuleContainer,
Sourcepub fn remove_useless_rules(&mut self)
pub fn remove_useless_rules(&mut self)
Removes useless rules. The language represented by the grammar doesn’t change.
Auto Trait Implementations§
impl<G> Freeze for Usefulness<G>where
G: Freeze,
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> 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
Mutably borrows from an owned value. Read more