pub trait RuleContainer: Sized {
    // Required methods
    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], HistoryId) -> bool;
    fn add_rule(&mut self, lhs: Symbol, rhs: &[Symbol], history: HistoryId);
    fn history_graph(&self) -> &HistoryGraph;
    fn add_history_node(&mut self, node: HistoryNode) -> HistoryId;

    // Provided methods
    fn sym<T>(&mut self) -> T
       where T: SymbolContainer { ... }
    fn next_sym(&mut self) -> Symbol { ... }
    fn num_syms(&self) -> usize { ... }
    fn rule(&mut self, lhs: Symbol) -> RuleBuilder<&mut Self> { ... }
    fn precedenced_rule(
        &mut self,
        lhs: Symbol
    ) -> PrecedencedRuleBuilder<&mut Self> { ... }
}
Expand description

Trait for rule and symbol containers.

Required Methods§

source

fn sym_source(&self) -> &SymbolSource

Returns an immutable reference to the grammar’s symbol source.

source

fn sym_source_mut(&mut self) -> &mut SymbolSource

Returns a mutable reference to the grammar’s symbol source.

source

fn retain<F>(&mut self, f: F)where F: FnMut(Symbol, &[Symbol], HistoryId) -> bool,

Retains only the rules specified by the predicate.

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

source

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

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

source

fn history_graph(&self) -> &HistoryGraph

source

fn add_history_node(&mut self, node: HistoryNode) -> HistoryId

Provided Methods§

source

fn sym<T>(&mut self) -> Twhere T: SymbolContainer,

Returns generated symbols.

source

fn next_sym(&mut self) -> Symbol

Generates a new unique symbol.

source

fn num_syms(&self) -> usize

Returns the number of symbols in use.

source

fn rule(&mut self, lhs: Symbol) -> RuleBuilder<&mut Self>

Starts building a new rule.

source

fn precedenced_rule(&mut self, lhs: Symbol) -> PrecedencedRuleBuilder<&mut Self>

Starts building a new precedenced rule.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a, D> RuleContainer for &'a mut Dwhere D: RuleContainer,

source§

fn sym_source(&self) -> &SymbolSource

source§

fn sym_source_mut(&mut self) -> &mut SymbolSource

source§

fn retain<F>(&mut self, f: F)where F: FnMut(Symbol, &[Symbol], HistoryId) -> bool,

source§

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

source§

fn add_history_node(&mut self, node: HistoryNode) -> HistoryId

source§

fn history_graph(&self) -> &HistoryGraph

Implementors§