[−][src]Struct cfg::Cfg
Basic representation of context-free grammars.
Methods
impl<H, Hs> Cfg<H, Hs>
[src]
pub fn new() -> Self
[src]
Creates an empty context-free grammar.
pub fn with_sym_source(sym_source: SymbolSource) -> Self
[src]
Creates an empty context-free grammar with the given symbol source.
impl<H, Hs> Cfg<H, Hs> where
Hs: RewriteSequence<Rewritten = H>,
H: Clone,
Hs: Clone,
[src]
Hs: RewriteSequence<Rewritten = H>,
H: Clone,
Hs: Clone,
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.
pub fn sequence(
&mut self,
lhs: Symbol
) -> SequenceRuleBuilder<Hs, &mut Vec<Sequence<Hs>>>
[src]
&mut self,
lhs: Symbol
) -> SequenceRuleBuilder<Hs, &mut Vec<Sequence<Hs>>>
Starts building a sequence rule.
pub fn sequence_rules(&self) -> &[Sequence<Hs>]
[src]
Returns sequence rules.
pub fn rewrite_sequences(&mut self)
[src]
Forces a rewrite of sequence rules into grammar rules.
pub fn binarize<'a>(&'a self) -> BinarizedCfg<H> where
&'a Self: ContextFreeRef<'a, Target = Self>,
H: Binarize + Clone + 'static,
[src]
&'a Self: ContextFreeRef<'a, Target = Self>,
H: Binarize + Clone + 'static,
Returns a binarized grammar which is weakly equivalent to this grammar.
Trait Implementations
impl<H, Hs> ContextFree for Cfg<H, Hs> where
Hs: Clone + RewriteSequence<Rewritten = H>,
[src]
Hs: Clone + RewriteSequence<Rewritten = H>,
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, Hs> ContextFreeRef<'a> for &'a Cfg<H, Hs> where
H: 'a,
Hs: Clone + RewriteSequence<Rewritten = H>,
[src]
H: 'a,
Hs: Clone + RewriteSequence<Rewritten = H>,
type RuleRef = <Self::Rules as Iterator>::Item
Immutable reference to a rule.
type Rules = Iter<'a, Rule<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, Hs> ContextFreeMut<'a> for &'a mut Cfg<H, Hs> where
H: 'a,
Hs: Clone + RewriteSequence<Rewritten = H> + 'a,
[src]
H: 'a,
Hs: Clone + RewriteSequence<Rewritten = H> + 'a,
impl<H, Hs> RuleContainer for Cfg<H, Hs> where
Hs: Clone + RewriteSequence<Rewritten = H>,
[src]
Hs: Clone + RewriteSequence<Rewritten = H>,
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], &H) -> bool,
[src]
F: FnMut(Symbol, &[Symbol], &H) -> bool,
fn add_rule(&mut self, lhs: Symbol, rhs: &[Symbol], history: H)
[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, Hs> EmptyRuleContainer for Cfg<H, Hs> where
Hs: Clone + RewriteSequence<Rewritten = H>,
[src]
Hs: Clone + RewriteSequence<Rewritten = H>,
impl<H: Clone, Hs: Clone> Clone for Cfg<H, Hs>
[src]
impl<H, Hs> Default for Cfg<H, Hs>
[src]
Auto Trait Implementations
impl<H, Hs> Send for Cfg<H, Hs> where
H: Send,
Hs: Send,
H: Send,
Hs: Send,
impl<H, Hs> Sync for Cfg<H, Hs> where
H: Sync,
Hs: Sync,
H: Sync,
Hs: Sync,
impl<H, Hs> Unpin for Cfg<H, Hs> where
H: Unpin,
Hs: Unpin,
H: Unpin,
Hs: Unpin,
impl<H, Hs> UnwindSafe for Cfg<H, Hs> where
H: UnwindSafe,
Hs: UnwindSafe,
H: UnwindSafe,
Hs: UnwindSafe,
impl<H, Hs> RefUnwindSafe for Cfg<H, Hs> where
H: RefUnwindSafe,
Hs: RefUnwindSafe,
H: RefUnwindSafe,
Hs: 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,