pub enum Rule<'a> {
Text(Cow<'a, str>),
Choice(Cow<'a, [&'a Rule<'a>]>),
Sequence(Cow<'a, [&'a Rule<'a>]>),
Repeat(RepeatRange, &'a Rule<'a>),
Semantic(SemanticValue<Cow<'a, str>>, &'a Rule<'a>),
}Expand description
A rule that defines one or more phrases or fragments that can be recognized by the engine.
Variants§
Text(Cow<'a, str>)
A sequence of words
Choice(Cow<'a, [&'a Rule<'a>]>)
A set of rules to choose from
Sequence(Cow<'a, [&'a Rule<'a>]>)
A sequence of rules that must be recognized in order
Repeat(RepeatRange, &'a Rule<'a>)
A rule repeated a certain number of times
Semantic(SemanticValue<Cow<'a, str>>, &'a Rule<'a>)
A rule that will produce a node in the semantic tree when recognized
Implementations§
Source§impl<'a> Rule<'a>
impl<'a> Rule<'a>
Sourcepub fn text<T: Into<Cow<'a, str>>>(text: T) -> Self
pub fn text<T: Into<Cow<'a, str>>>(text: T) -> Self
Creates a rule that defines a sequence of words to be recognized.
Sourcepub fn choice<L: Into<Cow<'a, [&'a Rule<'a>]>>>(options: L) -> Self
pub fn choice<L: Into<Cow<'a, [&'a Rule<'a>]>>>(options: L) -> Self
Creates a rule that defines a set of alternatives to choose from.
Sourcepub fn sequence<L: Into<Cow<'a, [&'a Rule<'a>]>>>(parts: L) -> Self
pub fn sequence<L: Into<Cow<'a, [&'a Rule<'a>]>>>(parts: L) -> Self
Creates a rule the defines a sequence of sub-rules that must be recognized in order.
Sourcepub fn repeat<R: Into<RepeatRange>>(times: R, target: &'a Rule<'a>) -> Self
pub fn repeat<R: Into<RepeatRange>>(times: R, target: &'a Rule<'a>) -> Self
Creates a rule that recognizes a sub-rule repeated a certain number of times.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Rule<'a>
impl<'a> RefUnwindSafe for Rule<'a>
impl<'a> Send for Rule<'a>
impl<'a> Sync for Rule<'a>
impl<'a> Unpin for Rule<'a>
impl<'a> UnwindSafe for Rule<'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