#[repr(u8)]pub enum GreType {
End = 0,
Alt = 1,
RuleRef = 2,
Char = 3,
CharNot = 4,
CharRngUpper = 5,
CharAlt = 6,
CharAny = 7,
Token = 8,
TokenNot = 9,
}Expand description
Element kinds, matching enum llama_gretype one for one.
The discriminants are llama.cpp’s, so a serialized grammar could be compared against upstream without a translation table.
Variants§
End = 0
End of a rule definition.
Alt = 1
Start of an alternate definition for a rule.
RuleRef = 2
Non-terminal: a reference to another rule, by rule id.
Char = 3
Terminal: a single Unicode code point.
CharNot = 4
Inverted character set: [^a], [^a-b], [^abc].
CharRngUpper = 5
Modifies a preceding Char or CharAlt into an inclusive range
([a-z]).
CharAlt = 6
Modifies a preceding Char or CharRngUpper by adding another
alternative to match ([ab], [a-zA]).
CharAny = 7
Any character (.).
Token = 8
Terminal: a token id (<[42]>).
TokenNot = 9
Inverted token (!<[42]>).
Implementations§
Source§impl GreType
impl GreType
Sourcepub fn is_char_element(self) -> bool
pub fn is_char_element(self) -> bool
True for the element kinds that consume a character.
llama_grammar_is_char_element, used only by the printer and by
rule validation.
Sourcepub fn is_stack_terminal(self) -> bool
pub fn is_stack_terminal(self) -> bool
True for the element kinds a parse stack may legally rest on.
llama_grammar_advance_stack aborts if a stack top is anything
else; we return an error instead (see super::GrammarError).
Trait Implementations§
impl Copy for GreType
impl Eq for GreType
Source§impl Ord for GreType
impl Ord for GreType
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for GreType
impl PartialOrd for GreType
impl StructuralPartialEq for GreType
Auto Trait Implementations§
impl Freeze for GreType
impl RefUnwindSafe for GreType
impl Send for GreType
impl Sync for GreType
impl Unpin for GreType
impl UnsafeUnpin for GreType
impl UnwindSafe for GreType
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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