pub struct Grammar { /* private fields */ }Expand description
Order-preserving grammar.
Implementations§
Source§impl Grammar
impl Grammar
Sourcepub fn validate(&self) -> Vec<GrammarDiagnostic>
pub fn validate(&self) -> Vec<GrammarDiagnostic>
Runs semantic grammar validation.
Source§impl Grammar
impl Grammar
Sourcepub const fn builder() -> GrammarBuilder
pub const fn builder() -> GrammarBuilder
Builds a fluent grammar builder.
Sourcepub const fn expr() -> ExprBuilder
pub const fn expr() -> ExprBuilder
Builds an expression builder.
Sourcepub fn with_rule(self, rule: GrammarRule) -> Self
pub fn with_rule(self, rule: GrammarRule) -> Self
Returns this grammar with an additional rule.
Sourcepub fn with_start(self, start: impl Into<String>) -> Self
pub fn with_start(self, start: impl Into<String>) -> Self
Returns this grammar with a start rule name.
Sourcepub const fn with_source_format(self, source_format: GrammarFormat) -> Self
pub const fn with_source_format(self, source_format: GrammarFormat) -> Self
Returns this grammar with a source format.
Sourcepub fn add_rule(&mut self, rule: GrammarRule)
pub fn add_rule(&mut self, rule: GrammarRule)
Adds a rule to the grammar.
Sourcepub fn clear_start(&mut self)
pub fn clear_start(&mut self)
Clears the explicit grammar start rule.
Sourcepub const fn set_source_format(&mut self, source_format: GrammarFormat)
pub const fn set_source_format(&mut self, source_format: GrammarFormat)
Sets the grammar source format.
Sourcepub fn rules(&self) -> &[GrammarRule]
pub fn rules(&self) -> &[GrammarRule]
Returns all rules in source order.
Sourcepub fn rule(&self, name: &str) -> Option<&GrammarRule>
pub fn rule(&self, name: &str) -> Option<&GrammarRule>
Returns the rule with name, when present.
Sourcepub fn start(&self) -> Option<&str>
pub fn start(&self) -> Option<&str>
Returns the explicitly configured start symbol, if present.
Sourcepub fn start_rule(&self) -> Option<&GrammarRule>
pub fn start_rule(&self) -> Option<&GrammarRule>
Returns the start rule, defaulting to the first rule when unset.
Sourcepub const fn source_format(&self) -> Option<GrammarFormat>
pub const fn source_format(&self) -> Option<GrammarFormat>
Returns the source format, if known.
Sourcepub fn rule_names(&self) -> Vec<&str>
pub fn rule_names(&self) -> Vec<&str>
Returns rule names in source order.
Sourcepub fn referenced_nonterminals(&self) -> BTreeSet<String>
pub fn referenced_nonterminals(&self) -> BTreeSet<String>
Returns non-terminal names referenced from every rule expression.
Sourcepub fn undefined_nonterminals(&self) -> BTreeSet<String>
pub fn undefined_nonterminals(&self) -> BTreeSet<String>
Returns referenced non-terminals that do not have a local rule.
Trait Implementations§
Source§impl FromLinks for Grammar
impl FromLinks for Grammar
Source§fn from_links(
decoder: &mut LinksDecoder<'_>,
link: LinkId,
) -> Result<Self, LinksCodecError>
fn from_links( decoder: &mut LinksDecoder<'_>, link: LinkId, ) -> Result<Self, LinksCodecError>
Reconstructs this value from a root link id.
Source§impl ToLinks for Grammar
impl ToLinks for Grammar
Source§fn to_links(&self, encoder: &mut LinksEncoder) -> LinkId
fn to_links(&self, encoder: &mut LinksEncoder) -> LinkId
Inserts links for this value and returns the root link id.
impl Eq for Grammar
impl StructuralPartialEq for Grammar
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§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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,
§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
Compare self to
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
Checks if this value is equivalent to the given key. Read more
§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
Checks if this value is equivalent to the given key. Read more
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§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.