From 7e9c8d5fbb1c6536012207073931b3db09345fad Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 10 Sep 2019 14:04:38 +0200 Subject: Remove custom pair debugging --- pest_consume/src/lib.rs | 52 ------------------------------------------------- 1 file changed, 52 deletions(-) (limited to 'pest_consume/src') diff --git a/pest_consume/src/lib.rs b/pest_consume/src/lib.rs index 7e2c1ca..1a7d4f2 100644 --- a/pest_consume/src/lib.rs +++ b/pest_consume/src/lib.rs @@ -33,11 +33,6 @@ where } /// Create an error that points to the span of the input. pub fn error(&self, message: String) -> Error { - let message = format!( - "{} while matching on:\n{}", - message, - debug_pair(self.pair.clone()) - ); Error::new_from_span( ErrorVariant::CustomError { message }, self.as_span(), @@ -116,53 +111,6 @@ pub trait PestConsumer { fn allows_shortcut(rule: Self::Rule) -> bool; } -/// Pretty-print a pair and its nested children. -fn debug_pair(pair: Pair) -> String { - use std::fmt::Write; - let mut s = String::new(); - fn aux( - s: &mut String, - indent: usize, - prefix: String, - pair: Pair, - ) { - let indent_str = "| ".repeat(indent); - let rule = pair.as_rule(); - let contents = pair.as_str(); - let mut inner = pair.into_inner(); - let mut first = true; - while let Some(p) = inner.next() { - if first { - first = false; - let last = inner.peek().is_none(); - if last && p.as_str() == contents { - let prefix = format!("{}{:?} > ", prefix, rule); - aux(s, indent, prefix, p); - continue; - } else { - writeln!( - s, - r#"{}{}{:?}: "{}""#, - indent_str, prefix, rule, contents - ) - .unwrap(); - } - } - aux(s, indent + 1, "".into(), p); - } - if first { - writeln!( - s, - r#"{}{}{:?}: "{}""#, - indent_str, prefix, rule, contents - ) - .unwrap(); - } - } - aux(&mut s, 0, "".into(), pair); - s -} - impl<'input, 'data, Rule, Data> Iterator for ParseInputs<'input, 'data, Rule, Data> where -- cgit v1.2.3