Skip to content

Commit

Permalink
Merge pull request #459 from ltratt/better_file_warning
Browse files Browse the repository at this point in the history
Give better warnings if lexer/grammar can't be read at build time.
  • Loading branch information
ratmice authored Jun 4, 2024
2 parents 05e40d1 + 1409b63 commit ff41257
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lrlex/src/lib/ctbuilder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ where
lk.insert(outp.clone());
}

let lex_src = read_to_string(lexerp)?;
let lex_src = read_to_string(lexerp)
.map_err(|e| format!("When reading '{}': {e}", lexerp.display()))?;
let line_cache = NewlineCache::from_str(&lex_src).unwrap();
let mut lexerdef: Box<dyn LexerDef<LexerTypesT>> = match self.lexerkind {
LexerKind::LRNonStreamingLexer => Box::new(
Expand Down
3 changes: 2 additions & 1 deletion lrpar/src/lib/ctbuilder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ where
lk.insert(outp.clone());
}

let inc = read_to_string(grmp).unwrap();
let inc =
read_to_string(grmp).map_err(|e| format!("When reading '{}': {e}", grmp.display()))?;
let ast_validation = ASTWithValidityInfo::new(yk, &inc);
let warnings = ast_validation.ast().warnings();
let spanned_fmt = |x: &dyn Spanned, inc: &str, line_cache: &NewlineCache| {
Expand Down

0 comments on commit ff41257

Please sign in to comment.