[][src]Struct cfg::Cfg

pub struct Cfg<H = NullHistory, Hs = H> { /* fields omitted */ }

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]

pub fn sym<T>(&mut self) -> T where
    T: SymbolContainer
[src]

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]

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]

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]

impl<'a, H, Hs> ContextFreeRef<'a> for &'a Cfg<H, Hs> where
    H: 'a,
    Hs: Clone + RewriteSequence<Rewritten = H>, 
[src]

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.

impl<'a, H, Hs> ContextFreeMut<'a> for &'a mut Cfg<H, Hs> where
    H: 'a,
    Hs: Clone + RewriteSequence<Rewritten = H> + 'a, 
[src]

impl<H, Hs> RuleContainer for Cfg<H, Hs> where
    Hs: Clone + RewriteSequence<Rewritten = H>, 
[src]

type History = H

The type of history carried with the rule.

impl<H, Hs> EmptyRuleContainer for Cfg<H, Hs> where
    Hs: Clone + RewriteSequence<Rewritten = H>, 
[src]

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

impl<H, Hs> Sync for Cfg<H, Hs> where
    H: Sync,
    Hs: Sync

impl<H, Hs> Unpin for Cfg<H, Hs> where
    H: Unpin,
    Hs: Unpin

impl<H, Hs> UnwindSafe for Cfg<H, Hs> where
    H: UnwindSafe,
    Hs: UnwindSafe

impl<H, Hs> RefUnwindSafe for Cfg<H, Hs> where
    H: RefUnwindSafe,
    Hs: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]