Struct cfg::classification::useful::Usefulness
source · 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>,
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>,
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) -> Selfwhere
Sr: AsRef<[Symbol]>,
pub fn reachable<Sr>(self, syms: Sr) -> Selfwhere Sr: AsRef<[Symbol]>,
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.
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>,
impl<'a, G> Usefulness<&'a mut G>where G: RuleContainer + Default, &'a G: RuleContainerRef<'a, Target = G>, &'a mut G: RuleContainerMut<'a, Target = G>,
sourcepub fn useless_rules(
&'a self
) -> UselessRules<'a, G, <&'a G as RuleContainerRef<'a>>::Rules> ⓘ
pub fn useless_rules( &'a self ) -> UselessRules<'a, G, <&'a G as RuleContainerRef<'a>>::Rules> ⓘ
Returns an iterator over the grammar’s useless rules.
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> 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