Struct cfg::Cfg [] [src]

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

Basic representation of context-free grammars.

Methods

impl<H, Hs> Cfg<H, Hs>
[src]

fn new() -> Self

Creates an empty context-free grammar.

fn with_sym_source(sym_source: SymbolSource) -> Self

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]

fn sym<T>(&mut self) -> T where 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.

fn sequence(&mut self, lhs: Symbol) -> SequenceRuleBuilder<Hs, &mut Vec<Sequence<Hs>>>

Starts building a sequence rule.

fn sequence_rules(&self) -> &[Sequence<Hs>]

Returns sequence rules.

fn rewrite_sequences(&mut self)

Forces a rewrite of sequence rules into grammar rules.

fn binarize<'a>(&'a self) -> BinarizedCfg<H> where &'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: Clone, Hs: Clone> Clone for Cfg<H, Hs>
[src]

fn clone(&self) -> Cfg<H, Hs>

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, Hs> ContextFree for Cfg<H, Hs> where Hs: Clone + RewriteSequence<Rewritten=H>
[src]

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

Starts building a new precedenced rule.

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

type RuleRef = Self::Rules::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

Returns an 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.

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], &H) -> bool

Retains only the rules specified by the predicate. Read more

fn add_rule(&mut self, lhs: Symbol, rhs: &[Symbol], history: H)

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

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.