pub struct Grammar {
pub rules: HashMap<String, GrammarNode>,
pub root: String,
pub source: String,
}Expand description
A fully parsed GBNF grammar.
Fields§
§rules: HashMap<String, GrammarNode>Map from rule name to its grammar node.
root: StringThe root rule name (first rule defined, or “root” if present).
source: StringThe original GBNF source string (retained for snapshot/resume).
Implementations§
Source§impl Grammar
impl Grammar
Sourcepub fn parse(input: &str) -> GrammarResult<Self>
pub fn parse(input: &str) -> GrammarResult<Self>
Parse a GBNF grammar string into a Grammar structure.
Sourcepub fn root_node(&self) -> GrammarResult<&GrammarNode>
pub fn root_node(&self) -> GrammarResult<&GrammarNode>
Get the grammar node for the root rule.
Source§impl Grammar
impl Grammar
Sourcepub fn initial_state(&self) -> GrammarState
pub fn initial_state(&self) -> GrammarState
Create the initial parse state for this grammar.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Grammar
impl RefUnwindSafe for Grammar
impl Send for Grammar
impl Sync for Grammar
impl Unpin for Grammar
impl UnsafeUnpin for Grammar
impl UnwindSafe for Grammar
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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