Struct gearley::grammar::Grammar [] [src]

pub struct Grammar {
    // some fields omitted
}

Drop-in replacement for cfg::Cfg that traces relations between user-provided and internal grammars.

Methods

impl Grammar

fn new() -> Self

fn set_start(&mut self, start: Symbol)

fn get_start(&self) -> Symbol

fn rule(&mut self, lhs: Symbol) -> RuleBuilder<&mut Cfg<History, History>, BuildHistory>

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

fn binarize(&self) -> BinarizedGrammar

fn into_internal_grammar(&self) -> InternalGrammar

Methods from Deref<Target=Cfg<History, 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.

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

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 H: Binarize + Clone + 'static, &'a Cfg<H, Hs>: ContextFreeRef<'a>, &'a Cfg<H, Hs>::Target == Cfg<H, Hs>

Returns a binarized grammar which is weakly equivalent to this grammar.

Trait Implementations

impl Deref for Grammar

type Target = Cfg<History, History>

fn deref(&self) -> &Self::Target

impl DerefMut for Grammar

fn deref_mut(&mut self) -> &mut Self::Target