aboutsummaryrefslogtreecommitdiff
path: root/src/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/parser.rs b/src/parser.rs
index e917aac..418a17e 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -222,27 +222,30 @@ parser! {
}
}
-#[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);
+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!");
- }
+ 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::*;
#[test]
fn test_sets() {