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
impl Usefulness
Sourcepub fn new(grammar: &Cfg) -> Self
pub fn new(grammar: &Cfg) -> Self
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(&mut self, syms: impl AsRef<[Symbol]>)
pub fn reachable(&mut self, syms: impl 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.
Sourcepub fn all_reachable(&self) -> bool
pub fn all_reachable(&self) -> bool
Checks whether all rules in the grammar are reachable.
Sourcepub fn usefulness<'r>(&self, rule: &'r CfgRule) -> UsefulnessForRule<'r>
pub fn usefulness<'r>(&self, rule: &'r CfgRule) -> UsefulnessForRule<'r>
Get the usefulness of the given rule.
Sourcepub fn useless_rules<'a, 'g>(
&'a self,
grammar: &'g Cfg,
) -> impl Iterator<Item = UsefulnessForRule<'g>> + 'awhere
'g: 'a,
pub fn useless_rules<'a, 'g>(
&'a self,
grammar: &'g Cfg,
) -> impl Iterator<Item = UsefulnessForRule<'g>> + 'awhere
'g: 'a,
Returns an iterator over the grammar’s useless rules.
Sourcepub fn remove_useless_rules(&self, grammar: &mut Cfg)
pub fn remove_useless_rules(&self, grammar: &mut Cfg)
Removes useless rules. The language represented by the grammar doesn’t change.
Auto Trait Implementations§
impl Freeze for Usefulness
impl RefUnwindSafe for Usefulness
impl Send for Usefulness
impl Sync for Usefulness
impl Unpin for Usefulness
impl UnwindSafe for Usefulness
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