summaryrefslogtreecommitdiff
path: root/pest_consume
diff options
context:
space:
mode:
authorNadrieril2019-09-10 14:04:38 +0200
committerNadrieril2019-09-10 14:04:38 +0200
commit7e9c8d5fbb1c6536012207073931b3db09345fad (patch)
treefc8cd15a1024bcd572b5650ab03daee352a54c51 /pest_consume
parenta86088505de38c9b3d4c4bb8feecab28055514d8 (diff)
Remove custom pair debugging
Diffstat (limited to 'pest_consume')
-rw-r--r--pest_consume/src/lib.rs52
1 files changed, 0 insertions, 52 deletions
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<Rule> {
- 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<Rule: pest::RuleType>(pair: Pair<Rule>) -> String {
- use std::fmt::Write;
- let mut s = String::new();
- fn aux<Rule: pest::RuleType>(
- s: &mut String,
- indent: usize,
- prefix: String,
- pair: Pair<Rule>,
- ) {
- 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