Struct cfg::BinarizedCfg
[−]
[src]
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]
fn new() -> Self
Creates a BinarizedCfg.
fn with_sym_source(sym_source: SymbolSource) -> Self
Creates an empty BinarizedCfg with the given symbol source.
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,
G: ContextFree<History = H>,
&'a G: ContextFreeRef<'a, Target = G>,
H: Binarize + Clone + 'static,
Creates a BinarizedCfg by binarizing a context-free grammar.
fn sort(&mut self)
Sorts the rule array.
fn sort_by<F>(&mut self, compare: F) where
F: FnMut(&BinarizedRule<H>, &BinarizedRule<H>) -> Ordering,
F: FnMut(&BinarizedRule<H>, &BinarizedRule<H>) -> Ordering,
Sorts the rule array in place, using the argument to compare elements.
fn dedup(&mut self)
Removes consecutive duplicate rules.
impl<H> BinarizedCfg<H> where
H: Binarize,
[src]
H: Binarize,
fn sym<T>(&mut self) -> T where
T: SymbolContainer,
T: SymbolContainer,
Returns generated symbols.
fn next_sym(&mut self) -> Symbol
Generates a new unique symbol.
fn num_syms(&self) -> usize
Returns the number of symbols in use.
impl<H> BinarizedCfg<H> where
H: Binarize + Clone + EliminateNulling,
[src]
H: Binarize + Clone + EliminateNulling,
fn eliminate_nulling_rules(&mut self) -> BinarizedCfg<H>
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: Clone> Clone for BinarizedCfg<H>
[src]
fn clone(&self) -> BinarizedCfg<H>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<H> ContextFree for BinarizedCfg<H> where
H: Binarize,
[src]
H: Binarize,
fn rule(&mut self, lhs: Symbol) -> RuleBuilder<&mut Self>
Starts building a new rule.
fn precedenced_rule(&mut self, lhs: Symbol) -> PrecedencedRuleBuilder<&mut Self> where
Self::History: AssignPrecedence + Default,
Self::History: AssignPrecedence + Default,
Starts building a new precedenced rule.
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 = Chain<LhsWithHistoryToRuleRef<Enumerate<Iter<'a, Option<H>>>>, BinarizedRuleToRuleRef<Iter<'a, BinarizedRule<H>>>>
Iterator over immutable references to the grammar's rules.
fn rules(self) -> Self::Rules
Returns an iterator over immutable references to the grammar's rules.
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
Returns an immutable reference to the grammar's symbol source.
fn sym_source_mut(&mut self) -> &mut SymbolSource
Returns a mutable reference to the grammar's symbol source.
fn retain<F>(&mut self, f: F) where
F: FnMut(Symbol, &[Symbol], &Self::History) -> bool,
F: FnMut(Symbol, &[Symbol], &Self::History) -> bool,
Retains only the rules specified by the predicate. Read more
fn add_rule(&mut self, lhs: Symbol, rhs: &[Symbol], history: Self::History)
Inserts a rule with lhs
and rhs
on its LHS and RHS. The rule carries history
.
fn sym<T>(&mut self) -> T where
T: SymbolContainer,
T: SymbolContainer,
Returns generated symbols.
fn next_sym(&mut self) -> Symbol
Generates a new unique symbol.
fn num_syms(&self) -> usize
Returns the number of symbols in use.