pub struct Cfg { /* private fields */ }
Expand description
Basic representation of context-free grammars.
Implementations§
source§impl Cfg
impl Cfg
sourcepub fn with_sym_source(sym_source: SymbolSource) -> Self
pub fn with_sym_source(sym_source: SymbolSource) -> Self
Creates an empty context-free grammar with the given symbol source.
source§impl Cfg
impl Cfg
sourcepub fn sym<T>(&mut self) -> Twhere
T: SymbolContainer,
pub fn sym<T>(&mut self) -> Twhere T: SymbolContainer,
Returns generated symbols.
sourcepub fn sequence(
&mut self,
lhs: Symbol
) -> SequenceRuleBuilder<&mut Vec<Sequence>>
pub fn sequence( &mut self, lhs: Symbol ) -> SequenceRuleBuilder<&mut Vec<Sequence>>
Starts building a sequence rule.
sourcepub fn sequence_rules(&self) -> &[Sequence]
pub fn sequence_rules(&self) -> &[Sequence]
Returns sequence rules.
sourcepub fn rewrite_sequences(&mut self)
pub fn rewrite_sequences(&mut self)
Forces a rewrite of sequence rules into grammar rules.
sourcepub fn binarize<'a>(&'a self) -> BinarizedCfgwhere
&'a Self: RuleContainerRef<'a, Target = Self>,
pub fn binarize<'a>(&'a self) -> BinarizedCfgwhere &'a Self: RuleContainerRef<'a, Target = Self>,
Returns a binarized grammar which is weakly equivalent to this grammar.
Trait Implementations§
source§impl RuleContainer for Cfg
impl RuleContainer for Cfg
fn history_graph(&self) -> &HistoryGraph
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: HistoryId)
fn add_rule(&mut self, lhs: Symbol, rhs: &[Symbol], history: HistoryId)
Inserts a rule with
lhs
and rhs
on its LHS and RHS. The rule carries history
.fn add_history_node(&mut self, node: HistoryNode) -> HistoryId
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 Cfg
impl<'a> RuleContainerRef<'a> for &'a Cfg
impl<'a> RuleContainerMut<'a> for &'a mut Cfg
Auto Trait Implementations§
impl RefUnwindSafe for Cfg
impl Send for Cfg
impl Sync for Cfg
impl Unpin for Cfg
impl UnwindSafe for Cfg
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