Minor fix for parsing error messages

This commit is contained in:
greg 2018-11-20 03:03:08 -08:00
parent e00948cad9
commit 6be208b51d

View File

@ -19,10 +19,10 @@ impl Fold for RecursiveDescentFn {
let new_block: syn::Block = parse_quote! {
{
let next_token = self.peek_with_token_offset();
let next_token_before_parse = self.peek_with_token_offset();
let record = ParseRecord {
production_name: stringify!(#ident).to_string(),
next_token: format!("{}", next_token.to_string_with_metadata()),
next_token: format!("{}", next_token_before_parse.to_string_with_metadata()),
level: self.parse_level,
};
self.parse_level += 1;
@ -33,8 +33,11 @@ impl Fold for RecursiveDescentFn {
self.parse_level -= 1;
}
match result {
Err(ParseError { token: None, msg }) =>
Err(ParseError { token: Some(next_token), msg }),
Err(ParseError { token: None, msg }) => {
let next_token_after_parse = self.peek_with_token_offset();
println!("HERE? {:?}", next_token_after_parse);
Err(ParseError { token: Some(next_token_after_parse), msg })
},
_ => result
}
}