[][src]Struct cfg::binarized::BinarizedCfg

pub struct BinarizedCfg<H = NullHistory> { /* fields omitted */ }

Representation for grammars where right-hand sides of all rules have at most two symbols.

Methods

impl<H> BinarizedCfg<H>[src]

pub fn new() -> Self[src]

Creates a BinarizedCfg.

pub fn with_sym_source(sym_source: SymbolSource) -> Self[src]

Creates an empty BinarizedCfg with the given symbol source.

pub fn from_context_free<'a, G>(this: &'a G) -> BinarizedCfg<H> where
    G: ContextFree<History = H>,
    &'a G: ContextFreeRef<'a, Target = G>,
    H: Binarize + Clone + 'static, 
[src]

Creates a BinarizedCfg by binarizing a context-free grammar.

pub fn sort(&mut self)[src]

Sorts the rule array.

pub fn sort_by<F>(&mut self, compare: F) where
    F: FnMut(&BinarizedRule<H>, &BinarizedRule<H>) -> Ordering
[src]

Sorts the rule array in place, using the argument to compare elements.

pub fn dedup(&mut self)[src]

Removes consecutive duplicate rules.

impl<H> BinarizedCfg<H> where
    H: Binarize
[src]

pub fn sym<T>(&mut self) -> T where
    T: SymbolContainer
[src]

Returns generated symbols.

pub fn next_sym(&mut self) -> Symbol[src]

Generates a new unique symbol.

pub fn num_syms(&self) -> usize[src]

Returns the number of symbols in use.

impl<H> BinarizedCfg<H> where
    H: Binarize + Clone + EliminateNulling
[src]

pub fn eliminate_nulling_rules(&mut self) -> BinarizedCfg<H>[src]

Eliminates all rules of the form A ::= epsilon.

In other words, this splits off the set of nulling rules.

The language represented by the grammar is preserved, except for the possible lack of the empty string. Unproductive rules aren't preserved.

Trait Implementations

impl<H> ContextFree for BinarizedCfg<H> where
    H: Binarize
[src]

impl<'a, H> ContextFreeRef<'a> for &'a BinarizedCfg<H> where
    H: Binarize + 'a, 
[src]

type RuleRef = RuleRef<'a, H>

Immutable reference to a rule.

type Rules = BinarizedRules<'a, H>

Iterator over immutable references to the grammar's rules.

impl<'a, H> ContextFreeMut<'a> for &'a mut BinarizedCfg<H> where
    H: Binarize + 'a, 
[src]

impl<H> RuleContainer for BinarizedCfg<H> where
    H: Binarize
[src]

type History = H

The type of history carried with the rule.

impl<H> EmptyRuleContainer for BinarizedCfg<H>[src]

impl<H: Clone> Clone for BinarizedCfg<H>[src]

impl<H> Default for BinarizedCfg<H>[src]

Auto Trait Implementations

impl<H> Send for BinarizedCfg<H> where
    H: Send

impl<H> Sync for BinarizedCfg<H> where
    H: Sync

impl<H> Unpin for BinarizedCfg<H> where
    H: Unpin

impl<H> UnwindSafe for BinarizedCfg<H> where
    H: UnwindSafe

impl<H> RefUnwindSafe for BinarizedCfg<H> where
    H: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]