Trait cfg::rule::container::RuleContainer [] [src]

pub trait RuleContainer {
    type History;
    fn sym_source(&self) -> &SymbolSource;
    fn sym_source_mut(&mut self) -> &mut SymbolSource;
    fn retain<F>(&mut self, f: F) where F: FnMut(Symbol, &[Symbol], &Self::History) -> bool;
    fn add_rule(&mut self, lhs: Symbol, rhs: &[Symbol], history: Self::History);

    fn sym<T>(&mut self) -> T where T: SymbolContainer { ... }
    fn next_sym(&mut self) -> Symbol { ... }
    fn num_syms(&self) -> usize { ... }
}

Trait for rule and symbol containers.

Associated Types

type History

The type of history carried with the rule.

Required Methods

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], &Self::History) -> bool

Retains only the rules specified by the predicate.

In other words, removes all rules rule for which f(&rule) returns false.

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

Inserts a rule with lhs and rhs on its LHS and RHS. The rule carries history.

Provided Methods

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.

Implementors