Struct cfg::usefulness::Usefulness
[−]
[src]
pub struct Usefulness<G> { // some fields omitted }
Contains the information about usefulness of the grammar's rules. Useful rules are both reachable and productive.
Methods
impl<'a, G> Usefulness<&'a mut G> where G: ContextFree, &'b G: ContextFreeRef<'b, Target=G>, &'b mut G: ContextFreeMut<'b, Target=G>
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.
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.
fn reachable<Sr>(self, syms: Sr) -> Self where Sr: AsRef<[Symbol]>
Sets symbol reachability. Takes an array of reachable symbols.
fn all_useful(&self) -> bool
Checks whether all rules in the grammar are useful.
fn all_productive(&self) -> bool
Checks whether all rules in the grammar are productive.
impl<'a, G> Usefulness<&'a mut G> where G: ContextFree, &'a G: ContextFreeRef<'a, Target=G>, &'a mut G: ContextFreeMut<'a, Target=G>
fn useless_rules(&'a self) -> UselessRules<'a, G, &'a G::Rules>
Returns an iterator over the grammar's useless rules.
fn remove_useless_rules(&mut self)
Removes useless rules. The language represented by the grammar doesn't change.