[−][src]Struct cfg::binarized::BinarizedCfg
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]
G: ContextFree<History = H>,
&'a G: ContextFreeRef<'a, Target = G>,
H: Binarize + Clone + 'static,
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]
F: FnMut(&BinarizedRule<H>, &BinarizedRule<H>) -> Ordering,
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]
H: Binarize,
pub fn sym<T>(&mut self) -> T where
T: SymbolContainer,
[src]
T: SymbolContainer,
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]
H: Binarize + Clone + EliminateNulling,
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]
H: Binarize,
fn rule(&mut self, lhs: Symbol) -> RuleBuilder<&mut Self>
[src]
fn precedenced_rule(&mut self, lhs: Symbol) -> PrecedencedRuleBuilder<&mut Self> where
Self::History: AssignPrecedence + Default,
[src]
Self::History: AssignPrecedence + Default,
impl<'a, H> ContextFreeRef<'a> for &'a BinarizedCfg<H> where
H: Binarize + 'a,
[src]
H: Binarize + 'a,
type RuleRef = RuleRef<'a, H>
Immutable reference to a rule.
type Rules = BinarizedRules<'a, H>
Iterator over immutable references to the grammar's rules.
fn rules(self) -> Self::Rules
[src]
fn reverse(self) -> Self::Target where
<Self::Target as RuleContainer>::History: Clone,
Self::Target: EmptyRuleContainer,
[src]
<Self::Target as RuleContainer>::History: Clone,
Self::Target: EmptyRuleContainer,
impl<'a, H> ContextFreeMut<'a> for &'a mut BinarizedCfg<H> where
H: Binarize + 'a,
[src]
H: Binarize + 'a,
impl<H> RuleContainer for BinarizedCfg<H> where
H: Binarize,
[src]
H: Binarize,
type History = H
The type of history carried with the rule.
fn sym_source(&self) -> &SymbolSource
[src]
fn sym_source_mut(&mut self) -> &mut SymbolSource
[src]
fn retain<F>(&mut self, f: F) where
F: FnMut(Symbol, &[Symbol], &Self::History) -> bool,
[src]
F: FnMut(Symbol, &[Symbol], &Self::History) -> bool,
fn add_rule(&mut self, lhs: Symbol, rhs: &[Symbol], history: Self::History)
[src]
fn sym<T>(&mut self) -> T where
T: SymbolContainer,
[src]
T: SymbolContainer,
fn next_sym(&mut self) -> Symbol
[src]
fn num_syms(&self) -> usize
[src]
impl<H> EmptyRuleContainer for BinarizedCfg<H>
[src]
impl<H: Clone> Clone for BinarizedCfg<H>
[src]
fn clone(&self) -> BinarizedCfg<H>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<H> Default for BinarizedCfg<H>
[src]
Auto Trait Implementations
impl<H> Send for BinarizedCfg<H> where
H: Send,
H: Send,
impl<H> Sync for BinarizedCfg<H> where
H: Sync,
H: Sync,
impl<H> Unpin for BinarizedCfg<H> where
H: Unpin,
H: Unpin,
impl<H> UnwindSafe for BinarizedCfg<H> where
H: UnwindSafe,
H: UnwindSafe,
impl<H> RefUnwindSafe for BinarizedCfg<H> where
H: RefUnwindSafe,
H: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,