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