Add production name in ParseError
for debugging
This commit is contained in:
parent
f9a59838b0
commit
28056b1f89
@ -32,7 +32,10 @@ impl Fold for RecursiveDescentFn {
|
|||||||
if self.parse_level != 0 {
|
if self.parse_level != 0 {
|
||||||
self.parse_level -= 1;
|
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);
|
i.block = Box::new(new_block);
|
||||||
|
@ -160,13 +160,14 @@ use crate::ast::*;
|
|||||||
/// Represents a parsing error
|
/// Represents a parsing error
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ParseError {
|
pub struct ParseError {
|
||||||
|
pub production_name: Option<String>,
|
||||||
pub msg: String,
|
pub msg: String,
|
||||||
pub token: Token
|
pub token: Token
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ParseError {
|
impl ParseError {
|
||||||
fn new_with_token<T, M>(msg: M, token: Token) -> ParseResult<T> where M: Into<String> {
|
fn new_with_token<T, M>(msg: M, token: Token) -> ParseResult<T> where M: Into<String> {
|
||||||
Err(ParseError { msg: msg.into(), token })
|
Err(ParseError { msg: msg.into(), token, production_name: None })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user