diff --git a/schala-lang/codegen/src/lib.rs b/schala-lang/codegen/src/lib.rs index 6883a4d..c752a9d 100644 --- a/schala-lang/codegen/src/lib.rs +++ b/schala-lang/codegen/src/lib.rs @@ -32,7 +32,10 @@ impl Fold for RecursiveDescentFn { if self.parse_level != 0 { self.parse_level -= 1; } - result + result.map_err(|mut parse_error: ParseError| { + parse_error.production_name = Some(stringify!(#ident).to_string()); + parse_error + }) } }; i.block = Box::new(new_block); diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index 3bf1d37..c591827 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -160,13 +160,14 @@ use crate::ast::*; /// Represents a parsing error #[derive(Debug)] pub struct ParseError { + pub production_name: Option, pub msg: String, pub token: Token } impl ParseError { fn new_with_token(msg: M, token: Token) -> ParseResult where M: Into { - Err(ParseError { msg: msg.into(), token }) + Err(ParseError { msg: msg.into(), token, production_name: None }) } }