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 with_declarations(self, declarations: GrammarDeclarations) -> Self
pub fn with_declarations(self, declarations: GrammarDeclarations) -> Self
Returns this grammar with feature union declarations.
Sourcepub const fn declarations(&self) -> &GrammarDeclarations
pub const fn declarations(&self) -> &GrammarDeclarations
The feature union declarations.
Sourcepub fn set_declarations(&mut self, declarations: GrammarDeclarations)
pub fn set_declarations(&mut self, declarations: GrammarDeclarations)
Replaces the feature union declarations.
Sourcepub fn kinds(&self) -> &[GrammarKind]
pub fn kinds(&self) -> &[GrammarKind]
The node kinds no rule defines that keep their source names.
Sourcepub fn set_kinds(&mut self, kinds: Vec<GrammarKind>)
pub fn set_kinds(&mut self, kinds: Vec<GrammarKind>)
Replaces the node kinds no rule defines.
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§
impl Eq for Grammar
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>
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 = ()
§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
§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
key and return true if they are equal.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