pub struct GrammarBuilder<'a> { /* private fields */ }
Expand description
Helper type that constructs a grammar from a set of top-level rules.
A top-level rule defines one or more phrases that can be recognized. The rules contained in or referenced by a top-level rule will not be recognized as phrases, unless they are also added as top-level rules. For example, consider the following top-level rule definition:
Rule::sequence(vec![
&Rule::text("good"),
&Rule::choice(vec![
&Rule::text("morning"),
&Rule::text("evening"),
])
])
Given this rule, the engine will only recognize the phrases “good morning” and “good evening”, but not “good”, “morning”, or “evening”.
Implementations§
Source§impl<'a> GrammarBuilder<'a>
impl<'a> GrammarBuilder<'a>
Sourcepub fn add_rule(&mut self, rule: &'a Rule<'a>) -> &mut Self
pub fn add_rule(&mut self, rule: &'a Rule<'a>) -> &mut Self
Adds an unnamed top-level rule to the grammar.
Auto Trait Implementations§
impl<'a> Freeze for GrammarBuilder<'a>
impl<'a> RefUnwindSafe for GrammarBuilder<'a>
impl<'a> Send for GrammarBuilder<'a>
impl<'a> Sync for GrammarBuilder<'a>
impl<'a> Unpin for GrammarBuilder<'a>
impl<'a> UnwindSafe for GrammarBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more