pub enum GrammarExpr {
Show 16 variants
Empty,
Terminal(String),
TerminalInsensitive(String),
CharRange(char, char),
CharClass {
negated: bool,
items: Vec<CharClassItem>,
},
AnyChar,
NonTerminal(String),
Choice {
ordered: bool,
alternatives: Vec<Self>,
},
Sequence(Vec<Self>),
Optional(Box<Self>),
ZeroOrMore(Box<Self>),
OneOrMore(Box<Self>),
Repeat {
expr: Box<Self>,
min: usize,
max: Option<usize>,
},
And(Box<Self>),
Not(Box<Self>),
Capture {
label: Option<String>,
expr: Box<Self>,
},
}Expand description
One node of the grammar expression algebra.
Variants§
Empty
Matches the empty string.
Terminal(String)
Literal string terminal, for example "fn".
TerminalInsensitive(String)
Case-insensitive literal string terminal.
CharRange(char, char)
Inclusive character range, for example 'a'..='z'.
CharClass
Explicit set of characters or ranges.
Fields
items: Vec<CharClassItem>Characters and ranges accepted by the class.
AnyChar
The any-character wildcard.
NonTerminal(String)
Reference to another grammar rule by name.
Choice
Alternation between expressions.
Fields
Sequence(Vec<Self>)
Concatenation of expressions.
Optional(Box<Self>)
Optional expression.
ZeroOrMore(Box<Self>)
Zero-or-more repetition.
OneOrMore(Box<Self>)
One-or-more repetition.
Repeat
Counted repetition.
Fields
And(Box<Self>)
Positive lookahead predicate.
Not(Box<Self>)
Negative lookahead predicate.
Capture
Labelled or anonymous capture.
Implementations§
Source§impl GrammarExpr
impl GrammarExpr
Sourcepub fn terminal_insensitive(value: impl Into<String>) -> Self
pub fn terminal_insensitive(value: impl Into<String>) -> Self
Builds a case-insensitive literal terminal expression.
Sourcepub const fn char_range(start: char, end: char) -> Self
pub const fn char_range(start: char, end: char) -> Self
Builds an inclusive character range expression.
Sourcepub fn char_class<I>(negated: bool, items: I) -> Selfwhere
I: IntoIterator<Item = CharClassItem>,
pub fn char_class<I>(negated: bool, items: I) -> Selfwhere
I: IntoIterator<Item = CharClassItem>,
Builds a character class expression.
Sourcepub fn non_terminal(value: impl Into<String>) -> Self
pub fn non_terminal(value: impl Into<String>) -> Self
Builds a non-terminal reference expression.
Sourcepub fn choice<I>(ordered: bool, alternatives: I) -> Selfwhere
I: IntoIterator<Item = Self>,
pub fn choice<I>(ordered: bool, alternatives: I) -> Selfwhere
I: IntoIterator<Item = Self>,
Builds a choice expression.
Sourcepub fn sequence<I>(items: I) -> Selfwhere
I: IntoIterator<Item = Self>,
pub fn sequence<I>(items: I) -> Selfwhere
I: IntoIterator<Item = Self>,
Builds a sequence expression.
Sourcepub fn zero_or_more(expr: Self) -> Self
pub fn zero_or_more(expr: Self) -> Self
Builds a zero-or-more repetition expression.
Sourcepub fn one_or_more(expr: Self) -> Self
pub fn one_or_more(expr: Self) -> Self
Builds a one-or-more repetition expression.
Sourcepub fn repeat(expr: Self, min: usize, max: Option<usize>) -> Self
pub fn repeat(expr: Self, min: usize, max: Option<usize>) -> Self
Builds a counted repetition expression.
Sourcepub fn capture(label: impl Into<String>, expr: Self) -> Self
pub fn capture(label: impl Into<String>, expr: Self) -> Self
Builds a labelled capture expression.
Sourcepub fn capture_unlabeled(expr: Self) -> Self
pub fn capture_unlabeled(expr: Self) -> Self
Builds an anonymous capture expression.
Trait Implementations§
Source§impl Clone for GrammarExpr
impl Clone for GrammarExpr
Source§fn clone(&self) -> GrammarExpr
fn clone(&self) -> GrammarExpr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GrammarExpr
impl Debug for GrammarExpr
Source§impl Display for GrammarExpr
impl Display for GrammarExpr
Source§impl PartialEq for GrammarExpr
impl PartialEq for GrammarExpr
Source§fn eq(&self, other: &GrammarExpr) -> bool
fn eq(&self, other: &GrammarExpr) -> bool
self and other values to be equal, and is used by ==.impl Eq for GrammarExpr
impl StructuralPartialEq for GrammarExpr
Auto Trait Implementations§
impl Freeze for GrammarExpr
impl RefUnwindSafe for GrammarExpr
impl Send for GrammarExpr
impl Sync for GrammarExpr
impl Unpin for GrammarExpr
impl UnsafeUnpin for GrammarExpr
impl UnwindSafe for GrammarExpr
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more