nom::dbg_dmp! [] [src]

macro_rules! dbg_dmp (
  ($i: expr, $submac:ident!( $($args:tt)* )) => (
    {
      use $crate::HexDisplay;
      let l = line!();
      match $submac!($i, $($args)*) {
        $crate::IResult::Error(a) => {
          println!("Error({:?}) at l.{} by ' {} '\n{}", a, l, stringify!($submac!($($args)*)), $i.to_hex(8));
          $crate::IResult::Error(a)
        },
        $crate::IResult::Incomplete(a) => {
          println!("Incomplete({:?}) at {} by ' {} '\n{}", a, l, stringify!($submac!($($args)*)), $i.to_hex(8));
          $crate::IResult::Incomplete(a)
        },
        a => a
      }
    }
  );
);

Prints a message and the input if the parser fails

The message prints the Error or Incomplete and the parser's calling code.

It also displays the input in hexdump format

   named!(f, dbg_dmp!( tag!( "abcd" ) ) );

   let a = &b"efghijkl"[..];

   // Will print the following message:
   // Error(Position(0, [101, 102, 103, 104, 105, 106, 107, 108])) at l.5 by ' tag ! ( "abcd" ) '
   // 00000000        65 66 67 68 69 6a 6b 6c         efghijkl
   f(a);