Skip to content

Commit

Permalink
Merge pull request #434 from ratmice/ast_validity_priv_fields
Browse files Browse the repository at this point in the history
Make pub(crate) fields of `ASTWithValidityInfo` private.
  • Loading branch information
ltratt authored Dec 31, 2023
2 parents 62b9c4e + 4fa1426 commit 37275d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cfgrammar/src/lib/yacc/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use crate::Span;
/// Contains a `GrammarAST` structure produced from a grammar source file.
/// As well as any errors which occurred during the construction of the AST.
pub struct ASTWithValidityInfo {
pub(crate) ast: GrammarAST,
pub(crate) errs: Vec<YaccGrammarError>,
ast: GrammarAST,
errs: Vec<YaccGrammarError>,
}

impl ASTWithValidityInfo {
Expand Down Expand Up @@ -48,7 +48,7 @@ impl ASTWithValidityInfo {
/// Returns whether any errors where encountered during the
/// parsing and validation of the AST during it's construction.
pub fn is_valid(&self) -> bool {
self.errs.is_empty()
self.errors().is_empty()
}

/// Returns all errors which were encountered during AST construction.
Expand Down
4 changes: 2 additions & 2 deletions cfgrammar/src/lib/yacc/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ where
ast_validation: &ast::ASTWithValidityInfo,
) -> YaccGrammarResult<Self> {
if !ast_validation.is_valid() {
return Err(ast_validation.errs.clone());
return Err(ast_validation.errors().to_owned());
}
let ast = &ast_validation.ast;
let ast = ast_validation.ast();
// Check that StorageT is big enough to hold RIdx/PIdx/SIdx/TIdx values; after these
// checks we can guarantee that things like RIdx(ast.rules.len().as_()) are safe.
if ast.rules.len() > num_traits::cast(StorageT::max_value()).unwrap() {
Expand Down

0 comments on commit 37275d5

Please sign in to comment.