Struct cfg::binarized::BinarizedCfg
source · pub struct BinarizedCfg { /* private fields */ }
Expand description
Representation for grammars where right-hand sides of all rules have at most two symbols.
Implementations§
source§impl BinarizedCfg
impl BinarizedCfg
sourcepub fn with_sym_source(sym_source: SymbolSource) -> Self
pub fn with_sym_source(sym_source: SymbolSource) -> Self
Creates an empty BinarizedCfg with the given symbol source.
sourcepub fn from_context_free<'a, G>(this: &'a G) -> BinarizedCfgwhere
G: RuleContainer + Default,
&'a G: RuleContainerRef<'a, Target = G>,
pub fn from_context_free<'a, G>(this: &'a G) -> BinarizedCfgwhere G: RuleContainer + Default, &'a G: RuleContainerRef<'a, Target = G>,
Creates a BinarizedCfg by binarizing a context-free grammar.
sourcepub fn sort_by<F>(&mut self, compare: F)where
F: FnMut(&BinarizedRule, &BinarizedRule) -> Ordering,
pub fn sort_by<F>(&mut self, compare: F)where F: FnMut(&BinarizedRule, &BinarizedRule) -> Ordering,
Sorts the rule array in place, using the argument to compare elements.
sourcepub fn sym<T>(&mut self) -> Twhere
T: SymbolContainer,
pub fn sym<T>(&mut self) -> Twhere T: SymbolContainer,
Returns generated symbols.
sourcepub fn eliminate_nulling_rules(&mut self) -> BinarizedCfg
pub fn eliminate_nulling_rules(&mut self) -> BinarizedCfg
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§
source§impl Clone for BinarizedCfg
impl Clone for BinarizedCfg
source§fn clone(&self) -> BinarizedCfg
fn clone(&self) -> BinarizedCfg
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Default for BinarizedCfg
impl Default for BinarizedCfg
source§impl RuleContainer for BinarizedCfg
impl RuleContainer for BinarizedCfg
fn history_graph(&self) -> &HistoryGraph
fn add_history_node(&mut self, node: HistoryNode) -> HistoryId
source§fn sym_source(&self) -> &SymbolSource
fn sym_source(&self) -> &SymbolSource
Returns an immutable reference to the grammar’s symbol source.
source§fn sym_source_mut(&mut self) -> &mut SymbolSource
fn sym_source_mut(&mut self) -> &mut SymbolSource
Returns a mutable reference to the grammar’s symbol source.
source§fn retain<F>(&mut self, f: F)where
F: FnMut(Symbol, &[Symbol], HistoryId) -> bool,
fn retain<F>(&mut self, f: F)where F: FnMut(Symbol, &[Symbol], HistoryId) -> bool,
Retains only the rules specified by the predicate. Read more
source§fn add_rule(&mut self, lhs: Symbol, rhs: &[Symbol], history_id: HistoryId)
fn add_rule(&mut self, lhs: Symbol, rhs: &[Symbol], history_id: HistoryId)
Inserts a rule with
lhs
and rhs
on its LHS and RHS. The rule carries history
.source§fn sym<T>(&mut self) -> Twhere
T: SymbolContainer,
fn sym<T>(&mut self) -> Twhere T: SymbolContainer,
Returns generated symbols.
source§fn precedenced_rule(&mut self, lhs: Symbol) -> PrecedencedRuleBuilder<&mut Self>
fn precedenced_rule(&mut self, lhs: Symbol) -> PrecedencedRuleBuilder<&mut Self>
Starts building a new precedenced rule.
source§impl<'a> RuleContainerRef<'a> for &'a BinarizedCfg
impl<'a> RuleContainerRef<'a> for &'a BinarizedCfg
§type Rules = Chain<LhsWithHistoryToRuleRef<'a, Enumerate<Cloned<Iter<'a, Option<NonZeroUsize>>>>>, BinarizedRuleToRuleRef<Iter<'a, BinarizedRule>>>
type Rules = Chain<LhsWithHistoryToRuleRef<'a, Enumerate<Cloned<Iter<'a, Option<NonZeroUsize>>>>>, BinarizedRuleToRuleRef<Iter<'a, BinarizedRule>>>
Iterator over immutable references to the grammar’s rules.
impl<'a> RuleContainerMut<'a> for &'a mut BinarizedCfg
Auto Trait Implementations§
impl RefUnwindSafe for BinarizedCfg
impl Send for BinarizedCfg
impl Sync for BinarizedCfg
impl Unpin for BinarizedCfg
impl UnwindSafe for BinarizedCfg
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