From 6be208b51d02c7782b409ba0dcdeee71b5c2336d Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 20 Nov 2018 03:03:08 -0800 Subject: [PATCH] Minor fix for parsing error messages --- schala-lang/codegen/src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/schala-lang/codegen/src/lib.rs b/schala-lang/codegen/src/lib.rs index 7647249..7ba53ec 100644 --- a/schala-lang/codegen/src/lib.rs +++ b/schala-lang/codegen/src/lib.rs @@ -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 } }