From cafb3a62af10bb09f8489ba0ab07258a70a75664 Mon Sep 17 00:00:00 2001 From: tslil Date: Wed, 29 Apr 2026 12:45:48 +0100 Subject: wire in instance checking to the main checker --- src/parser.rs | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'src/parser.rs') diff --git a/src/parser.rs b/src/parser.rs index e917aac..418a17e 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -222,28 +222,31 @@ parser! { } } +pub fn debug_parse(src: &str) -> Programme { + match parser::program(src) { + Ok(p) => { + println!("```{}\n```\n=>\n{}\n", src, p); + p + } + Err(e) => { + let line = e.location.line; + let col = e.location.column; + let off = e.location.offset; + println!("FAIL at {}:{} (offset {})", line, col, off); + println!("expected: {:#}", e.expected); + + let before = &src[off.saturating_sub(40)..off]; + let after = &src[off..(off + 40).min(src.len())]; + println!("...{}⟨HERE⟩{}...", before, after); + panic!("Parse failed!"); + } + } +} + #[cfg(test)] mod tests { use super::*; - fn debug_parse(src: &str) { - match parser::program(src) { - Ok(p) => println!("```{}\n```\n=>\n{}\n", src, p), - Err(e) => { - let line = e.location.line; - let col = e.location.column; - let off = e.location.offset; - println!("FAIL at {}:{} (offset {})", line, col, off); - println!("expected: {:#}", e.expected); - - let before = &src[off.saturating_sub(40)..off]; - let after = &src[off..(off + 40).min(src.len())]; - println!("...{}⟨HERE⟩{}...", before, after); - panic!("Parse failed!"); - } - } - } - #[test] fn test_sets() { let src = r#" -- cgit v1.3.1