Trait cfg::rule_container::RuleContainer

source ·
pub trait RuleContainer: Sized {
Show 13 methods // 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(RuleRef<'_>) -> bool; fn add_rule(&mut self, rule_ref: RuleRef<'_>); fn history_graph(&self) -> &HistoryGraph; fn add_history_node(&mut self, node: HistoryNode) -> NonZero<usize>; fn rules<'a>(&'a self) -> impl Iterator<Item = RuleRef<'a>> where Self: 'a; // Provided methods fn sym<const N: usize>(&mut self) -> [Symbol; N] { ... } 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> { ... } fn reverse(&self) -> Self where Self: Default { ... }
}
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(RuleRef<'_>) -> 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, rule_ref: RuleRef<'_>)

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) -> NonZero<usize>

source

fn rules<'a>(&'a self) -> impl Iterator<Item = RuleRef<'a>>
where Self: 'a,

Provided Methods§

source

fn sym<const N: usize>(&mut self) -> [Symbol; N]

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.

source

fn reverse(&self) -> Self
where Self: Default,

Reverses the grammar.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl RuleContainer for BinarizedGrammar

source§

fn rules<'a>(&'a self) -> impl Iterator<Item = RuleRef<'a>>
where BinarizedGrammar: 'a,

source§

fn history_graph(&self) -> &HistoryGraph

source§

fn add_history_node(&mut self, node: HistoryNode) -> NonZero<usize>

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(RuleRef<'_>) -> bool,

source§

fn add_rule(&mut self, rule: RuleRef<'_>)

source§

impl<'r, D> RuleContainer for &'r mut D
where D: RuleContainer,

source§

fn reverse(&self) -> &'r mut D

Reverses the grammar.

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(RuleRef<'_>) -> bool,

source§

fn add_rule(&mut self, rule_ref: RuleRef<'_>)

source§

fn add_history_node(&mut self, node: HistoryNode) -> NonZero<usize>

source§

fn history_graph(&self) -> &HistoryGraph

source§

fn rules<'a>(&'a self) -> impl Iterator<Item = RuleRef<'a>>
where &'r mut D: 'a,

Implementors§