pub struct ASTWithValidityInfo { /* private fields */ }Expand description
Contains a GrammarAST structure produced from a grammar source file.
As well as any errors which occurred during the construction of the AST.
Implementations§
Source§impl ASTWithValidityInfo
impl ASTWithValidityInfo
Sourcepub fn new(yacc_kind: YaccKind, s: &str) -> Self
pub fn new(yacc_kind: YaccKind, s: &str) -> Self
Parses a source file into an AST, returning an ast and any errors that were
encountered during the construction of it. The ASTWithValidityInfo can be
then unused to construct a YaccGrammar, which will either produce an
Ok(YaccGrammar) or an Err which includes these errors.
This function ignores the %grmtools section entirely, assuming that the caller has
already extracted the YaccKind if any.
Sourcepub fn ast(&self) -> &GrammarAST
pub fn ast(&self) -> &GrammarAST
Returns a GrammarAST constructed as the result of parsing a source file.
When errors have occurred and is_valid returns false, this AST is the
subset of the source file which parsed correctly while not encountering
any errors. As such even when an AST is not valid, it will return an AST.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns whether any errors where encountered during the parsing and validation of the AST during it’s construction.
Sourcepub fn yacc_kind(&self) -> YaccKind
pub fn yacc_kind(&self) -> YaccKind
Returns the YaccKind that was used to parse the GrammarAST.
Sourcepub fn errors(&self) -> &[YaccGrammarError]
pub fn errors(&self) -> &[YaccGrammarError]
Returns all errors which were encountered during AST construction.
pub fn clone_and_change_start_rule( &self, rule: Rule, ) -> Result<Self, ASTModificationError>
Sourcepub fn header_value_get(&self, key: &str) -> Option<(Span, &Value<Span>)>
pub fn header_value_get(&self, key: &str) -> Option<(Span, &Value<Span>)>
Performs a lookup in the grmtools section for an entry with the key crate_name.key_name and returns it.
Sourcepub fn iter_prefix_keys(
&self,
prefix: &str,
) -> impl Iterator<Item = (&str, Span)>
pub fn iter_prefix_keys( &self, prefix: &str, ) -> impl Iterator<Item = (&str, Span)>
Returns all the keys starting with {prefix}. for the prefix from the %grmtools section.
Sourcepub fn iter_prefixes(&self) -> impl Iterator<Item = &str>
pub fn iter_prefixes(&self) -> impl Iterator<Item = &str>
Returns all of the unique prefixes for all keys in the %grmtools section.