Repository: Geal/nom
Pull request #1351 (2021-08-05 16:00:12)

remove macros from bytes module
related: #1343 


Patch:
diff --git a/src/bytes/macros.rs b/src/bytes/macros.rs
deleted file mode 100644
index 5270ba7..0000000
--- a/src/bytes/macros.rs
+++ /dev/null
@@ -1,974 +0,0 @@
-//! Byte level parsers and combinators
-//!
-#[allow(unused_variables)]
-
-/// `tag!(&[T]: nom::AsBytes) => &[T] -> IResult<&[T], &[T]>`
-/// declares a byte array as a suite to recognize.
-///
-/// Consumes the recognized characters.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  named!(x, tag!("abcd"));
-///  let r = x(&b"abcdefgh"[..]);
-///  assert_eq!(r, Ok((&b"efgh"[..], &b"abcd"[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! tag (
-  ($i:expr, $tag: expr) => ({
-    $crate::bytes::streaming::tag($tag)($i)
-  });
-);
-
-/// `tag_no_case!(&[T]) => &[T] -> IResult<&[T], &[T]>`
-/// declares a case insensitive ascii string as a suite to recognize.
-///
-/// Consumes the recognized characters.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  named!(test, tag_no_case!("ABcd"));
-///
-///  let r = test(&b"aBCdefgh"[..]);
-///  assert_eq!(r, Ok((&b"efgh"[..], &b"aBCd"[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! tag_no_case (
-  ($i:expr, $tag: expr) => ({
-    $crate::bytes::streaming::tag_no_case($tag)($i)
-  });
-);
-
-/// `is_not!(&[T:AsBytes]) => &[T] -> IResult<&[T], &[T]>`
-/// returns the longest list of bytes that do not appear in the provided array.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  named!( not_space, is_not!( " \t\r\n" ) );
-///
-///  let r = not_space(&b"abcdefgh\nijkl"[..]);
-///  assert_eq!(r, Ok((&b"\nijkl"[..], &b"abcdefgh"[..])));
-///  # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! is_not (
-  ($input:expr, $arr:expr) => ({
-    $crate::bytes::streaming::is_not($arr)($input)
-  });
-);
-
-/// `is_a!(&[T]) => &[T] -> IResult<&[T], &[T]>`
-/// returns the longest list of bytes that appear in the provided array.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  named!(abcd, is_a!( "abcd" ));
-///
-///  let r1 = abcd(&b"aaaaefgh"[..]);
-///  assert_eq!(r1, Ok((&b"efgh"[..], &b"aaaa"[..])));
-///
-///  let r2 = abcd(&b"dcbaefgh"[..]);
-///  assert_eq!(r2, Ok((&b"efgh"[..], &b"dcba"[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! is_a (
-  ($input:expr, $arr:expr) => ({
-    $crate::bytes::streaming::is_a($arr)($input)
-  });
-);
-
-/// `escaped!(T -> IResult<T, T>, U, T -> IResult<T, T>) => T -> IResult<T, T> where T: InputIter,
-/// U: AsChar`
-/// matches a byte string with escaped characters.
-///
-/// * The first argument matches the normal characters (it must not accept the control character)
-/// * The second argument is the control character (like `\` in most languages)
-/// * The third argument matches the escaped characters
-#[macro_export(local_inner_macros)]
-macro_rules! escaped (
-  ($i:expr, $submac1:ident!( $($args:tt)* ), $control_char: expr, $submac2:ident!( $($args2:tt)*) ) => (
-    {
-     escaped!($i, |i| $submac1!(i, $($args)*), $control_char,  |i| $submac2!(i, $($args2)*))
-    }
-  );
-  ($i:expr, $normal:expr, $control_char: expr, $submac2:ident!( $($args2:tt)*) ) => (
-    {
-     escaped!($i, $normal, $control_char,  |i| $submac2!(i, $($args2)*))
-    }
-  );
-  ($i:expr, $submac1:ident!( $($args:tt)* ), $control_char: expr, $escapable:expr ) => (
-    {
-     escaped!($i, |i| $submac1!(i, $($args)*), $control_char,  $escapable)
-    }
-  );
-  ($i:expr, $normal:expr, $control_char: expr, $escapable:expr) => (
-    {
-      $crate::bytes::complete::escapedc($i, $normal, $control_char, $escapable)
-    }
-  );
-);
-
-/// `escaped_transform!(&[T] -> IResult<&[T], &[T]>, T, &[T] -> IResult<&[T], &[T]>) => &[T] -> IResult<&[T], Vec<T>>`
-/// matches a byte string with escaped characters.
-///
-/// * The first argument matches the normal characters (it must not match the control character)
-/// * The second argument is the control character (like `\` in most languages)
-/// * The third argument matches the escaped characters and transforms them
-///
-/// As an example, the chain `abc\tdef` could be `abc    def` (it also consumes the control character).
-#[cfg(feature = "alloc")]
-#[cfg_attr(feature = "docsrs", doc(cfg(feature = "alloc")))]
-#[macro_export(local_inner_macros)]
-macro_rules! escaped_transform (
-  ($i:expr, $submac1:ident!( $($args:tt)* ), $control_char: expr, $submac2:ident!( $($args2:tt)*) ) => (
-    {
-     escaped_transform!($i, |i| $submac1!(i, $($args)*), $control_char,  |i| $submac2!(i, $($args2)*))
-    }
-  );
-  ($i:expr, $normal:expr, $control_char: expr, $submac2:ident!( $($args2:tt)*) ) => (
-    {
-     escaped_transform!($i, $normal, $control_char,  |i| $submac2!(i, $($args2)*))
-    }
-  );
-  ($i:expr, $submac1:ident!( $($args:tt)* ), $control_char: expr, $transform:expr ) => (
-    {
-     escaped_transform!($i, |i| $submac1!(i, $($args)*), $control_char,  $transform)
-    }
-  );
-  ($i:expr, $normal:expr, $control_char: expr, $transform:expr) => (
-    {
-      $crate::bytes::complete::escaped_transformc($i, $normal, $control_char, $transform)
-    }
-  );
-);
-
-/// `take_while!(T -> bool) => &[T] -> IResult<&[T], &[T]>`
-/// returns the longest list of bytes until the provided function fails.
-///
-/// The argument is either a function `T -> bool` or a macro returning a `bool`.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use nom::character::is_alphanumeric;
-/// # fn main() {
-///  named!( alpha, take_while!( is_alphanumeric ) );
-///
-///  let r = alpha(&b"abcd\nefgh"[..]);
-///  assert_eq!(r, Ok((&b"\nefgh"[..], &b"abcd"[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! take_while (
-  ($input:expr, $submac:ident!( $($args:tt)* )) => ({
-    let res: $crate::IResult<_, _, _> = take_while!($input, (|c| $submac!(c, $($args)*)));
-    res
-  });
-  ($input:expr, $f:expr) => (
-    $crate::bytes::streaming::take_while($f)($input)
-  );
-);
-
-/// `take_while1!(T -> bool) => &[T] -> IResult<&[T], &[T]>`
-/// returns the longest (non empty) list of bytes until the provided function fails.
-///
-/// The argument is either a function `&[T] -> bool` or a macro returning a `bool`.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err,error::ErrorKind};
-/// # use nom::character::is_alphanumeric;
-/// # fn main() {
-///  named!( alpha, take_while1!( is_alphanumeric ) );
-///
-///  let r = alpha(&b"abcd\nefgh"[..]);
-///  assert_eq!(r, Ok((&b"\nefgh"[..], &b"abcd"[..])));
-///  let r = alpha(&b"\nefgh"[..]);
-///  assert_eq!(r, Err(Err::Error(error_position!(&b"\nefgh"[..], ErrorKind::TakeWhile1))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! take_while1 (
-  ($input:expr, $submac:ident!( $($args:tt)* )) => ({
-    let res: $crate::IResult<_, _, _> = take_while1!($input, (|c| $submac!(c, $($args)*)));
-    res
-  });
-  ($input:expr, $f:expr) => (
-    $crate::bytes::streaming::take_while1($f)($input)
-  );
-);
-
-/// `take_while_m_n!(m: usize, n: usize, T -> bool) => &[T] -> IResult<&[T], &[T]>`
-/// returns a list of bytes or characters for which the provided function returns true.
-/// The returned list's size will be at least m, and at most n.
-///
-/// The argument is either a function `T -> bool` or a macro returning a `bool`.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use nom::character::is_alphanumeric;
-/// # fn main() {
-///  named!( alpha, take_while_m_n!(3, 6, is_alphanumeric ) );
-///
-///  let r = alpha(&b"abcd\nefgh"[..]);
-///  assert_eq!(r, Ok((&b"\nefgh"[..], &b"abcd"[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! take_while_m_n (
-  ($input:expr, $m:expr, $n: expr, $submac:ident!( $($args:tt)* )) => ({
-    let res: $crate::IResult<_, _, _> = take_while_m_n!($input, $m, $n, (|c| $submac!(c, $($args)*)));
-    res
-  });
-  ($input:expr, $m:expr, $n:expr, $f:expr) => (
-    $crate::bytes::streaming::take_while_m_n($m, $n, $f)($input)
-  );
-);
-
-/// `take_till!(T -> bool) => &[T] -> IResult<&[T], &[T]>`
-/// returns the longest list of bytes until the provided function succeeds.
-///
-/// The argument is either a function `&[T] -> bool` or a macro returning a `bool`.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  named!( till_colon, take_till!(|ch| ch == b':') );
-///
-///  let r = till_colon(&b"abcd:efgh"[..]);
-///  assert_eq!(r, Ok((&b":efgh"[..], &b"abcd"[..])));
-///  let r2 = till_colon(&b":abcdefgh"[..]); // empty match is allowed
-///  assert_eq!(r2, Ok((&b":abcdefgh"[..], &b""[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! take_till (
-  ($input:expr, $submac:ident!( $($args:tt)* )) => ({
-    let res: $crate::IResult<_, _, _> = take_till!($input, (|c| $submac!(c, $($args)*)));
-    res
-  });
-  ($input:expr, $f:expr) => (
-    $crate::bytes::streaming::take_till($f)($input)
-  );
-);
-
-/// `take_till1!(T -> bool) => &[T] -> IResult<&[T], &[T]>`
-/// returns the longest non empty list of bytes until the provided function succeeds.
-///
-/// The argument is either a function `&[T] -> bool` or a macro returning a `bool`.
-///
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err, error::ErrorKind};
-/// # fn main() {
-///  named!( till1_colon, take_till1!(|ch| ch == b':') );
-///
-///  let r = till1_colon(&b"abcd:efgh"[..]);
-///  assert_eq!(r, Ok((&b":efgh"[..], &b"abcd"[..])));
-///
-///  let r2 = till1_colon(&b":abcdefgh"[..]); // empty match is error
-///  assert_eq!(r2, Err(Err::Error(error_position!(&b":abcdefgh"[..], ErrorKind::TakeTill1))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! take_till1 (
-  ($input:expr, $submac:ident!( $($args:tt)* )) => ({
-    let res: $crate::IResult<_, _, _> = take_till1!($input, (|c| $submac!(c, $($args)*)));
-    res
-  });
-  ($input:expr, $f:expr) => (
-    $crate::bytes::streaming::take_till1($f)($input)
-  );
-);
-
-/// `take!(nb) => &[T] -> IResult<&[T], &[T]>`
-/// generates a parser consuming the specified number of bytes.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  // Desmond parser
-///  named!(take5, take!( 5 ) );
-///
-///  let a = b"abcdefgh";
-///
-///  assert_eq!(take5(&a[..]), Ok((&b"fgh"[..], &b"abcde"[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! take (
-  ($i:expr, $count:expr) => ({
-    let c = $count as usize;
-    let res: $crate::IResult<_,_,_> = $crate::bytes::streaming::take(c)($i);
-    res
-  });
-);
-
-/// `take_str!(nb) => &[T] -> IResult<&[T], &str>`
-/// same as `take!` but returning a `&str`.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  named!(take5( &[u8] ) -> &str, take_str!( 5 ) );
-///
-///  let a = b"abcdefgh";
-///
-///  assert_eq!(take5(&a[..]), Ok((&b"fgh"[..], "abcde")));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! take_str (
- ( $i:expr, $size:expr ) => (
-    {
-      let input: &[u8] = $i;
-
-      map_res!(input, take!($size), $crate::lib::std::str::from_utf8)
-    }
-  );
-);
-
-/// `take_until!(tag) => &[T] -> IResult<&[T], &[T]>`
-/// consumes data until it finds the specified tag.
-///
-/// The remainder still contains the tag.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  named!(x, take_until!("foo"));
-///  let r = x(&b"abcd foo efgh"[..]);
-///  assert_eq!(r, Ok((&b"foo efgh"[..], &b"abcd "[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! take_until (
-  ($i:expr, $substr:expr) => ({
-    let res: $crate::IResult<_,_,_> = $crate::bytes::streaming::take_until($substr)($i);
-    res
-  });
-);
-
-/// `take_until1!(tag) => &[T] -> IResult<&[T], &[T]>`
-/// consumes data (at least one byte) until it finds the specified tag.
-///
-/// The remainder still contains the tag.
-/// # Example
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  named!(x, take_until1!("foo"));
-///
-///  let r = x(&b"abcd foo efgh"[..]);
-///
-///  assert_eq!(r, Ok((&b"foo efgh"[..], &b"abcd "[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! take_until1 (
-  ($i:expr, $substr:expr) => (
-    {
-      use $crate::lib::std::result::Result::*;
-      use $crate::lib::std::option::Option::*;
-      use $crate::{Err,Needed,IResult,error::ErrorKind};
-      use $crate::InputLength;
-      use $crate::FindSubstring;
-      use $crate::InputTake;
-      let input = $i;
-
-      let res: IResult<_,_> = match input.find_substring($substr) {
-        None => {
-          Err(Err::Incomplete(Needed::new(1 + $substr.input_len())))
-        },
-        Some(0) => {
-          let e = ErrorKind::TakeUntil;
-          Err(Err::Error(error_position!($i, e)))
-        },
-        Some(index) => {
-          Ok($i.take_split(index))
-        },
-      };
-      res
-    }
-  );
-);
-
-#[cfg(test)]
-mod tests {
-  #[cfg(feature = "alloc")]
-  use crate::bytes::complete::escaped_transform;
-  use crate::character::is_alphabetic;
-  use crate::character::streaming::{
-    alpha1 as alpha, alphanumeric1 as alphanumeric, digit1 as digit, hex_digit1 as hex_digit,
-    multispace1 as multispace, oct_digit1 as oct_digit, space1 as space,
-  };
-  use crate::error::ErrorKind;
-  use crate::internal::{Err, IResult, Needed};
-  use crate::{
-      combinator::recognize,
-      sequence::delimited,
-      bytes::streaming::{tag, take}
-  };
-  #[cfg(feature = "alloc")]
-  use crate::branch::alt;
-  #[cfg(feature = "alloc")]
-  use crate::combinator::{map, value};
-  #[cfg(feature = "alloc")]
-  use crate::lib::std::string::String;
-  #[cfg(feature = "alloc")]
-  use crate::lib::std::vec::Vec;
-
-  #[cfg(feature = "alloc")]
-  macro_rules! one_of (
-    ($i:expr, $inp: expr) => (
-      {
-        use $crate::Err;
-        use $crate::Slice;
-        use $crate::AsChar;
-        use $crate::FindToken;
-        use $crate::InputIter;
-
-        match ($i).iter_elements().next().map(|c| {
-          $inp.find_token(c)
-        }) {
-          None        => Err::<_,_>(Err::Incomplete(Needed::new(1))),
-          Some(false) => Err(Err::Error(error_position!($i, ErrorKind::OneOf))),
-          //the unwrap should be safe here
-          Some(true)  => Ok(($i.slice(1..), $i.iter_elements().next().unwrap().as_char()))
-        }
-      }
-    );
-  );
-
-  #[test]
-  fn is_a() {
-    named!(a_or_b, is_a!(&b"ab"[..]));
-
-    let a = &b"abcd"[..];
-    assert_eq!(a_or_b(a), Ok((&b"cd"[..], &b"ab"[..])));
-
-    let b = &b"bcde"[..];
-    assert_eq!(a_or_b(b), Ok((&b"cde"[..], &b"b"[..])));
-
-    let c = &b"cdef"[..];
-    assert_eq!(
-      a_or_b(c),
-      Err(Err::Error(error_position!(c, ErrorKind::IsA)))
-    );
-
-    let d = &b"bacdef"[..];
-    assert_eq!(a_or_b(d), Ok((&b"cdef"[..], &b"ba"[..])));
-  }
-
-  #[test]
-  fn is_not() {
-    named!(a_or_b, is_not!(&b"ab"[..]));
-
-    let a = &b"cdab"[..];
-    assert_eq!(a_or_b(a), Ok((&b"ab"[..], &b"cd"[..])));
-
-    let b = &b"cbde"[..];
-    assert_eq!(a_or_b(b), Ok((&b"bde"[..], &b"c"[..])));
-
-    let c = &b"abab"[..];
-    assert_eq!(
-      a_or_b(c),
-      Err(Err::Error(error_position!(c, ErrorKind::IsNot)))
-    );
-
-    let d = &b"cdefba"[..];
-    assert_eq!(a_or_b(d), Ok((&b"ba"[..], &b"cdef"[..])));
-
-    let e = &b"e"[..];
-    assert_eq!(a_or_b(e), Err(Err::Incomplete(Needed::new(1))));
-  }
-
-  #[cfg(feature = "alloc")]
-  #[allow(unused_variables)]
-  #[test]
-  fn escaping() {
-    named!(esc, escaped!(call!(alpha), '\\', one_of!("\"n\\")));
-    assert_eq!(esc(&b"abcd;"[..]), Ok((&b";"[..], &b"abcd"[..])));
-    assert_eq!(esc(&b"ab\\\"cd;"[..]), Ok((&b";"[..], &b"ab\\\"cd"[..])));
-    assert_eq!(esc(&b"\\\"abcd;"[..]), Ok((&b";"[..], &b"\\\"abcd"[..])));
-    assert_eq!(esc(&b"\\n;"[..]), Ok((&b";"[..], &b"\\n"[..])));
-    assert_eq!(esc(&b"ab\\\"12"[..]), Ok((&b"12"[..], &b"ab\\\""[..])));
-    assert_eq!(
-      esc(&b"AB\\"[..]),
-      Err(Err::Error(error_position!(
-        &b"AB\\"[..],
-        ErrorKind::Escaped
-      )))
-    );
-    assert_eq!(
-      esc(&b"AB\\A"[..]),
-      Err(Err::Error(error_node_position!(
-        &b"AB\\A"[..],
-        ErrorKind::Escaped,
-        error_position!(&b"A"[..], ErrorKind::OneOf)
-      )))
-    );
-
-    named!(esc2, escaped!(call!(digit), '\\', one_of!("\"n\\")));
-    assert_eq!(esc2(&b"12\\nnn34"[..]), Ok((&b"nn34"[..], &b"12\\n"[..])));
-  }
-
-  #[cfg(feature = "alloc")]
-  #[test]
-  fn escaping_str() {
-    named!(esc<&str, &str>, escaped!(call!(alpha), '\\', one_of!("\"n\\")));
-    assert_eq!(esc("abcd;"), Ok((";", "abcd")));
-    assert_eq!(esc("ab\\\"cd;"), Ok((";", "ab\\\"cd")));
-    assert_eq!(esc("\\\"abcd;"), Ok((";", "\\\"abcd")));
-    assert_eq!(esc("\\n;"), Ok((";", "\\n")));
-    assert_eq!(esc("ab\\\"12"), Ok(("12", "ab\\\"")));
-    assert_eq!(
-      esc("AB\\"),
-      Err(Err::Error(error_position!("AB\\", ErrorKind::Escaped)))
-    );
-    assert_eq!(
-      esc("AB\\A"),
-      Err(Err::Error(error_node_position!(
-        "AB\\A",
-        ErrorKind::Escaped,
-        error_position!("A", ErrorKind::OneOf)
-      )))
-    );
-
-    named!(esc2<&str, &str>, escaped!(call!(digit), '\\', one_of!("\"n\\")));
-    assert_eq!(esc2("12\\nnn34"), Ok(("nn34", "12\\n")));
-
-    named!(esc3<&str, &str>, escaped!(call!(alpha), '\u{241b}', one_of!("\"n")));
-    assert_eq!(esc3("ab␛ncd;"), Ok((";", "ab␛ncd")));
-  }
-
-  #[cfg(feature = "alloc")]
-  fn to_s(i: Vec<u8>) -> String {
-    String::from_utf8_lossy(&i).into_owned()
-  }
-
-  #[cfg(feature = "alloc")]
-  #[test]
-  fn escape_transform() {
-    fn esc(i: &[u8]) -> IResult<&[u8], String> {
-        map(
-            escaped_transform(alpha, '\\',
-                          alt((
-                            value(&b"\\"[..], tag("\\")),
-                            value(&b"\""[..], tag("\"")),
-                            value(&b"\n"[..], tag("n")),
-                          ))),
-            to_s)(i)
-    }
-
-    assert_eq!(esc(&b"abcd;"[..]), Ok((&b";"[..], String::from("abcd"))));
-    assert_eq!(
-      esc(&b"ab\\\"cd;"[..]),
-      Ok((&b";"[..], String::from("ab\"cd")))
-    );
-    assert_eq!(
-      esc(&b"\\\"abcd;"[..]),
-      Ok((&b";"[..], String::from("\"abcd")))
-    );
-    assert_eq!(esc(&b"\\n;"[..]), Ok((&b";"[..], String::from("\n"))));
-    assert_eq!(
-      esc(&b"ab\\\"12"[..]),
-      Ok((&b"12"[..], String::from("ab\"")))
-    );
-    assert_eq!(
-      esc(&b"AB\\"[..]),
-      Err(Err::Error(error_position!(
-        &b"\\"[..],
-        ErrorKind::EscapedTransform
-      )))
-    );
-    assert_eq!(
-      esc(&b"AB\\A"[..]),
-      Err(Err::Error(error_node_position!(
-        &b"AB\\A"[..],
-        ErrorKind::EscapedTransform,
-        error_position!(&b"A"[..], ErrorKind::Tag)
-      )))
-    );
-
-    fn esc2(i: &[u8]) -> IResult<&[u8], String> {
-        map(
-            escaped_transform(alpha, '&',
-                          alt((
-                            value("è".as_bytes(), tag("egrave;")),
-                            value("à".as_bytes(), tag("agrave;"))
-                          ))),
-            to_s)(i)
-    }
-    assert_eq!(
-      esc2(&b"ab&egrave;DEF;"[..]),
-      Ok((&b";"[..], String::from("abèDEF")))
-    );
-    assert_eq!(
-      esc2(&b"ab&egrave;D&agrave;EF;"[..]),
-      Ok((&b";"[..], String::from("abèDàEF")))
-    );
-  }
-
-  #[cfg(feature = "std")]
-  #[test]
-  fn escape_transform_str() {
-    fn esc(i: &str) -> IResult<&str, String> {
-        escaped_transform(alpha, '\\',
-                          alt((
-                            value("\\", tag("\\")),
-                            value("\"", tag("\"")),
-                            value("\n", tag("n")),
-                          )))(i)
-    }
-
-    assert_eq!(esc("abcd;"), Ok((";", String::from("abcd"))));
-    assert_eq!(esc("ab\\\"cd;"), Ok((";", String::from("ab\"cd"))));
-    assert_eq!(esc("\\\"abcd;"), Ok((";", String::from("\"abcd"))));
-    assert_eq!(esc("\\n;"), Ok((";", String::from("\n"))));
-    assert_eq!(esc("ab\\\"12"), Ok(("12", String::from("ab\""))));
-    assert_eq!(
-      esc("AB\\"),
-      Err(Err::Error(error_position!(
-        "\\",
-        ErrorKind::EscapedTransform
-      )))
-    );
-    assert_eq!(
-      esc("AB\\A"),
-      Err(Err::Error(error_node_position!(
-        "AB\\A",
-        ErrorKind::EscapedTransform,
-        error_position!("A", ErrorKind::Tag)
-      )))
-    );
-
-    fn esc2(i: &str) -> IResult<&str, String> {
-        escaped_transform(alpha, '&',
-                          alt((
-                            value("è", tag("egrave;")),
-                            value("à", tag("agrave;"))
-                          )))(i)
-    }
-    assert_eq!(esc2("ab&egrave;DEF;"), Ok((";", String::from("abèDEF"))));
-    assert_eq!(
-      esc2("ab&egrave;D&agrave;EF;"),
-      Ok((";", String::from("abèDàEF")))
-    );
-
-    fn esc3(i: &str) -> IResult<&str, String> {
-        escaped_transform(alpha, '␛',
-                          alt((
-                            value("\0", tag("0")),
-                            value("\n", tag("n"))
-                          )))(i)
-    }
-    assert_eq!(esc3("a␛0bc␛n"), Ok(("", String::from("a\0bc\n"))));
-  }
-
-  #[test]
-  fn take_str_test() {
-    let a = b"omnomnom";
-
-    let res: IResult<_, _, (&[u8], ErrorKind)> = take_str!(&a[..], 5u32);
-    assert_eq!(res, Ok((&b"nom"[..], "omnom")));
-
-    let res: IResult<_, _, (&[u8], ErrorKind)> = take_str!(&a[..], 9u32);
-    assert_eq!(res, Err(Err::Incomplete(Needed::new(1))));
-  }
-
-  #[test]
-  fn take_until_incomplete() {
-    named!(y, take_until!("end"));
-    assert_eq!(y(&b"nd"[..]), Err(Err::Incomplete(Needed::Unknown)));
-    assert_eq!(y(&b"123"[..]), Err(Err::Incomplete(Needed::Unknown)));
-    assert_eq!(y(&b"123en"[..]), Err(Err::Incomplete(Needed::Unknown)));
-  }
-
-  #[test]
-  fn take_until_incomplete_s() {
-    named!(ys<&str, &str>, take_until!("end"));
-    assert_eq!(ys("123en"), Err(Err::Incomplete(Needed::Unknown)));
-  }
-
-  #[test]
-  fn recognize_test() {
-    fn x(i: &[u8]) -> IResult<&[u8], &[u8]> {
-        recognize(delimited(tag("<!--"), take(5usize), tag("-->")))(i)
-    }
-
-    let r = x(&b"<!-- abc --> aaa"[..]);
-    assert_eq!(r, Ok((&b" aaa"[..], &b"<!-- abc -->"[..])));
-
-    let semicolon = &b";"[..];
-
-    named!(ya, recognize!(alpha));
-    let ra = ya(&b"abc;"[..]);
-    assert_eq!(ra, Ok((semicolon, &b"abc"[..])));
-
-    named!(yd, recognize!(digit));
-    let rd = yd(&b"123;"[..]);
-    assert_eq!(rd, Ok((semicolon, &b"123"[..])));
-
-    named!(yhd, recognize!(hex_digit));
-    let rhd = yhd(&b"123abcDEF;"[..]);
-    assert_eq!(rhd, Ok((semicolon, &b"123abcDEF"[..])));
-
-    named!(yod, recognize!(oct_digit));
-    let rod = yod(&b"1234567;"[..]);
-    assert_eq!(rod, Ok((semicolon, &b"1234567"[..])));
-
-    named!(yan, recognize!(alphanumeric));
-    let ran = yan(&b"123abc;"[..]);
-    assert_eq!(ran, Ok((semicolon, &b"123abc"[..])));
-
-    named!(ys, recognize!(space));
-    let rs = ys(&b" \t;"[..]);
-    assert_eq!(rs, Ok((semicolon, &b" \t"[..])));
-
-    named!(yms, recognize!(multispace));
-    let rms = yms(&b" \t\r\n;"[..]);
-    assert_eq!(rms, Ok((semicolon, &b" \t\r\n"[..])));
-  }
-
-  #[test]
-  fn take_while() {
-    named!(f, take_while!(is_alphabetic));
-    let a = b"";
-    let b = b"abcd";
-    let c = b"abcd123";
-    let d = b"123";
-
-    assert_eq!(f(&a[..]), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(f(&b[..]), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(f(&c[..]), Ok((&d[..], &b[..])));
-    assert_eq!(f(&d[..]), Ok((&d[..], &a[..])));
-  }
-
-  #[test]
-  fn take_while1() {
-    named!(f, take_while1!(is_alphabetic));
-    let a = b"";
-    let b = b"abcd";
-    let c = b"abcd123";
-    let d = b"123";
-
-    assert_eq!(f(&a[..]), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(f(&b[..]), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(f(&c[..]), Ok((&b"123"[..], &b[..])));
-    assert_eq!(
-      f(&d[..]),
-      Err(Err::Error(error_position!(&d[..], ErrorKind::TakeWhile1)))
-    );
-  }
-
-  #[test]
-  fn take_while_m_n() {
-    named!(x, take_while_m_n!(2, 4, is_alphabetic));
-    let a = b"";
-    let b = b"a";
-    let c = b"abc";
-    let d = b"abc123";
-    let e = b"abcde";
-    let f = b"123";
-
-    assert_eq!(x(&a[..]), Err(Err::Incomplete(Needed::new(2))));
-    assert_eq!(x(&b[..]), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(x(&c[..]), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(x(&d[..]), Ok((&b"123"[..], &c[..])));
-    assert_eq!(x(&e[..]), Ok((&b"e"[..], &b"abcd"[..])));
-    assert_eq!(
-      x(&f[..]),
-      Err(Err::Error(error_position!(&f[..], ErrorKind::TakeWhileMN)))
-    );
-  }
-
-  #[test]
-  fn take_till() {
-    named!(f, take_till!(is_alphabetic));
-    let a = b"";
-    let b = b"abcd";
-    let c = b"123abcd";
-    let d = b"123";
-
-    assert_eq!(f(&a[..]), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(f(&b[..]), Ok((&b"abcd"[..], &b""[..])));
-    assert_eq!(f(&c[..]), Ok((&b"abcd"[..], &b"123"[..])));
-    assert_eq!(f(&d[..]), Err(Err::Incomplete(Needed::new(1))));
-  }
-
-  #[test]
-  fn take_till1() {
-    named!(f, take_till1!(is_alphabetic));
-    let a = b"";
-    let b = b"abcd";
-    let c = b"123abcd";
-    let d = b"123";
-
-    assert_eq!(f(&a[..]), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(
-      f(&b[..]),
-      Err(Err::Error(error_position!(&b[..], ErrorKind::TakeTill1)))
-    );
-    assert_eq!(f(&c[..]), Ok((&b"abcd"[..], &b"123"[..])));
-    assert_eq!(f(&d[..]), Err(Err::Incomplete(Needed::new(1))));
-  }
-
-  #[test]
-  fn take_while_utf8() {
-    named!(f<&str,&str>, take_while!(|c:char| { c != '點' }));
-
-    assert_eq!(f(""), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(f("abcd"), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(f("abcd點"), Ok(("點", "abcd")));
-    assert_eq!(f("abcd點a"), Ok(("點a", "abcd")));
-
-    named!(g<&str,&str>, take_while!(|c:char| { c == '點' }));
-
-    assert_eq!(g(""), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(g("點abcd"), Ok(("abcd", "點")));
-    assert_eq!(g("點點點a"), Ok(("a", "點點點")));
-  }
-
-  #[test]
-  fn take_till_utf8() {
-    named!(f<&str,&str>, take_till!(|c:char| { c == '點' }));
-
-    assert_eq!(f(""), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(f("abcd"), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(f("abcd點"), Ok(("點", "abcd")));
-    assert_eq!(f("abcd點a"), Ok(("點a", "abcd")));
-
-    named!(g<&str,&str>, take_till!(|c:char| { c != '點' }));
-
-    assert_eq!(g(""), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(g("點abcd"), Ok(("abcd", "點")));
-    assert_eq!(g("點點點a"), Ok(("a", "點點點")));
-  }
-
-  #[test]
-  fn take_utf8() {
-    named!(f<&str,&str>, take!(3));
-
-    assert_eq!(f(""), Err(Err::Incomplete(Needed::Unknown)));
-    assert_eq!(f("ab"), Err(Err::Incomplete(Needed::Unknown)));
-    assert_eq!(f("點"), Err(Err::Incomplete(Needed::Unknown)));
-    assert_eq!(f("ab點cd"), Ok(("cd", "ab點")));
-    assert_eq!(f("a點bcd"), Ok(("cd", "a點b")));
-    assert_eq!(f("a點b"), Ok(("", "a點b")));
-
-    named!(g<&str,&str>, take_while!(|c:char| { c == '點' }));
-
-    assert_eq!(g(""), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(g("點abcd"), Ok(("abcd", "點")));
-    assert_eq!(g("點點點a"), Ok(("a", "點點點")));
-  }
-
-  #[test]
-  fn take_while_m_n_utf8() {
-    named!(parser<&str, &str>, take_while_m_n!(1, 1, |c| c == 'A' || c == '😃'));
-    assert_eq!(parser("A!"), Ok(("!", "A")));
-    assert_eq!(parser("😃!"), Ok(("!", "😃")));
-  }
-
-  #[test]
-  fn take_while_m_n_utf8_full_match() {
-    named!(parser<&str, &str>, take_while_m_n!(1, 1, |c: char| c.is_alphabetic()));
-    assert_eq!(parser("øn"), Ok(("n", "ø")));
-  }
-
-  #[cfg(nightly)]
-  use test::Bencher;
-
-  #[cfg(nightly)]
-  #[bench]
-  fn take_while_bench(b: &mut Bencher) {
-    named!(f, take_while!(is_alphabetic));
-    b.iter(|| f(&b"abcdefghijklABCDEejfrfrjgro12aa"[..]));
-  }
-
-  #[test]
-  #[cfg(feature = "std")]
-  fn recognize_take_while() {
-    use crate::character::is_alphanumeric;
-    named!(x, take_while!(is_alphanumeric));
-    named!(y, recognize!(x));
-    assert_eq!(x(&b"ab."[..]), Ok((&b"."[..], &b"ab"[..])));
-    println!("X: {:?}", x(&b"ab"[..]));
-    assert_eq!(y(&b"ab."[..]), Ok((&b"."[..], &b"ab"[..])));
-  }
-
-  #[test]
-  fn length_bytes() {
-    use crate::{
-        number::streaming::le_u8,
-        bytes::streaming::tag,
-        multi::length_data
-    };
-
-    fn x(i: &[u8]) -> IResult<&[u8], &[u8]> {
-        length_data(le_u8)(i)
-    }
-    assert_eq!(x(b"\x02..>>"), Ok((&b">>"[..], &b".."[..])));
-    assert_eq!(x(b"\x02.."), Ok((&[][..], &b".."[..])));
-    assert_eq!(x(b"\x02."), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(x(b"\x02"), Err(Err::Incomplete(Needed::new(2))));
-
-    fn y(i: &[u8]) -> IResult<&[u8], &[u8]> {
-        let (i, _) = tag("magic")(i)?;
-        length_data(le_u8)(i)
-    }
-    assert_eq!(y(b"magic\x02..>>"), Ok((&b">>"[..], &b".."[..])));
-    assert_eq!(y(b"magic\x02.."), Ok((&[][..], &b".."[..])));
-    assert_eq!(y(b"magic\x02."), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(y(b"magic\x02"), Err(Err::Incomplete(Needed::new(2))));
-  }
-
-  #[cfg(feature = "alloc")]
-  #[test]
-  fn case_insensitive() {
-    named!(test, tag_no_case!("ABcd"));
-    assert_eq!(test(&b"aBCdefgh"[..]), Ok((&b"efgh"[..], &b"aBCd"[..])));
-    assert_eq!(test(&b"abcdefgh"[..]), Ok((&b"efgh"[..], &b"abcd"[..])));
-    assert_eq!(test(&b"ABCDefgh"[..]), Ok((&b"efgh"[..], &b"ABCD"[..])));
-    assert_eq!(test(&b"ab"[..]), Err(Err::Incomplete(Needed::new(2))));
-    assert_eq!(
-      test(&b"Hello"[..]),
-      Err(Err::Error(error_position!(&b"Hello"[..], ErrorKind::Tag)))
-    );
-    assert_eq!(
-      test(&b"Hel"[..]),
-      Err(Err::Error(error_position!(&b"Hel"[..], ErrorKind::Tag)))
-    );
-
-    named!(test2<&str, &str>, tag_no_case!("ABcd"));
-    assert_eq!(test2("aBCdefgh"), Ok(("efgh", "aBCd")));
-    assert_eq!(test2("abcdefgh"), Ok(("efgh", "abcd")));
-    assert_eq!(test2("ABCDefgh"), Ok(("efgh", "ABCD")));
-    assert_eq!(test2("ab"), Err(Err::Incomplete(Needed::new(2))));
-    assert_eq!(
-      test2("Hello"),
-      Err(Err::Error(error_position!(&"Hello"[..], ErrorKind::Tag)))
-    );
-    assert_eq!(
-      test2("Hel"),
-      Err(Err::Error(error_position!(&"Hel"[..], ErrorKind::Tag)))
-    );
-  }
-
-  #[test]
-  fn tag_fixed_size_array() {
-    named!(test, tag!([0x42]));
-    named!(test2, tag!(&[0x42]));
-    let input = [0x42, 0x00];
-    assert_eq!(test(&input), Ok((&b"\x00"[..], &b"\x42"[..])));
-    assert_eq!(test2(&input), Ok((&b"\x00"[..], &b"\x42"[..])));
-  }
-}
diff --git a/src/bytes/mod.rs b/src/bytes/mod.rs
index 64fb00d..7bc2d15 100644
--- a/src/bytes/mod.rs
+++ b/src/bytes/mod.rs
@@ -1,6 +1,6 @@
 //! Parsers recognizing bytes streams
 
-#[macro_use]
-mod macros;
 pub mod complete;
 pub mod streaming;
+#[cfg(test)]
+mod tests;
diff --git a/src/combinator/macros.rs b/src/combinator/macros.rs
deleted file mode 100644
index 62396a7..0000000
--- a/src/combinator/macros.rs
+++ /dev/null
@@ -1,1093 +0,0 @@
-//! Macro combinators
-//!
-//! Macros are used to make combination easier,
-//! since they often do not depend on the type
-//! of the data they manipulate or return.
-//!
-//! There is a trick to make them easier to assemble,
-//! combinators are defined like this:
-//!
-//! ```ignore
-//! macro_rules! tag (
-//!   ($i:expr, $inp: expr) => (
-//!     {
-//!       ...
-//!     }
-//!   );
-//! );
-//! ```
-//!
-//! But when used in other combinators, are used
-//! like this:
-//!
-//! ```ignore
-//! named!(my_function, tag!("abcd"));
-//! ```
-//!
-//! Internally, other combinators will rewrite
-//! that call to pass the input as first argument:
-//!
-//! ```ignore
-//! macro_rules! named (
-//!   ($name:ident, $submac:ident!( $($args:tt)* )) => (
-//!     fn $name<'a>( i: &'a [u8] ) -> IResult<'a,&[u8], &[u8]> {
-//!       $submac!(i, $($args)*)
-//!     }
-//!   );
-//! );
-//! ```
-//!
-//! If you want to call a combinator directly, you can
-//! do it like this:
-//!
-//! ```ignore
-//! let res = { tag!(input, "abcd"); }
-//! ```
-//!
-//! Combinators must have a specific variant for
-//! non-macro arguments. Example: Passing a function
-//! to `take_while!` instead of another combinator.
-//!
-//! ```ignore
-//! macro_rules! take_while(
-//!   ($input:expr, $submac:ident!( $($args:tt)* )) => (
-//!     {
-//!       ...
-//!     }
-//!   );
-//!
-//!   // wrap the function in a macro to pass it to the main implementation
-//!   ($input:expr, $f:expr) => (
-//!     take_while!($input, call!($f));
-//!   );
-//! );
-//! ```
-#[allow(unused_variables)]
-
-/// Makes a function from a parser combination
-///
-/// The type can be set up if the compiler needs
-/// more information.
-///
-/// Function-like declaration:
-/// ```
-/// # use nom::{named, tag};
-/// named!(my_function( &[u8] ) -> &[u8], tag!("abcd"));
-/// ```
-/// Alternative declaration. First type parameter is input, second is output:
-/// ```
-/// # use nom::{named, tag};
-/// named!(my_function<&[u8], &[u8]>, tag!("abcd"));
-/// ```
-/// This one will have `&[u8]` as input type, `&[u8]` as output type:
-/// ```
-/// # use nom::{named, tag};
-/// named!(my_function, tag!("abcd"));
-/// ```
-/// Will use `&[u8]` as output type:
-/// ```
-/// # use nom::{named, tag};
-/// named!(my_function<&[u8]>, tag!("abcd"));
-/// ```
-/// Prefix them with 'pub' to make the functions public:
-/// ```
-/// # use nom::{named, tag};
-/// named!(pub my_function, tag!("abcd"));
-/// ```
-/// Prefix them with 'pub(crate)' to make the functions public within the crate:
-/// ```
-/// # use nom::{named, tag};
-/// named!(pub(crate) my_function, tag!("abcd"));
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! named (
-    (#$($args:tt)*) => (
-        named_attr!(#$($args)*);
-    );
-    ($vis:vis $name:ident( $i:ty ) -> $o:ty, $submac:ident!( $($args:tt)* )) => (
-        $vis fn $name( i: $i ) -> $crate::IResult<$i, $o, $crate::error::Error<$i>> {
-            $submac!(i, $($args)*)
-        }
-    );
-    ($vis:vis $name:ident<$i:ty,$o:ty,$e:ty>, $submac:ident!( $($args:tt)* )) => (
-        $vis fn $name( i: $i ) -> $crate::IResult<$i, $o, $e> {
-            $submac!(i, $($args)*)
-        }
-    );
-    ($vis:vis $name:ident<$i:ty,$o:ty>, $submac:ident!( $($args:tt)* )) => (
-        $vis fn $name( i: $i ) -> $crate::IResult<$i, $o, $crate::error::Error<$i>> {
-            $submac!(i, $($args)*)
-        }
-    );
-    ($vis:vis $name:ident<$o:ty>, $submac:ident!( $($args:tt)* )) => (
-        $vis fn $name( i: &[u8] ) -> $crate::IResult<&[u8], $o, $crate::error::Error<&[u8]>> {
-            $submac!(i, $($args)*)
-        }
-    );
-    ($vis:vis $name:ident, $submac:ident!( $($args:tt)* )) => (
-        $vis fn $name( i: &[u8] ) -> $crate::IResult<&[u8], &[u8], $crate::error::Error<&[u8]>> {
-            $submac!(i, $($args)*)
-        }
-    );
-);
-
-/// Makes a function from a parser combination, with attributes.
-///
-/// The usage of this macro is almost identical to `named!`, except that
-/// you also pass attributes to be attached to the generated function.
-/// This is ideal for adding documentation to your parser.
-///
-/// Create my_function as if you wrote it with the doc comment /// My Func:
-/// ```
-/// # use nom::{named_attr, tag};
-/// named_attr!(#[doc = "My Func"], my_function( &[u8] ) -> &[u8], tag!("abcd"));
-/// ```
-/// Also works for pub functions, and multiple lines:
-/// ```
-/// # use nom::{named_attr, tag};
-/// named_attr!(#[doc = "My Func\nRecognise abcd"], pub my_function, tag!("abcd"));
-/// ```
-/// Multiple attributes can be passed if required:
-/// ```
-/// # use nom::{named_attr, tag};
-/// named_attr!(#[doc = "My Func"] #[inline(always)], pub my_function, tag!("abcd"));
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! named_attr (
-    ($(#[$attr:meta])*, $vis:vis $name:ident( $i:ty ) -> $o:ty, $submac:ident!( $($args:tt)* )) => (
-        $(#[$attr])*
-        $vis fn $name( i: $i ) -> $crate::IResult<$i,$o, $crate::error::Error<$i>> {
-            $submac!(i, $($args)*)
-        }
-    );
-    ($(#[$attr:meta])*, $vis:vis $name:ident<$i:ty,$o:ty,$e:ty>, $submac:ident!( $($args:tt)* )) => (
-        $(#[$attr])*
-        $vis fn $name( i: $i ) -> $crate::IResult<$i, $o, $e> {
-            $submac!(i, $($args)*)
-        }
-    );
-    ($(#[$attr:meta])*, $vis:vis $name:ident<$i:ty,$o:ty>, $submac:ident!( $($args:tt)* )) => (
-        $(#[$attr])*
-        $vis fn $name( i: $i ) -> $crate::IResult<$i, $o, $crate::error::Error<$i>> {
-            $submac!(i, $($args)*)
-        }
-    );
-    ($(#[$attr:meta])*, $vis:vis $name:ident<$o:ty>, $submac:ident!( $($args:tt)* )) => (
-        $(#[$attr])*
-        $vis fn $name( i: &[u8] ) -> $crate::IResult<&[u8], $o, $crate::error::Error<&[u8]>> {
-            $submac!(i, $($args)*)
-        }
-    );
-    ($(#[$attr:meta])*, $vis:vis $name:ident, $submac:ident!( $($args:tt)* )) => (
-        $(#[$attr])*
-        $vis fn $name<'a>( i: &'a [u8] ) -> $crate::IResult<&[u8], &[u8], $crate::error::Error<&[u8]>> {
-            $submac!(i, $($args)*)
-        }
-    );
-);
-
-/// Used to wrap common expressions and function as macros.
-///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use nom::IResult;
-/// # fn main() {
-///   fn take_wrapper(input: &[u8], i: u8) -> IResult<&[u8], &[u8]> { take!(input, i * 10) }
-///
-///   // will make a parser taking 20 bytes
-///   named!(parser, call!(take_wrapper, 2));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! call (
-  ($i:expr, $fun:expr) => ( $fun( $i ) );
-  ($i:expr, $fun:expr, $($args:expr),* ) => ( $fun( $i, $($args),* ) );
-);
-
-//FIXME: error rewrite
-/// Prevents backtracking if the child parser fails.
-///
-/// This parser will do an early return instead of sending
-/// its result to the parent parser.
-///
-/// If another `return_error!` combinator is present in the parent
-/// chain, the error will be wrapped and another early
-/// return will be made.
-///
-/// This makes it easy to build report on which parser failed,
-/// where it failed in the input, and the chain of parsers
-/// that led it there.
-///
-/// Additionally, the error chain contains number identifiers
-/// that can be matched to provide useful error messages.
-///
-#[macro_export(local_inner_macros)]
-macro_rules! return_error (
-  ($i:expr, $code:expr, $submac:ident!( $($args:tt)* )) => (
-    {
-      use $crate::lib::std::result::Result::*;
-      use $crate::Err;
-
-      let i_ = $i.clone();
-      let cl = || {
-        $submac!(i_, $($args)*)
-      };
-
-      match cl() {
-        Err(Err::Incomplete(x)) => Err(Err::Incomplete(x)),
-        Ok((i, o))              => Ok((i, o)),
-        Err(Err::Error(e)) | Err(Err::Failure(e)) => {
-          return Err(Err::Failure($crate::error::append_error($i, $code, e)))
-        }
-      }
-    }
-  );
-  ($i:expr, $code:expr, $f:expr) => (
-    return_error!($i, $code, call!($f));
-  );
-  ($i:expr, $submac:ident!( $($args:tt)* )) => (
-    {
-      use $crate::lib::std::result::Result::*;
-      use $crate::Err;
-
-      let i_ = $i.clone();
-      let cl = || {
-        $submac!(i_, $($args)*)
-      };
-
-      match cl() {
-        Err(Err::Incomplete(x)) => Err(Err::Incomplete(x)),
-        Ok((i, o))              => Ok((i, o)),
-        Err(Err::Error(e)) | Err(Err::Failure(e)) => {
-          return Err(Err::Failure(e))
-        }
-      }
-    }
-  );
-  ($i:expr, $f:expr) => (
-    return_error!($i, call!($f));
-  );
-);
-
-//FIXME: error rewrite
-/// Add an error if the child parser fails.
-///
-/// While `return_error!` does an early return and avoids backtracking,
-/// `add_return_error!` backtracks normally. It just provides more context
-/// for an error.
-///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use std::collections;
-/// # use nom::Err;
-/// # use nom::error::ErrorKind;
-/// # fn main() {
-///     named!(err_test, add_return_error!(ErrorKind::Tag, tag!("abcd")));
-///
-///     let a = &b"efghblah"[..];
-///     let res_a = err_test(a);
-///     assert_eq!(res_a, Err(Err::Error(error_node_position!(a, ErrorKind::Tag, error_position!(a, ErrorKind::Tag)))));
-/// # }
-/// ```
-///
-#[macro_export(local_inner_macros)]
-macro_rules! add_return_error (
-  ($i:expr, $code:expr, $submac:ident!( $($args:tt)* )) => (
-    {
-      use $crate::lib::std::result::Result::*;
-      use $crate::{Err,error::ErrorKind};
-
-      match $submac!($i, $($args)*) {
-        Ok((i, o)) => Ok((i, o)),
-        Err(Err::Error(e)) => {
-          Err(Err::Error(error_node_position!($i, $code, e)))
-        },
-        Err(Err::Failure(e)) => {
-          Err(Err::Failure(error_node_position!($i, $code, e)))
-        },
-        Err(e) => Err(e),
-      }
-    }
-  );
-  ($i:expr, $code:expr, $f:expr) => (
-    add_return_error!($i, $code, call!($f));
-  );
-);
-
-/// Replaces a `Incomplete` returned by the child parser
-/// with an `Error`.
-///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use std::collections;
-/// # use nom::Err;
-/// # use nom::error::ErrorKind;
-/// # fn main() {
-///     named!(take_5, complete!(take!(5)));
-///
-///     let a = &b"abcd"[..];
-///     let res_a = take_5(a);
-///     assert_eq!(res_a, Err(Err::Error(error_position!(a, ErrorKind::Complete))));
-/// # }
-/// ```
-///
-#[macro_export(local_inner_macros)]
-macro_rules! complete (
-  ($i:expr, $submac:ident!( $($args:tt)* )) => (
-    $crate::combinator::completec($i, move |i| { $submac!(i, $($args)*) })
-  );
-  ($i:expr, $f:expr) => (
-    complete!($i, call!($f));
-  );
-);
-
-/// A bit like `std::try!`, this macro will return the remaining input and
-/// parsed value if the child parser returned `Ok`, and will do an early
-/// return for the `Err` side.
-///
-/// This can provide more flexibility than `do_parse!` if needed.
-///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use nom::Err;
-/// # use nom::error::ErrorKind;
-/// # use nom::IResult;
-///
-///  fn take_add(input:&[u8], size: u8) -> IResult<&[u8], &[u8]> {
-///    let (i1, length)     = try_parse!(input, map_opt!(nom::number::streaming::be_u8, |sz| size.checked_add(sz)));
-///    let (i2, data)   = try_parse!(i1, take!(length));
-///    return Ok((i2, data));
-///  }
-/// # fn main() {
-/// let arr1 = [1, 2, 3, 4, 5];
-/// let r1 = take_add(&arr1[..], 1);
-/// assert_eq!(r1, Ok((&[4,5][..], &[2,3][..])));
-///
-/// let arr2 = [0xFE, 2, 3, 4, 5];
-/// // size is overflowing
-/// let r1 = take_add(&arr2[..], 42);
-/// assert_eq!(r1, Err(Err::Error(error_position!(&[254, 2,3,4,5][..], ErrorKind::MapOpt))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! try_parse (
-  ($i:expr, $submac:ident!( $($args:tt)* )) => ({
-    use $crate::lib::std::result::Result::*;
-
-    match $submac!($i, $($args)*) {
-      Ok((i,o)) => (i,o),
-      Err(e)    => return Err(e),
-    }
-    });
-  ($i:expr, $f:expr) => (
-    try_parse!($i, call!($f))
-  );
-);
-
-/// `map!(I -> IResult<I, O>, O -> P) => I -> IResult<I, P>`
-///
-/// Maps a function on the result of a parser.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err,error::ErrorKind, IResult};
-/// use nom::character::complete::digit1;
-/// # fn main() {
-///
-/// named!(parse<&str, usize>, map!(digit1, |s| s.len()));
-///
-/// // the parser will count how many characters were returned by digit1
-/// assert_eq!(parse("123456"), Ok(("", 6)));
-///
-/// // this will fail if digit1 fails
-/// assert_eq!(parse("abc"), Err(Err::Error(error_position!("abc", ErrorKind::Digit))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! map(
-  // Internal parser, do not use directly
-  (__impl $i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
-    $crate::combinator::mapc($i, move |i| {$submac!(i, $($args)*)}, $g)
-  );
-  ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
-    map!(__impl $i, $submac!($($args)*), $g);
-  );
-  ($i:expr, $f:expr, $g:expr) => (
-    map!(__impl $i, call!($f), $g);
-  );
-);
-
-/// `map_res!(I -> IResult<I, O>, O -> Result<P>) => I -> IResult<I, P>`
-/// maps a function returning a `Result` on the output of a parser.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err,error::ErrorKind, IResult};
-/// use nom::character::complete::digit1;
-/// # fn main() {
-///
-/// named!(parse<&str, u8>, map_res!(digit1, |s: &str| s.parse::<u8>()));
-///
-/// // the parser will convert the result of digit1 to a number
-/// assert_eq!(parse("123"), Ok(("", 123)));
-///
-/// // this will fail if digit1 fails
-/// assert_eq!(parse("abc"), Err(Err::Error(error_position!("abc", ErrorKind::Digit))));
-///
-/// // this will fail if the mapped function fails (a `u8` is too small to hold `123456`)
-/// assert_eq!(parse("123456"), Err(Err::Error(error_position!("123456", ErrorKind::MapRes))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! map_res (
-  // Internal parser, do not use directly
-  (__impl $i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => (
-    $crate::combinator::map_resc($i, move |i| {$submac!(i, $($args)*)}, move |i| {$submac2!(i, $($args2)*)})
-  );
-  ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
-    map_res!(__impl $i, $submac!($($args)*), call!($g));
-  );
-  ($i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => (
-    map_res!(__impl $i, $submac!($($args)*), $submac2!($($args2)*));
-  );
-  ($i:expr, $f:expr, $g:expr) => (
-    map_res!(__impl $i, call!($f), call!($g));
-  );
-  ($i:expr, $f:expr, $submac:ident!( $($args:tt)* )) => (
-    map_res!(__impl $i, call!($f), $submac!($($args)*));
-  );
-);
-
-/// `map_opt!(I -> IResult<I, O>, O -> Option<P>) => I -> IResult<I, P>`
-/// maps a function returning an `Option` on the output of a parser.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err,error::{Error, ErrorKind}, IResult};
-/// use nom::character::complete::digit1;
-/// # fn main() {
-///
-/// named!(parser<&str, u8>, map_opt!(digit1, |s: &str| s.parse::<u8>().ok()));
-///
-/// // the parser will convert the result of digit1 to a number
-/// assert_eq!(parser("123"), Ok(("", 123)));
-///
-/// // this will fail if digit1 fails
-/// assert_eq!(parser("abc"), Err(Err::Error(Error::new("abc", ErrorKind::Digit))));
-///
-/// // this will fail if the mapped function fails (a `u8` is too small to hold `123456`)
-/// assert_eq!(parser("123456"), Err(Err::Error(Error::new("123456", ErrorKind::MapOpt))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! map_opt (
-  // Internal parser, do not use directly
-  (__impl $i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => (
-    $crate::combinator::map_optc($i, move |i| {$submac!(i, $($args)*)}, move |i| {$submac2!(i, $($args2)*)})
-  );
-  ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
-    map_opt!(__impl $i, $submac!($($args)*), call!($g));
-  );
-  ($i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => (
-    map_opt!(__impl $i, $submac!($($args)*), $submac2!($($args2)*));
-  );
-  ($i:expr, $f:expr, $g:expr) => (
-    map_opt!(__impl $i, call!($f), call!($g));
-  );
-  ($i:expr, $f:expr, $submac:ident!( $($args:tt)* )) => (
-    map_opt!(__impl $i, call!($f), $submac!($($args)*));
-  );
-);
-
-/// `parse_to!(O) => I -> IResult<I, O>`
-/// Uses the `parse` method from `std::str::FromStr` to convert the current
-/// input to the specified type.
-///
-/// This will completely consume the input.
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err,error::{Error, ErrorKind}, IResult};
-/// use nom::character::complete::digit1;
-/// # fn main() {
-///
-/// named!(parser<&str, u8>, parse_to!(u8));
-///
-/// assert_eq!(parser("123"), Ok(("", 123)));
-///
-/// assert_eq!(parser("abc"), Err(Err::Error(Error::new("abc", ErrorKind::ParseTo))));
-///
-/// // this will fail if the mapped function fails (a `u8` is too small to hold `123456`)
-/// assert_eq!(parser("123456"), Err(Err::Error(Error::new("123456", ErrorKind::ParseTo))));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! parse_to (
-  ($i:expr, $t:ty ) => (
-    {
-      use $crate::lib::std::result::Result::*;
-      use $crate::lib::std::option::Option;
-      use $crate::lib::std::option::Option::*;
-      use $crate::{Err,error::ErrorKind};
-
-      use $crate::ParseTo;
-      use $crate::Slice;
-      use $crate::InputLength;
-
-      let res: Option<$t> = ($i).parse_to();
-      match res {
-        Some(output) => Ok(($i.slice($i.input_len()..), output)),
-        None         => Err(Err::Error($crate::error::make_error($i, ErrorKind::ParseTo)))
-      }
-    }
-  );
-);
-
-/// `verify!(I -> IResult<I, O>, O -> bool) => I -> IResult<I, O>`
-/// returns the result of the child parser if it satisfies a verification function.
-///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  named!(check<u32>, verify!(nom::number::streaming::be_u32, |val: &u32| *val < 3));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! verify (
-  ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
-    $crate::combinator::verifyc($i, |i| $submac!(i, $($args)*), $g)
-  );
-  ($i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => (
-    $crate::combinator::verifyc($i, |i| $submac!(i, $($args)*), |&o| $submac2!(o, $($args2)*))
-  );
-  ($i:expr, $f:expr, $g:expr) => (
-    $crate::combinator::verify($f, $g)($i)
-  );
-  ($i:expr, $f:expr, $submac:ident!( $($args:tt)* )) => (
-    $crate::combinator::verify($f, |&o| $submac!(o, $($args)*))($i)
-  );
-);
-
-/// `value!(T, R -> IResult<R, S> ) => R -> IResult<R, T>`
-///
-/// or `value!(T) => R -> IResult<R, T>`
-///
-/// If the child parser was successful, return the value.
-/// If no child parser is provided, always return the value.
-///
-#[macro_export(local_inner_macros)]
-macro_rules! value (
-  ($i:expr, $res:expr, $submac:ident!( $($args:tt)* )) => (
-    $crate::combinator::valuec($i, $res, |i| $submac!(i, $($args)*))
-  );
-  ($i:expr, $res:expr, $f:expr) => (
-    $crate::combinator::valuec($i, $res, $f)
-  );
-  ($i:expr, $res:expr) => (
-    Ok(($i, $res))
-  );
-);
-
-/// `opt!(I -> IResult<I,O>) => I -> IResult<I, Option<O>>`
-/// make the underlying parser optional.
-///
-/// Returns an `Option` of the returned type. This parser returns `Some(result)` if the child parser
-/// succeeds, `None` if it fails, and `Incomplete` if it did not have enough data to decide.
-///
-/// *Warning*: if you are using `opt` for some kind of optional ending token (like an end of line),
-/// you should combine it with `complete` to make sure it works.
-///
-/// As an example, `opt!(tag!("\r\n"))` will return `Incomplete` if it receives an empty input,
-/// because `tag` does not have enough input to decide.
-/// On the contrary, `opt!(complete!(tag!("\r\n")))` would return `None` as produced value,
-/// since `complete!` transforms an `Incomplete` in an `Error`.
-///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  named!( o<&[u8], Option<&[u8]> >, opt!( tag!( "abcd" ) ) );
-///
-///  let a = b"abcdef";
-///  let b = b"bcdefg";
-///  assert_eq!(o(&a[..]), Ok((&b"ef"[..], Some(&b"abcd"[..]))));
-///  assert_eq!(o(&b[..]), Ok((&b"bcdefg"[..], None)));
-///  # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! opt(
-  ($i:expr, $submac:ident!( $($args:tt)* )) => (
-    {
-      $crate::combinator::optc($i, |i| $submac!(i, $($args)*))
-    }
-  );
-  ($i:expr, $f:expr) => (
-    $crate::combinator::opt($f)($i)
-  );
-);
-
-/// `opt_res!(I -> IResult<I,O>) => I -> IResult<I, Result<nom::Err,O>>`
-/// make the underlying parser optional.
-///
-/// Returns a `Result`, with `Err` containing the parsing error.
-///
-/// ```ignore
-/// # #[macro_use] extern crate nom;
-/// # use nom::ErrorKind;
-/// # fn main() {
-///  named!( o<&[u8], Result<&[u8], nom::Err<&[u8]> > >, opt_res!( tag!( "abcd" ) ) );
-///
-///  let a = b"abcdef";
-///  let b = b"bcdefg";
-///  assert_eq!(o(&a[..]), Ok((&b"ef"[..], Ok(&b"abcd"[..])));
-///  assert_eq!(o(&b[..]), Ok((&b"bcdefg"[..], Err(error_position!(&b[..], ErrorKind::Tag))));
-///  # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! opt_res (
-  ($i:expr, $submac:ident!( $($args:tt)* )) => (
-    {
-      use $crate::lib::std::result::Result::*;
-      use $crate::Err;
-
-      let i_ = $i.clone();
-      match $submac!(i_, $($args)*) {
-        Ok((i,o))          => Ok((i,  Ok(o))),
-        Err(Err::Error(e)) => Ok(($i, Err(Err::Error(e)))),
-        // in case of failure, we return a real error
-        Err(e)             => Err(e)
-      }
-    }
-  );
-  ($i:expr, $f:expr) => (
-    opt_res!($i, call!($f));
-  );
-);
-
-/// `cond!(bool, I -> IResult<I,O>) => I -> IResult<I, Option<O>>`
-/// Conditional combinator
-///
-/// Wraps another parser and calls it if the
-/// condition is met. This combinator returns
-/// an Option of the return type of the child
-/// parser.
-///
-/// This is especially useful if a parser depends
-/// on the value returned by a preceding parser in
-/// a `do_parse!`.
-///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use nom::IResult;
-/// # fn main() {
-///  fn f_true(i: &[u8]) -> IResult<&[u8], Option<&[u8]>> {
-///    cond!(i, true, tag!("abcd"))
-///  }
-///
-///  fn f_false(i: &[u8]) -> IResult<&[u8], Option<&[u8]>> {
-///    cond!(i, false, tag!("abcd"))
-///  }
-///
-///  let a = b"abcdef";
-///  assert_eq!(f_true(&a[..]), Ok((&b"ef"[..], Some(&b"abcd"[..]))));
-///
-///  assert_eq!(f_false(&a[..]), Ok((&b"abcdef"[..], None)));
-///  # }
-/// ```
-///
-#[macro_export(local_inner_macros)]
-macro_rules! cond(
-  ($i:expr, $cond:expr, $submac:ident!( $($args:tt)* )) => (
-    $crate::combinator::condc($i, $cond, |i|  $submac!(i, $($args)*) )
-  );
-  ($i:expr, $cond:expr, $f:expr) => (
-    $crate::combinator::cond($cond, $f)($i)
-  );
-);
-
-/// `peek!(I -> IResult<I,O>) => I -> IResult<I, O>`
-/// returns a result without consuming the input.
-///
-/// The embedded parser may return `Err(Err::Incomplete)`.
-///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///  named!(ptag, peek!( tag!( "abcd" ) ) );
-///
-///  let r = ptag(&b"abcdefgh"[..]);
-///  assert_eq!(r, Ok((&b"abcdefgh"[..], &b"abcd"[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! peek(
-  ($i:expr, $submac:ident!( $($args:tt)* )) => (
-    $crate::combinator::peekc($i, |i| $submac!(i, $($args)*))
-  );
-  ($i:expr, $f:expr) => (
-    $crate::combinator::peek($f)($i)
-  );
-);
-
-/// `not!(I -> IResult<I,O>) => I -> IResult<I, ()>`
-/// returns a result only if the embedded parser returns `Error` or `Err(Err::Incomplete)`.
-/// Does not consume the input.
-#[macro_export(local_inner_macros)]
-macro_rules! not(
-  ($i:expr, $submac:ident!( $($args:tt)* )) => (
-    $crate::combinator::notc($i, |i| $submac!(i, $($args)*))
-  );
-  ($i:expr, $f:expr) => (
-    $crate::combinator::not($f)($i)
-  );
-);
-
-/// `tap!(name: I -> IResult<I,O> => { block }) => I -> IResult<I, O>`
-/// allows access to the parser's result without affecting it.
-///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use std::str;
-/// # fn main() {
-///  named!(ptag, tap!(res: tag!( "abcd" ) => { println!("recognized {}", str::from_utf8(res).unwrap()) } ) );
-///
-///  let r = ptag(&b"abcdefgh"[..]);
-///  assert_eq!(r, Ok((&b"efgh"[..], &b"abcd"[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! tap (
-  ($i:expr, $name:ident : $submac:ident!( $($args:tt)* ) => $e:expr) => (
-    {
-      use $crate::lib::std::result::Result::*;
-      use $crate::{Err,Needed,IResult};
-
-      match $submac!($i, $($args)*) {
-        Ok((i,o)) => {
-          let $name = o;
-          $e;
-          Ok((i, $name))
-        },
-        Err(e)    => Err(Err::convert(e)),
-      }
-    }
-  );
-  ($i:expr, $name: ident: $f:expr => $e:expr) => (
-    tap!($i, $name: call!($f) => $e);
-  );
-);
-
-/// `eof!()` returns its input if it is at the end of input data.
-///
-/// When we're at the end of the data, this combinator
-/// will succeed.
-///
-///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # use std::str;
-/// # use nom::{Err, error::{Error ,ErrorKind}};
-/// # fn main() {
-///  named!(parser, eof!());
-///
-///  assert_eq!(parser(&b"abc"[..]), Err(Err::Error(Error::new(&b"abc"[..], ErrorKind::Eof))));
-///  assert_eq!(parser(&b""[..]), Ok((&b""[..], &b""[..])));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! eof (
-  ($i:expr,) => (
-    {
-      use $crate::lib::std::result::Result::*;
-      use $crate::{Err,error::ErrorKind};
-
-      use $crate::InputLength;
-      if ($i).input_len() == 0 {
-        let clone = $i.clone();
-        Ok(($i, clone))
-      } else {
-        Err(Err::Error(error_position!($i, ErrorKind::Eof)))
-      }
-    }
-  );
-);
-
-/// `exact!()` will fail if the child parser does not consume the whole data.
-///
-/// TODO: example
-#[macro_export(local_inner_macros)]
-macro_rules! exact (
-  ($i:expr, $submac:ident!( $($args:tt)* )) => ({
-      terminated!($i, $submac!( $($args)*), eof!())
-  });
-  ($i:expr, $f:expr) => (
-    exact!($i, call!($f));
-  );
-);
-
-/// `recognize!(I -> IResult<I, O> ) => I -> IResult<I, I>`
-/// if the child parser was successful, return the consumed input as produced value.
-#[macro_export(local_inner_macros)]
-macro_rules! recognize (
-  ($i:expr, $submac:ident!( $($args:tt)* )) => (
-    $crate::combinator::recognizec($i, |i| $submac!(i, $($args)*))
-  );
-  ($i:expr, $f:expr) => (
-    $crate::combinator::recognize($f)($i)
-  );
-);
-
-/// `into!(I -> IResult<I, O1, E1>) => I -> IResult<I, O2, E2>`
-/// automatically converts the child parser's result to another type
-///
-/// it will be able to convert the output value and the error value
-/// as long as the `Into` implementations are available
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::IResult;
-/// # fn main() {
-///  named!(parse_to_str<&str, &str>, take!(4));
-///  named!(parse_to_vec<&str, Vec<u8>>, into!(parse_to_str));
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! into (
-  ($i:expr, $submac:ident!( $($args:tt)* )) => (
-    $crate::combinator::intoc($i, |i| $submac!(i, $($args)*))
-  );
-  ($i:expr, $f:expr) => (
-    $crate::combinator::intoc($i, $f)
-  );
-);
-
-#[cfg(test)]
-mod tests {
-  use crate::error::ErrorKind;
-  use crate::error::ParseError;
-  use crate::internal::{Err, IResult, Needed};
-  #[cfg(feature = "alloc")]
-  use crate::lib::std::boxed::Box;
-
-  // reproduce the tag and take macros, because of module import order
-  macro_rules! tag (
-    ($i:expr, $tag: expr) => ({
-      use $crate::lib::std::result::Result::*;
-      use $crate::{Err,Needed,IResult,error::ErrorKind};
-      use $crate::{Compare,CompareResult,InputLength,Slice};
-
-      let res: IResult<_,_> = match ($i).compare($tag) {
-        CompareResult::Ok => {
-          let blen = $tag.input_len();
-          Ok(($i.slice(blen..), $i.slice(..blen)))
-        },
-        CompareResult::Incomplete => {
-          Err(Err::Incomplete(Needed::new($tag.input_len() - $i.input_len())))
-        },
-        CompareResult::Error => {
-          let e:ErrorKind = ErrorKind::Tag;
-          Err(Err::Error($crate::error::make_error($i, e)))
-        }
-      };
-      res
-      });
-  );
-
-  macro_rules! take(
-    ($i:expr, $count:expr) => (
-      {
-        let cnt = $count as usize;
-        let res:IResult<&[u8],&[u8]> = if $i.len() < cnt {
-          Err($crate::Err::Incomplete($crate::Needed::new(cnt - $i.len())))
-        } else {
-          Ok((&$i[cnt..],&$i[0..cnt]))
-        };
-        res
-      }
-    );
-  );
-
-  mod pub_named_mod {
-    named!(pub tst, tag!("abcd"));
-  }
-
-  #[test]
-  fn pub_named_test() {
-    let a = &b"abcd"[..];
-    let res = pub_named_mod::tst(a);
-    assert_eq!(res, Ok((&b""[..], a)));
-  }
-
-  mod pub_crate_named_mod {
-    named!(pub(crate) tst, tag!("abcd"));
-  }
-
-  #[test]
-  fn pub_crate_named_test() {
-    let a = &b"abcd"[..];
-    let res = pub_crate_named_mod::tst(a);
-    assert_eq!(res, Ok((&b""[..], a)));
-  }
-
-  #[test]
-  fn apply_test() {
-    fn sum2(a: u8, b: u8) -> u8 {
-      a + b
-    }
-    fn sum3(a: u8, b: u8, c: u8) -> u8 {
-      a + b + c
-    }
-    let a = call!(1, sum2, 2);
-    let b = call!(1, sum3, 2, 3);
-
-    assert_eq!(a, 3);
-    assert_eq!(b, 6);
-  }
-
-  #[test]
-  fn opt() {
-    named!(opt_abcd<&[u8],Option<&[u8]> >, opt!(tag!("abcd")));
-
-    let a = &b"abcdef"[..];
-    let b = &b"bcdefg"[..];
-    let c = &b"ab"[..];
-    assert_eq!(opt_abcd(a), Ok((&b"ef"[..], Some(&b"abcd"[..]))));
-    assert_eq!(opt_abcd(b), Ok((&b"bcdefg"[..], None)));
-    assert_eq!(opt_abcd(c), Err(Err::Incomplete(Needed::new(2))));
-  }
-
-  #[test]
-  fn opt_res() {
-    named!(opt_res_abcd<&[u8], Result<&[u8], Err<crate::error::Error<&[u8]>>> >, opt_res!(tag!("abcd")));
-
-    let a = &b"abcdef"[..];
-    let b = &b"bcdefg"[..];
-    let c = &b"ab"[..];
-    assert_eq!(opt_res_abcd(a), Ok((&b"ef"[..], Ok(&b"abcd"[..]))));
-    assert_eq!(
-      opt_res_abcd(b),
-      Ok((
-        &b"bcdefg"[..],
-        Err(Err::Error(error_position!(b, ErrorKind::Tag)))
-      ))
-    );
-    assert_eq!(opt_res_abcd(c), Err(Err::Incomplete(Needed::new(2))));
-  }
-
-  use crate::lib::std::convert::From;
-  #[derive(Debug, PartialEq)]
-  pub struct CustomError(&'static str);
-  impl<I> From<(I, ErrorKind)> for CustomError {
-    fn from(_: (I, ErrorKind)) -> Self {
-      CustomError("test")
-    }
-  }
-  impl<I> From<crate::error::Error<I>> for CustomError {
-    fn from(_: crate::error::Error<I>) -> Self {
-      CustomError("test")
-    }
-  }
-
-  impl<I> ParseError<I> for CustomError {
-    fn from_error_kind(_: I, _: ErrorKind) -> Self {
-      CustomError("from_error_kind")
-    }
-
-    fn append(_: I, _: ErrorKind, _: CustomError) -> Self {
-      CustomError("append")
-    }
-  }
-
-  #[test]
-  #[cfg(feature = "alloc")]
-  fn cond() {
-    fn f_true(i: &[u8]) -> IResult<&[u8], Option<&[u8]>, CustomError> {
-      fix_error!(i, CustomError, cond!(true, tag!("abcd")))
-    }
-
-    fn f_false(i: &[u8]) -> IResult<&[u8], Option<&[u8]>, CustomError> {
-      fix_error!(i, CustomError, cond!(false, tag!("abcd")))
-    }
-
-    assert_eq!(f_true(&b"abcdef"[..]), Ok((&b"ef"[..], Some(&b"abcd"[..]))));
-    assert_eq!(f_true(&b"ab"[..]), Err(Err::Incomplete(Needed::new(2))));
-    assert_eq!(f_true(&b"xxx"[..]), Err(Err::Error(CustomError("test"))));
-
-    assert_eq!(f_false(&b"abcdef"[..]), Ok((&b"abcdef"[..], None)));
-    assert_eq!(f_false(&b"ab"[..]), Ok((&b"ab"[..], None)));
-    assert_eq!(f_false(&b"xxx"[..]), Ok((&b"xxx"[..], None)));
-  }
-
-  #[test]
-  #[cfg(feature = "alloc")]
-  fn cond_wrapping() {
-    // Test that cond!() will wrap a given identifier in the call!() macro.
-    named!(tag_abcd, tag!("abcd"));
-    fn f_true(i: &[u8]) -> IResult<&[u8], Option<&[u8]>, CustomError> {
-      fix_error!(i, CustomError, cond!(true, tag_abcd))
-    }
-
-    fn f_false(i: &[u8]) -> IResult<&[u8], Option<&[u8]>, CustomError> {
-      fix_error!(i, CustomError, cond!(false, tag_abcd))
-    }
-
-    assert_eq!(f_true(&b"abcdef"[..]), Ok((&b"ef"[..], Some(&b"abcd"[..]))));
-    assert_eq!(f_true(&b"ab"[..]), Err(Err::Incomplete(Needed::new(2))));
-    assert_eq!(f_true(&b"xxx"[..]), Err(Err::Error(CustomError("test"))));
-
-    assert_eq!(f_false(&b"abcdef"[..]), Ok((&b"abcdef"[..], None)));
-    assert_eq!(f_false(&b"ab"[..]), Ok((&b"ab"[..], None)));
-    assert_eq!(f_false(&b"xxx"[..]), Ok((&b"xxx"[..], None)));
-  }
-
-  #[test]
-  fn peek() {
-    named!(peek_tag<&[u8],&[u8]>, peek!(tag!("abcd")));
-
-    assert_eq!(peek_tag(&b"abcdef"[..]), Ok((&b"abcdef"[..], &b"abcd"[..])));
-    assert_eq!(peek_tag(&b"ab"[..]), Err(Err::Incomplete(Needed::new(2))));
-    assert_eq!(
-      peek_tag(&b"xxx"[..]),
-      Err(Err::Error(error_position!(&b"xxx"[..], ErrorKind::Tag)))
-    );
-  }
-
-  #[test]
-  fn not() {
-    named!(not_aaa<()>, not!(tag!("aaa")));
-    assert_eq!(
-      not_aaa(&b"aaa"[..]),
-      Err(Err::Error(error_position!(&b"aaa"[..], ErrorKind::Not)))
-    );
-    assert_eq!(not_aaa(&b"aa"[..]), Err(Err::Incomplete(Needed::new(1))));
-    assert_eq!(not_aaa(&b"abcd"[..]), Ok((&b"abcd"[..], ())));
-  }
-
-  #[test]
-  fn verify() {
-    named!(test, verify!(take!(5), |slice: &[u8]| slice[0] == b'a'));
-    assert_eq!(test(&b"bcd"[..]), Err(Err::Incomplete(Needed::new(2))));
-    assert_eq!(
-      test(&b"bcdefg"[..]),
-      Err(Err::Error(error_position!(
-        &b"bcdefg"[..],
-        ErrorKind::Verify
-      )))
-    );
-    assert_eq!(test(&b"abcdefg"[..]), Ok((&b"fg"[..], &b"abcde"[..])));
-  }
-
-  #[test]
-  fn parse_to() {
-    let res: IResult<_, _, (&str, ErrorKind)> = parse_to!("ab", usize);
-
-    assert_eq!(
-      res,
-      Err(Err::Error(error_position!("ab", ErrorKind::ParseTo)))
-    );
-
-    let res: IResult<_, _, (&str, ErrorKind)> = parse_to!("42", usize);
-
-    assert_eq!(res, Ok(("", 42)));
-    //assert_eq!(ErrorKind::convert(ErrorKind::ParseTo), ErrorKind::ParseTo::<u64>);
-  }
-}
diff --git a/src/combinator/mod.rs b/src/combinator/mod.rs
index 4792d0b..13aaceb 100644
--- a/src/combinator/mod.rs
+++ b/src/combinator/mod.rs
@@ -16,8 +16,8 @@ use crate::lib::std::ops::{Range, RangeFrom, RangeTo};
 use crate::traits::{AsChar, InputIter, InputLength, InputTakeAtPosition, ParseTo};
 use crate::traits::{Compare, CompareResult, Offset, Slice};
 
-#[macro_use]
-mod macros;
+#[cfg(test)]
+mod tests;
 
 /// Return the remaining input.
 ///
@@ -928,209 +928,3 @@ enum State<E> {
 pub fn success<I, O: Clone, E: ParseError<I>>(val: O) -> impl Fn(I) -> IResult<I, O, E> {
   move |input: I| Ok((input, val.clone()))
 }
-
-#[cfg(test)]
-mod tests {
-  use super::*;
-  use crate::bytes::complete::take;
-  use crate::error::ParseError;
-  use crate::internal::{Err, IResult, Needed};
-  use crate::number::complete::u8;
-
-  macro_rules! assert_parse(
-    ($left: expr, $right: expr) => {
-      let res: $crate::IResult<_, _, (_, ErrorKind)> = $left;
-      assert_eq!(res, $right);
-    };
-  );
-
-  /*#[test]
-  fn t1() {
-    let v1:Vec<u8> = vec![1,2,3];
-    let v2:Vec<u8> = vec![4,5,6];
-    let d = Ok((&v1[..], &v2[..]));
-    let res = d.flat_map(print);
-    assert_eq!(res, Ok((&v2[..], ())));
-  }*/
-
-  #[test]
-  fn eof_on_slices() {
-    let not_over: &[u8] = &b"Hello, world!"[..];
-    let is_over: &[u8] = &b""[..];
-
-    let res_not_over = eof(not_over);
-    assert_parse!(
-      res_not_over,
-      Err(Err::Error(error_position!(not_over, ErrorKind::Eof)))
-    );
-
-    let res_over = eof(is_over);
-    assert_parse!(res_over, Ok((is_over, is_over)));
-  }
-
-  #[test]
-  fn eof_on_strs() {
-    let not_over: &str = "Hello, world!";
-    let is_over: &str = "";
-
-    let res_not_over = eof(not_over);
-    assert_parse!(
-      res_not_over,
-      Err(Err::Error(error_position!(not_over, ErrorKind::Eof)))
-    );
-
-    let res_over = eof(is_over);
-    assert_parse!(res_over, Ok((is_over, is_over)));
-  }
-
-  /*
-  #[test]
-  fn end_of_input() {
-      let not_over = &b"Hello, world!"[..];
-      let is_over = &b""[..];
-      named!(eof_test, eof!());
-
-      let res_not_over = eof_test(not_over);
-      assert_eq!(res_not_over, Err(Err::Error(error_position!(not_over, ErrorKind::Eof))));
-
-      let res_over = eof_test(is_over);
-      assert_eq!(res_over, Ok((is_over, is_over)));
-  }
-  */
-
-  #[test]
-  fn rest_on_slices() {
-    let input: &[u8] = &b"Hello, world!"[..];
-    let empty: &[u8] = &b""[..];
-    assert_parse!(rest(input), Ok((empty, input)));
-  }
-
-  #[test]
-  fn rest_on_strs() {
-    let input: &str = "Hello, world!";
-    let empty: &str = "";
-    assert_parse!(rest(input), Ok((empty, input)));
-  }
-
-  #[test]
-  fn rest_len_on_slices() {
-    let input: &[u8] = &b"Hello, world!"[..];
-    assert_parse!(rest_len(input), Ok((input, input.len())));
-  }
-
-  use crate::lib::std::convert::From;
-  impl From<u32> for CustomError {
-    fn from(_: u32) -> Self {
-      CustomError
-    }
-  }
-
-  impl<I> ParseError<I> for CustomError {
-    fn from_error_kind(_: I, _: ErrorKind) -> Self {
-      CustomError
-    }
-
-    fn append(_: I, _: ErrorKind, _: CustomError) -> Self {
-      CustomError
-    }
-  }
-
-  struct CustomError;
-  #[allow(dead_code)]
-  fn custom_error(input: &[u8]) -> IResult<&[u8], &[u8], CustomError> {
-    //fix_error!(input, CustomError, alphanumeric)
-    crate::character::streaming::alphanumeric1(input)
-  }
-
-  #[test]
-  fn test_flat_map() {
-    let input: &[u8] = &[3, 100, 101, 102, 103, 104][..];
-    assert_parse!(
-      flat_map(u8, take)(input),
-      Ok((&[103, 104][..], &[100, 101, 102][..]))
-    );
-  }
-
-  #[test]
-  fn test_map_opt() {
-    let input: &[u8] = &[50][..];
-    assert_parse!(
-      map_opt(u8, |u| if u < 20 { Some(u) } else { None })(input),
-      Err(Err::Error((&[50][..], ErrorKind::MapOpt)))
-    );
-    assert_parse!(
-      map_opt(u8, |u| if u > 20 { Some(u) } else { None })(input),
-      Ok((&[][..], 50))
-    );
-  }
-
-  #[test]
-  fn test_map_parser() {
-    let input: &[u8] = &[100, 101, 102, 103, 104][..];
-    assert_parse!(
-      map_parser(take(4usize), take(2usize))(input),
-      Ok((&[104][..], &[100, 101][..]))
-    );
-  }
-
-  #[test]
-  fn test_all_consuming() {
-    let input: &[u8] = &[100, 101, 102][..];
-    assert_parse!(
-      all_consuming(take(2usize))(input),
-      Err(Err::Error((&[102][..], ErrorKind::Eof)))
-    );
-    assert_parse!(
-      all_consuming(take(3usize))(input),
-      Ok((&[][..], &[100, 101, 102][..]))
-    );
-  }
-
-  #[test]
-  #[allow(unused)]
-  fn test_verify_ref() {
-    use crate::bytes::complete::take;
-
-    let mut parser1 = verify(take(3u8), |s: &[u8]| s == &b"abc"[..]);
-
-    assert_eq!(parser1(&b"abcd"[..]), Ok((&b"d"[..], &b"abc"[..])));
-    assert_eq!(
-      parser1(&b"defg"[..]),
-      Err(Err::Error((&b"defg"[..], ErrorKind::Verify)))
-    );
-
-    fn parser2(i: &[u8]) -> IResult<&[u8], u32> {
-      verify(crate::number::streaming::be_u32, |val: &u32| *val < 3)(i)
-    }
-  }
-
-  #[test]
-  #[cfg(feature = "alloc")]
-  fn test_verify_alloc() {
-    use crate::bytes::complete::take;
-    let mut parser1 = verify(map(take(3u8), |s: &[u8]| s.to_vec()), |s: &[u8]| {
-      s == &b"abc"[..]
-    });
-
-    assert_eq!(parser1(&b"abcd"[..]), Ok((&b"d"[..], (&b"abc").to_vec())));
-    assert_eq!(
-      parser1(&b"defg"[..]),
-      Err(Err::Error((&b"defg"[..], ErrorKind::Verify)))
-    );
-  }
-
-  #[test]
-  #[cfg(feature = "std")]
-  fn test_into() {
-    use crate::bytes::complete::take;
-    use crate::{
-      error::{Error, ParseError},
-      Err,
-    };
-
-    let mut parser = into(take::<_, _, Error<_>>(3u8));
-    let result: IResult<&[u8], Vec<u8>> = parser(&b"abcdefg"[..]);
-
-    assert_eq!(result, Ok((&b"defg"[..], vec![97, 98, 99])));
-  }
-}
diff --git a/src/error.rs b/src/error.rs
index a5aa678..67b8252 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -564,103 +564,6 @@ macro_rules! error_node_position(
   });
 );
 
-//FIXME: error rewrite
-/// translate parser result from IResult<I,O,u32> to IResult<I,O,E> with a custom type
-///
-/// ```
-/// # //FIXME
-/// # #[macro_use] extern crate nom;
-/// # use nom::IResult;
-/// # use std::convert::From;
-/// # use nom::Err;
-/// # use nom::error::ErrorKind;
-/// # fn main() {
-/// #    /*
-/// #    // will add a Custom(42) error to the error chain
-/// #    named!(err_test, add_return_error!(ErrorKind::Custom(42u32), tag!("abcd")));
-/// #
-/// #    #[derive(Debug,Clone,PartialEq)]
-/// #    pub struct ErrorStr(String);
-/// #
-/// #    // Convert to IResult<&[u8], &[u8], ErrorStr>
-/// #    impl From<u32> for ErrorStr {
-/// #      fn from(i: u32) -> Self {
-/// #        ErrorStr(format!("custom error code: {}", i))
-/// #      }
-/// #    }
-/// #
-/// #    named!(parser<&[u8], &[u8], ErrorStr>,
-/// #        fix_error!(ErrorStr, err_test)
-/// #      );
-/// #
-/// #    let a = &b"efghblah"[..];
-/// #    assert_eq!(parser(a), Err(Err::Error(Context::Code(a, ErrorKind::Custom(ErrorStr("custom error code: 42".to_string()))))));
-/// # */
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! fix_error (
-  ($i:expr, $t:ty, $submac:ident!( $($args:tt)* )) => (
-    {
-      use $crate::lib::std::result::Result::*;
-      use $crate::Err;
-
-      match $submac!($i, $($args)*) {
-        Ok((i,o)) => Ok((i,o)),
-        Err(e) => {
-          let e2 = match e {
-            Err::Error(err) => {
-              Err::Error(err.into())
-            },
-            Err::Failure(err) => {
-              Err::Failure(err.into())
-            },
-            Err::Incomplete(e) => Err::Incomplete(e),
-          };
-          Err(e2)
-        }
-      }
-    }
-  );
-  ($i:expr, $t:ty, $f:expr) => (
-    fix_error!($i, $t, call!($f));
-  );
-);
-
-/// `flat_map!(R -> IResult<R,S>, S -> IResult<S,T>) => R -> IResult<R, T>`
-///
-/// Combines a parser `R -> IResult<R,S>` and
-/// a parser `S -> IResult<S,T>` to return another
-/// parser `R -> IResult<R,T>`
-///
-/// ```rust
-/// # #[macro_use] extern crate nom;
-/// # use nom::{Err, error::{Error, ErrorKind}};
-/// use nom::number::complete::recognize_float;
-///
-/// named!(parser<&str, f64>, flat_map!(recognize_float, parse_to!(f64)));
-///
-/// assert_eq!(parser("123.45;"), Ok((";", 123.45)));
-/// assert_eq!(parser("abc"), Err(Err::Error(Error::new("abc", ErrorKind::Char))));
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! flat_map(
-  ($i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => (
-    flat_map!(__impl $i, $submac!($($args)*), $submac2!($($args2)*));
-  );
-  ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
-    flat_map!(__impl $i, $submac!($($args)*), call!($g));
-  );
-  ($i:expr, $f:expr, $submac:ident!( $($args:tt)* )) => (
-    flat_map!(__impl $i, call!($f), $submac!($($args)*));
-  );
-  ($i:expr, $f:expr, $g:expr) => (
-    flat_map!(__impl $i, call!($f), call!($g));
-  );
-  (__impl $i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => (
-    $crate::combinator::map_parserc($i, move |i| {$submac!(i, $($args)*)}, move |i| {$submac2!(i, $($args2)*)})
-  );
-);
 
 #[cfg(test)]
 #[cfg(feature = "alloc")]
diff --git a/src/lib.rs b/src/lib.rs
index ba5b03f..a05ee9d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,8 +6,6 @@
 //! ## Example
 //!
 //! ```rust
-//! extern crate nom;
-//!
 //! use nom::{
 //!   IResult,
 //!   bytes::complete::{tag, take_while_m_n},
@@ -55,8 +53,7 @@
 //! The code is available on [Github](https://github.com/Geal/nom)
 //!
 //! There are a few [guides](https://github.com/Geal/nom/tree/master/doc) with more details
-//! about [the design of nom macros](https://github.com/Geal/nom/blob/master/doc/how_nom_macros_work.md),
-//! [how to write parsers](https://github.com/Geal/nom/blob/master/doc/making_a_new_parser_from_scratch.md),
+//! about [how to write parsers](https://github.com/Geal/nom/blob/master/doc/making_a_new_parser_from_scratch.md),
 //! or the [error management system](https://github.com/Geal/nom/blob/master/doc/error_management.md).
 //! You can also check out the [recipes] module that contains examples of common patterns.
 //!
@@ -111,9 +108,6 @@
 //! Here is another parser, written without using nom's combinators this time:
 //!
 //! ```rust
-//! #[macro_use]
-//! extern crate nom;
-//!
 //! use nom::{IResult, Err, Needed};
 //!
 //! # fn main() {
@@ -130,7 +124,7 @@
 //! This function takes a byte array as input, and tries to consume 4 bytes.
 //! Writing all the parsers manually, like this, is dangerous, despite Rust's
 //! safety features. There are still a lot of mistakes one can make. That's why
-//! nom provides a list of function and macros to help in developing parsers.
+//! nom provides a list of functions to help in developing parsers.
 //!
 //! With functions, you would write it like this:
 //!
@@ -141,24 +135,6 @@
 //! }
 //! ```
 //!
-//! With macros, you would write it like this:
-//!
-//! ```rust
-//! #[macro_use]
-//! extern crate nom;
-//!
-//! # fn main() {
-//! named!(take4, take!(4));
-//! # }
-//! ```
-//!
-//! nom has used macros for combinators from versions 1 to 4, and from version
-//! 5, it proposes new combinators as functions, but still allows the macros style
-//! (macros have been rewritten to use the functions under the hood).
-//! For new parsers, we recommend using the functions instead of macros, since
-//! rustc messages will be much easier to understand.
-//!
-//!
 //! A parser in nom is a function which, for an input type `I`, an output type `O`
 //! and an optional error type `E`, will have the following signature:
 //!
@@ -253,7 +229,6 @@
 //! **`many0`** applies a parser 0 or more times, and returns a vector of the aggregated results:
 //!
 //! ```rust
-//! # #[macro_use] extern crate nom;
 //! # #[cfg(feature = "alloc")]
 //! # fn main() {
 //! use nom::{IResult, multi::many0, bytes::complete::tag};
@@ -274,7 +249,7 @@
 //! # fn main() {}
 //! ```
 //!
-//! Here are some basic combining macros available:
+//! Here are some basic combinators available:
 //!
 //! - **`opt`**: Will make the parser optional (if it returns the `O` type, the new parser returns `Option<O>`)
 //! - **`many0`**: Will apply the parser 0 or more times (if it returns the `O` type, the new parser returns `Vec<O>`)
@@ -286,7 +261,6 @@
 //! Example with `tuple`:
 //!
 //! ```rust
-//! # #[macro_use] extern crate nom;
 //! # fn main() {
 //! use nom::{error::ErrorKind, Needed,
 //! number::streaming::be_u16,
@@ -312,7 +286,6 @@
 //! thanks to the `?` operator:
 //!
 //! ```rust
-//! # #[macro_use] extern crate nom;
 //! # fn main() {
 //! use nom::{IResult, bytes::complete::tag};
 //!
diff --git a/src/number/complete.rs b/src/number/complete.rs
index 3e076db..0d53c0c 100644
--- a/src/number/complete.rs
+++ b/src/number/complete.rs
@@ -11,6 +11,26 @@ use crate::sequence::{pair, tuple};
 use crate::traits::{AsChar, InputIter, InputLength, InputTakeAtPosition};
 use crate::traits::{Offset, Slice};
 
+#[doc(hidden)]
+macro_rules! map(
+  // Internal parser, do not use directly
+  (__impl $i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
+    $crate::combinator::mapc($i, move |i| {$submac!(i, $($args)*)}, $g)
+  );
+  ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
+    map!(__impl $i, $submac!($($args)*), $g);
+  );
+  ($i:expr, $f:expr, $g:expr) => (
+    map!(__impl $i, call!($f), $g);
+  );
+);
+
+#[doc(hidden)]
+macro_rules! call (
+  ($i:expr, $fun:expr) => ( $fun( $i ) );
+  ($i:expr, $fun:expr, $($args:expr),* ) => ( $fun( $i, $($args),* ) );
+);
+
 /// Recognizes an unsigned 1 byte integer.
 ///
 /// *Complete version*: Returns an error if there is not enough input data.
diff --git a/src/number/streaming.rs b/src/number/streaming.rs
index 5d62685..801ae65 100644
--- a/src/number/streaming.rs
+++ b/src/number/streaming.rs
@@ -10,6 +10,26 @@ use crate::sequence::{pair, tuple};
 use crate::traits::{AsChar, InputIter, InputLength, InputTakeAtPosition};
 use crate::traits::{Offset, Slice};
 
+#[doc(hidden)]
+macro_rules! map(
+  // Internal parser, do not use directly
+  (__impl $i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
+    $crate::combinator::mapc($i, move |i| {$submac!(i, $($args)*)}, $g)
+  );
+  ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
+    map!(__impl $i, $submac!($($args)*), $g);
+  );
+  ($i:expr, $f:expr, $g:expr) => (
+    map!(__impl $i, call!($f), $g);
+  );
+);
+
+#[doc(hidden)]
+macro_rules! call (
+  ($i:expr, $fun:expr) => ( $fun( $i ) );
+  ($i:expr, $fun:expr, $($args:expr),* ) => ( $fun( $i, $($args),* ) );
+);
+
 /// Recognizes an unsigned 1 byte integer.
 ///
 /// *Streaming version*: Will return `Err(nom::Err::Incomplete(_))` if there is not enough data.
diff --git a/src/util.rs b/src/util.rs
index c48f808..13b67b9 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -1,8 +1,3 @@
-#[cfg(feature = "std")]
-use crate::internal::IResult;
-#[cfg(feature = "std")]
-use std::fmt::Debug;
-
 #[cfg(feature = "std")]
 #[cfg_attr(feature = "docsrs", doc(cfg(feature = "std")))]
 /// Helper trait to show a byte slice as a hex dump
@@ -80,139 +75,3 @@ impl HexDisplay for str {
   }
 }
 
-#[doc(hidden)]
-#[macro_export]
-macro_rules! nom_line (
-  () => (line!());
-);
-
-#[doc(hidden)]
-#[macro_export]
-macro_rules! nom_println (
-  ($($args:tt)*) => (println!($($args)*));
-);
-
-#[doc(hidden)]
-#[macro_export]
-macro_rules! nom_stringify (
-  ($($args:tt)*) => (stringify!($($args)*));
-);
-
-/// Prints a message if the parser fails.
-///
-/// The message prints the `Error` or `Incomplete`
-/// and the parser's calling code
-///
-/// ```
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///    named!(f, dbg_basic!( tag!( "abcd" ) ) );
-///
-///    let a = &b"efgh"[..];
-///
-///    // Will print the following message:
-///    // Error(Position(0, [101, 102, 103, 104])) at l.5 by ' tag ! ( "abcd" ) '
-///    f(a);
-/// # }
-/// ```
-#[macro_export(local_inner_macros)]
-macro_rules! dbg_basic (
-  ($i: expr, $submac:ident!( $($args:tt)* )) => (
-    {
-      use $crate::lib::std::result::Result::*;
-      let l = nom_line!();
-      match $submac!($i, $($args)*) {
-        Err(e) => {
-          nom_println!("Err({:?}) at l.{} by ' {} '", e, l, nom_stringify!($submac!($($args)*)));
-          Err(e)
-        },
-        a => a,
-      }
-    }
-  );
-
-  ($i:expr, $f:ident) => (
-      dbg_basic!($i, call!($f));
-  );
-);
-
-/// 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
-///
-/// ```rust
-/// use nom::{IResult, dbg_dmp, bytes::complete::tag};
-///
-/// fn f(i: &[u8]) -> IResult<&[u8], &[u8]> {
-///   dbg_dmp(tag("abcd"), "tag")(i)
-/// }
-///
-///   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);
-/// ```
-#[cfg(feature = "std")]
-#[cfg_attr(feature = "docsrs", doc(cfg(feature = "std")))]
-pub fn dbg_dmp<'a, F, O, E: Debug>(
-  f: F,
-  context: &'static str,
-) -> impl Fn(&'a [u8]) -> IResult<&'a [u8], O, E>
-where
-  F: Fn(&'a [u8]) -> IResult<&'a [u8], O, E>,
-{
-  move |i: &'a [u8]| match f(i) {
-    Err(e) => {
-      println!("{}: Error({:?}) at:\n{}", context, e, i.to_hex(8));
-      Err(e)
-    }
-    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
-///
-/// ```ignore
-/// # #[macro_use] extern crate nom;
-/// # fn main() {
-///    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);
-/// # }
-#[macro_export(local_inner_macros)]
-#[cfg(feature = "std")]
-#[cfg_attr(feature = "docsrs", doc(cfg(feature = "std")))]
-macro_rules! dbg_dmp (
-  ($i: expr, $submac:ident!( $($args:tt)* )) => (
-    {
-      use $crate::HexDisplay;
-      let l = nom_line!();
-      match $submac!($i, $($args)*) {
-        Err(e) => {
-          nom_println!("Error({:?}) at l.{} by ' {} '\n{}", e, l, nom_stringify!($submac!($($args)*)), $i.to_hex(8));
-          Err(e)
-        },
-        a => a,
-      }
-    }
-  );
-
-  ($i:expr, $f:ident) => (
-      dbg_dmp!($i, call!($f));
-  );
-);


Test patch:
diff --git a/src/bytes/tests.rs b/src/bytes/tests.rs
new file mode 100644
index 0000000..d6ad7e5
--- /dev/null
+++ b/src/bytes/tests.rs
@@ -0,0 +1,640 @@
+#[cfg(feature = "alloc")]
+use crate::branch::alt;
+#[cfg(feature = "alloc")]
+use crate::bytes::complete::tag;
+#[cfg(feature = "alloc")]
+use crate::bytes::complete::{escaped, escaped_transform};
+use crate::character::is_alphabetic;
+use crate::character::streaming::{
+  alpha1 as alpha, alphanumeric1 as alphanumeric, digit1 as digit, hex_digit1 as hex_digit,
+  multispace1 as multispace, oct_digit1 as oct_digit, space1 as space,
+};
+#[cfg(feature = "alloc")]
+use crate::combinator::{map, value};
+use crate::error::ErrorKind;
+use crate::internal::{Err, IResult, Needed};
+#[cfg(feature = "alloc")]
+use crate::lib::std::string::String;
+#[cfg(feature = "alloc")]
+use crate::lib::std::vec::Vec;
+
+#[test]
+fn is_a() {
+  use crate::bytes::streaming::is_a;
+
+  fn a_or_b(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    is_a("ab")(i)
+  }
+
+  let a = &b"abcd"[..];
+  assert_eq!(a_or_b(a), Ok((&b"cd"[..], &b"ab"[..])));
+
+  let b = &b"bcde"[..];
+  assert_eq!(a_or_b(b), Ok((&b"cde"[..], &b"b"[..])));
+
+  let c = &b"cdef"[..];
+  assert_eq!(
+    a_or_b(c),
+    Err(Err::Error(error_position!(c, ErrorKind::IsA)))
+  );
+
+  let d = &b"bacdef"[..];
+  assert_eq!(a_or_b(d), Ok((&b"cdef"[..], &b"ba"[..])));
+}
+
+#[test]
+fn is_not() {
+  use crate::bytes::streaming::is_not;
+
+  fn a_or_b(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    is_not("ab")(i)
+  }
+
+  let a = &b"cdab"[..];
+  assert_eq!(a_or_b(a), Ok((&b"ab"[..], &b"cd"[..])));
+
+  let b = &b"cbde"[..];
+  assert_eq!(a_or_b(b), Ok((&b"bde"[..], &b"c"[..])));
+
+  let c = &b"abab"[..];
+  assert_eq!(
+    a_or_b(c),
+    Err(Err::Error(error_position!(c, ErrorKind::IsNot)))
+  );
+
+  let d = &b"cdefba"[..];
+  assert_eq!(a_or_b(d), Ok((&b"ba"[..], &b"cdef"[..])));
+
+  let e = &b"e"[..];
+  assert_eq!(a_or_b(e), Err(Err::Incomplete(Needed::new(1))));
+}
+
+#[cfg(feature = "alloc")]
+#[allow(unused_variables)]
+#[test]
+fn escaping() {
+  use crate::character::streaming::one_of;
+
+  fn esc(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    escaped(alpha, '\\', one_of("\"n\\"))(i)
+  }
+  assert_eq!(esc(&b"abcd;"[..]), Ok((&b";"[..], &b"abcd"[..])));
+  assert_eq!(esc(&b"ab\\\"cd;"[..]), Ok((&b";"[..], &b"ab\\\"cd"[..])));
+  assert_eq!(esc(&b"\\\"abcd;"[..]), Ok((&b";"[..], &b"\\\"abcd"[..])));
+  assert_eq!(esc(&b"\\n;"[..]), Ok((&b";"[..], &b"\\n"[..])));
+  assert_eq!(esc(&b"ab\\\"12"[..]), Ok((&b"12"[..], &b"ab\\\""[..])));
+  assert_eq!(
+    esc(&b"AB\\"[..]),
+    Err(Err::Error(error_position!(
+      &b"AB\\"[..],
+      ErrorKind::Escaped
+    )))
+  );
+  assert_eq!(
+    esc(&b"AB\\A"[..]),
+    Err(Err::Error(error_node_position!(
+      &b"AB\\A"[..],
+      ErrorKind::Escaped,
+      error_position!(&b"A"[..], ErrorKind::OneOf)
+    )))
+  );
+
+  fn esc2(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    escaped(digit, '\\', one_of("\"n\\"))(i)
+  }
+  assert_eq!(esc2(&b"12\\nnn34"[..]), Ok((&b"nn34"[..], &b"12\\n"[..])));
+}
+
+#[cfg(feature = "alloc")]
+#[test]
+fn escaping_str() {
+  use crate::character::streaming::one_of;
+
+  fn esc(i: &str) -> IResult<&str, &str> {
+    escaped(alpha, '\\', one_of("\"n\\"))(i)
+  }
+  assert_eq!(esc("abcd;"), Ok((";", "abcd")));
+  assert_eq!(esc("ab\\\"cd;"), Ok((";", "ab\\\"cd")));
+  assert_eq!(esc("\\\"abcd;"), Ok((";", "\\\"abcd")));
+  assert_eq!(esc("\\n;"), Ok((";", "\\n")));
+  assert_eq!(esc("ab\\\"12"), Ok(("12", "ab\\\"")));
+  assert_eq!(
+    esc("AB\\"),
+    Err(Err::Error(error_position!("AB\\", ErrorKind::Escaped)))
+  );
+  assert_eq!(
+    esc("AB\\A"),
+    Err(Err::Error(error_node_position!(
+      "AB\\A",
+      ErrorKind::Escaped,
+      error_position!("A", ErrorKind::OneOf)
+    )))
+  );
+
+  fn esc2(i: &str) -> IResult<&str, &str> {
+    escaped(digit, '\\', one_of("\"n\\"))(i)
+  }
+  assert_eq!(esc2("12\\nnn34"), Ok(("nn34", "12\\n")));
+
+  fn esc3(i: &str) -> IResult<&str, &str> {
+    escaped(alpha, '\u{241b}', one_of("\"n"))(i)
+  }
+  assert_eq!(esc3("ab␛ncd;"), Ok((";", "ab␛ncd")));
+}
+
+#[cfg(feature = "alloc")]
+fn to_s(i: Vec<u8>) -> String {
+  String::from_utf8_lossy(&i).into_owned()
+}
+
+#[cfg(feature = "alloc")]
+#[test]
+fn escape_transform() {
+  fn esc(i: &[u8]) -> IResult<&[u8], String> {
+    map(
+      escaped_transform(
+        alpha,
+        '\\',
+        alt((
+          value(&b"\\"[..], tag("\\")),
+          value(&b"\""[..], tag("\"")),
+          value(&b"\n"[..], tag("n")),
+        )),
+      ),
+      to_s,
+    )(i)
+  }
+
+  assert_eq!(esc(&b"abcd;"[..]), Ok((&b";"[..], String::from("abcd"))));
+  assert_eq!(
+    esc(&b"ab\\\"cd;"[..]),
+    Ok((&b";"[..], String::from("ab\"cd")))
+  );
+  assert_eq!(
+    esc(&b"\\\"abcd;"[..]),
+    Ok((&b";"[..], String::from("\"abcd")))
+  );
+  assert_eq!(esc(&b"\\n;"[..]), Ok((&b";"[..], String::from("\n"))));
+  assert_eq!(
+    esc(&b"ab\\\"12"[..]),
+    Ok((&b"12"[..], String::from("ab\"")))
+  );
+  assert_eq!(
+    esc(&b"AB\\"[..]),
+    Err(Err::Error(error_position!(
+      &b"\\"[..],
+      ErrorKind::EscapedTransform
+    )))
+  );
+  assert_eq!(
+    esc(&b"AB\\A"[..]),
+    Err(Err::Error(error_node_position!(
+      &b"AB\\A"[..],
+      ErrorKind::EscapedTransform,
+      error_position!(&b"A"[..], ErrorKind::Tag)
+    )))
+  );
+
+  fn esc2(i: &[u8]) -> IResult<&[u8], String> {
+    map(
+      escaped_transform(
+        alpha,
+        '&',
+        alt((
+          value("è".as_bytes(), tag("egrave;")),
+          value("à".as_bytes(), tag("agrave;")),
+        )),
+      ),
+      to_s,
+    )(i)
+  }
+  assert_eq!(
+    esc2(&b"ab&egrave;DEF;"[..]),
+    Ok((&b";"[..], String::from("abèDEF")))
+  );
+  assert_eq!(
+    esc2(&b"ab&egrave;D&agrave;EF;"[..]),
+    Ok((&b";"[..], String::from("abèDàEF")))
+  );
+}
+
+#[cfg(feature = "std")]
+#[test]
+fn escape_transform_str() {
+  fn esc(i: &str) -> IResult<&str, String> {
+    escaped_transform(
+      alpha,
+      '\\',
+      alt((
+        value("\\", tag("\\")),
+        value("\"", tag("\"")),
+        value("\n", tag("n")),
+      )),
+    )(i)
+  }
+
+  assert_eq!(esc("abcd;"), Ok((";", String::from("abcd"))));
+  assert_eq!(esc("ab\\\"cd;"), Ok((";", String::from("ab\"cd"))));
+  assert_eq!(esc("\\\"abcd;"), Ok((";", String::from("\"abcd"))));
+  assert_eq!(esc("\\n;"), Ok((";", String::from("\n"))));
+  assert_eq!(esc("ab\\\"12"), Ok(("12", String::from("ab\""))));
+  assert_eq!(
+    esc("AB\\"),
+    Err(Err::Error(error_position!(
+      "\\",
+      ErrorKind::EscapedTransform
+    )))
+  );
+  assert_eq!(
+    esc("AB\\A"),
+    Err(Err::Error(error_node_position!(
+      "AB\\A",
+      ErrorKind::EscapedTransform,
+      error_position!("A", ErrorKind::Tag)
+    )))
+  );
+
+  fn esc2(i: &str) -> IResult<&str, String> {
+    escaped_transform(
+      alpha,
+      '&',
+      alt((value("è", tag("egrave;")), value("à", tag("agrave;")))),
+    )(i)
+  }
+  assert_eq!(esc2("ab&egrave;DEF;"), Ok((";", String::from("abèDEF"))));
+  assert_eq!(
+    esc2("ab&egrave;D&agrave;EF;"),
+    Ok((";", String::from("abèDàEF")))
+  );
+
+  fn esc3(i: &str) -> IResult<&str, String> {
+    escaped_transform(
+      alpha,
+      '␛',
+      alt((value("\0", tag("0")), value("\n", tag("n")))),
+    )(i)
+  }
+  assert_eq!(esc3("a␛0bc␛n"), Ok(("", String::from("a\0bc\n"))));
+}
+
+#[test]
+fn take_until_incomplete() {
+  use crate::bytes::streaming::take_until;
+  fn y(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    take_until("end")(i)
+  }
+  assert_eq!(y(&b"nd"[..]), Err(Err::Incomplete(Needed::Unknown)));
+  assert_eq!(y(&b"123"[..]), Err(Err::Incomplete(Needed::Unknown)));
+  assert_eq!(y(&b"123en"[..]), Err(Err::Incomplete(Needed::Unknown)));
+}
+
+#[test]
+fn take_until_incomplete_s() {
+  use crate::bytes::streaming::take_until;
+  fn ys(i: &str) -> IResult<&str, &str> {
+    take_until("end")(i)
+  }
+  assert_eq!(ys("123en"), Err(Err::Incomplete(Needed::Unknown)));
+}
+
+#[test]
+fn recognize() {
+  use crate::bytes::streaming::{tag, take};
+  use crate::combinator::recognize;
+  use crate::sequence::delimited;
+
+  fn x(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    recognize(delimited(tag("<!--"), take(5_usize), tag("-->")))(i)
+  }
+  let r = x(&b"<!-- abc --> aaa"[..]);
+  assert_eq!(r, Ok((&b" aaa"[..], &b"<!-- abc -->"[..])));
+
+  let semicolon = &b";"[..];
+
+  fn ya(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    recognize(alpha)(i)
+  }
+  let ra = ya(&b"abc;"[..]);
+  assert_eq!(ra, Ok((semicolon, &b"abc"[..])));
+
+  fn yd(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    recognize(digit)(i)
+  }
+  let rd = yd(&b"123;"[..]);
+  assert_eq!(rd, Ok((semicolon, &b"123"[..])));
+
+  fn yhd(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    recognize(hex_digit)(i)
+  }
+  let rhd = yhd(&b"123abcDEF;"[..]);
+  assert_eq!(rhd, Ok((semicolon, &b"123abcDEF"[..])));
+
+  fn yod(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    recognize(oct_digit)(i)
+  }
+  let rod = yod(&b"1234567;"[..]);
+  assert_eq!(rod, Ok((semicolon, &b"1234567"[..])));
+
+  fn yan(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    recognize(alphanumeric)(i)
+  }
+  let ran = yan(&b"123abc;"[..]);
+  assert_eq!(ran, Ok((semicolon, &b"123abc"[..])));
+
+  fn ys(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    recognize(space)(i)
+  }
+  let rs = ys(&b" \t;"[..]);
+  assert_eq!(rs, Ok((semicolon, &b" \t"[..])));
+
+  fn yms(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    recognize(multispace)(i)
+  }
+  let rms = yms(&b" \t\r\n;"[..]);
+  assert_eq!(rms, Ok((semicolon, &b" \t\r\n"[..])));
+}
+
+#[test]
+fn take_while() {
+  use crate::bytes::streaming::take_while;
+
+  fn f(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    take_while(is_alphabetic)(i)
+  }
+  let a = b"";
+  let b = b"abcd";
+  let c = b"abcd123";
+  let d = b"123";
+
+  assert_eq!(f(&a[..]), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(f(&b[..]), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(f(&c[..]), Ok((&d[..], &b[..])));
+  assert_eq!(f(&d[..]), Ok((&d[..], &a[..])));
+}
+
+#[test]
+fn take_while1() {
+  use crate::bytes::streaming::take_while1;
+
+  fn f(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    take_while1(is_alphabetic)(i)
+  }
+  let a = b"";
+  let b = b"abcd";
+  let c = b"abcd123";
+  let d = b"123";
+
+  assert_eq!(f(&a[..]), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(f(&b[..]), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(f(&c[..]), Ok((&b"123"[..], &b[..])));
+  assert_eq!(
+    f(&d[..]),
+    Err(Err::Error(error_position!(&d[..], ErrorKind::TakeWhile1)))
+  );
+}
+
+#[test]
+fn take_while_m_n() {
+  use crate::bytes::streaming::take_while_m_n;
+
+  fn x(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    take_while_m_n(2, 4, is_alphabetic)(i)
+  }
+  let a = b"";
+  let b = b"a";
+  let c = b"abc";
+  let d = b"abc123";
+  let e = b"abcde";
+  let f = b"123";
+
+  assert_eq!(x(&a[..]), Err(Err::Incomplete(Needed::new(2))));
+  assert_eq!(x(&b[..]), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(x(&c[..]), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(x(&d[..]), Ok((&b"123"[..], &c[..])));
+  assert_eq!(x(&e[..]), Ok((&b"e"[..], &b"abcd"[..])));
+  assert_eq!(
+    x(&f[..]),
+    Err(Err::Error(error_position!(&f[..], ErrorKind::TakeWhileMN)))
+  );
+}
+
+#[test]
+fn take_till() {
+  use crate::bytes::streaming::take_till;
+
+  fn f(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    take_till(is_alphabetic)(i)
+  }
+  let a = b"";
+  let b = b"abcd";
+  let c = b"123abcd";
+  let d = b"123";
+
+  assert_eq!(f(&a[..]), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(f(&b[..]), Ok((&b"abcd"[..], &b""[..])));
+  assert_eq!(f(&c[..]), Ok((&b"abcd"[..], &b"123"[..])));
+  assert_eq!(f(&d[..]), Err(Err::Incomplete(Needed::new(1))));
+}
+
+#[test]
+fn take_till1() {
+  use crate::bytes::streaming::take_till1;
+
+  fn f(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    take_till1(is_alphabetic)(i)
+  }
+  let a = b"";
+  let b = b"abcd";
+  let c = b"123abcd";
+  let d = b"123";
+
+  assert_eq!(f(&a[..]), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(
+    f(&b[..]),
+    Err(Err::Error(error_position!(&b[..], ErrorKind::TakeTill1)))
+  );
+  assert_eq!(f(&c[..]), Ok((&b"abcd"[..], &b"123"[..])));
+  assert_eq!(f(&d[..]), Err(Err::Incomplete(Needed::new(1))));
+}
+
+#[test]
+fn take_while_utf8() {
+  use crate::bytes::streaming::take_while;
+
+  fn f(i: &str) -> IResult<&str, &str> {
+    take_while(|c| c != '點')(i)
+  }
+
+  assert_eq!(f(""), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(f("abcd"), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(f("abcd點"), Ok(("點", "abcd")));
+  assert_eq!(f("abcd點a"), Ok(("點a", "abcd")));
+
+  fn g(i: &str) -> IResult<&str, &str> {
+    take_while(|c| c == '點')(i)
+  }
+
+  assert_eq!(g(""), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(g("點abcd"), Ok(("abcd", "點")));
+  assert_eq!(g("點點點a"), Ok(("a", "點點點")));
+}
+
+#[test]
+fn take_till_utf8() {
+  use crate::bytes::streaming::take_till;
+
+  fn f(i: &str) -> IResult<&str, &str> {
+    take_till(|c| c == '點')(i)
+  }
+
+  assert_eq!(f(""), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(f("abcd"), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(f("abcd點"), Ok(("點", "abcd")));
+  assert_eq!(f("abcd點a"), Ok(("點a", "abcd")));
+
+  fn g(i: &str) -> IResult<&str, &str> {
+    take_till(|c| c != '點')(i)
+  }
+
+  assert_eq!(g(""), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(g("點abcd"), Ok(("abcd", "點")));
+  assert_eq!(g("點點點a"), Ok(("a", "點點點")));
+}
+
+#[test]
+fn take_utf8() {
+  use crate::bytes::streaming::{take, take_while};
+
+  fn f(i: &str) -> IResult<&str, &str> {
+    take(3_usize)(i)
+  }
+
+  assert_eq!(f(""), Err(Err::Incomplete(Needed::Unknown)));
+  assert_eq!(f("ab"), Err(Err::Incomplete(Needed::Unknown)));
+  assert_eq!(f("點"), Err(Err::Incomplete(Needed::Unknown)));
+  assert_eq!(f("ab點cd"), Ok(("cd", "ab點")));
+  assert_eq!(f("a點bcd"), Ok(("cd", "a點b")));
+  assert_eq!(f("a點b"), Ok(("", "a點b")));
+
+  fn g(i: &str) -> IResult<&str, &str> {
+    take_while(|c| c == '點')(i)
+  }
+
+  assert_eq!(g(""), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(g("點abcd"), Ok(("abcd", "點")));
+  assert_eq!(g("點點點a"), Ok(("a", "點點點")));
+}
+
+#[test]
+fn take_while_m_n_utf8() {
+  use crate::bytes::streaming::take_while_m_n;
+
+  fn parser(i: &str) -> IResult<&str, &str> {
+    take_while_m_n(1, 1, |c| c == 'A' || c == '😃')(i)
+  }
+  assert_eq!(parser("A!"), Ok(("!", "A")));
+  assert_eq!(parser("😃!"), Ok(("!", "😃")));
+}
+
+#[test]
+fn take_while_m_n_utf8_full_match() {
+  use crate::bytes::streaming::take_while_m_n;
+
+  fn parser(i: &str) -> IResult<&str, &str> {
+    take_while_m_n(1, 1, |c: char| c.is_alphabetic())(i)
+  }
+  assert_eq!(parser("øn"), Ok(("n", "ø")));
+}
+
+#[test]
+#[cfg(feature = "std")]
+fn recognize_take_while() {
+  use crate::bytes::streaming::take_while;
+  use crate::character::is_alphanumeric;
+  use crate::combinator::recognize;
+
+  fn x(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    take_while(is_alphanumeric)(i)
+  }
+  fn y(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    recognize(x)(i)
+  }
+  assert_eq!(x(&b"ab."[..]), Ok((&b"."[..], &b"ab"[..])));
+  println!("X: {:?}", x(&b"ab"[..]));
+  assert_eq!(y(&b"ab."[..]), Ok((&b"."[..], &b"ab"[..])));
+}
+
+#[test]
+fn length_bytes() {
+  use crate::{bytes::streaming::tag, multi::length_data, number::streaming::le_u8};
+
+  fn x(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    length_data(le_u8)(i)
+  }
+  assert_eq!(x(b"\x02..>>"), Ok((&b">>"[..], &b".."[..])));
+  assert_eq!(x(b"\x02.."), Ok((&[][..], &b".."[..])));
+  assert_eq!(x(b"\x02."), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(x(b"\x02"), Err(Err::Incomplete(Needed::new(2))));
+
+  fn y(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    let (i, _) = tag("magic")(i)?;
+    length_data(le_u8)(i)
+  }
+  assert_eq!(y(b"magic\x02..>>"), Ok((&b">>"[..], &b".."[..])));
+  assert_eq!(y(b"magic\x02.."), Ok((&[][..], &b".."[..])));
+  assert_eq!(y(b"magic\x02."), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(y(b"magic\x02"), Err(Err::Incomplete(Needed::new(2))));
+}
+
+#[cfg(feature = "alloc")]
+#[test]
+fn case_insensitive() {
+  use crate::bytes::streaming::tag_no_case;
+
+  fn test(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    tag_no_case("ABcd")(i)
+  }
+  assert_eq!(test(&b"aBCdefgh"[..]), Ok((&b"efgh"[..], &b"aBCd"[..])));
+  assert_eq!(test(&b"abcdefgh"[..]), Ok((&b"efgh"[..], &b"abcd"[..])));
+  assert_eq!(test(&b"ABCDefgh"[..]), Ok((&b"efgh"[..], &b"ABCD"[..])));
+  assert_eq!(test(&b"ab"[..]), Err(Err::Incomplete(Needed::new(2))));
+  assert_eq!(
+    test(&b"Hello"[..]),
+    Err(Err::Error(error_position!(&b"Hello"[..], ErrorKind::Tag)))
+  );
+  assert_eq!(
+    test(&b"Hel"[..]),
+    Err(Err::Error(error_position!(&b"Hel"[..], ErrorKind::Tag)))
+  );
+
+  fn test2(i: &str) -> IResult<&str, &str> {
+    tag_no_case("ABcd")(i)
+  }
+  assert_eq!(test2("aBCdefgh"), Ok(("efgh", "aBCd")));
+  assert_eq!(test2("abcdefgh"), Ok(("efgh", "abcd")));
+  assert_eq!(test2("ABCDefgh"), Ok(("efgh", "ABCD")));
+  assert_eq!(test2("ab"), Err(Err::Incomplete(Needed::new(2))));
+  assert_eq!(
+    test2("Hello"),
+    Err(Err::Error(error_position!(&"Hello"[..], ErrorKind::Tag)))
+  );
+  assert_eq!(
+    test2("Hel"),
+    Err(Err::Error(error_position!(&"Hel"[..], ErrorKind::Tag)))
+  );
+}
+
+#[test]
+fn tag_fixed_size_array() {
+  use crate::bytes::streaming::tag;
+
+  fn test(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    tag([0x42])(i)
+  }
+  fn test2(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    tag(&[0x42])(i)
+  }
+  let input = [0x42, 0x00];
+  assert_eq!(test(&input), Ok((&b"\x00"[..], &b"\x42"[..])));
+  assert_eq!(test2(&input), Ok((&b"\x00"[..], &b"\x42"[..])));
+}
diff --git a/src/combinator/tests.rs b/src/combinator/tests.rs
new file mode 100644
index 0000000..b8c1c6c
--- /dev/null
+++ b/src/combinator/tests.rs
@@ -0,0 +1,266 @@
+use super::*;
+use crate::bytes::complete::take;
+use crate::bytes::streaming::tag;
+use crate::error::ErrorKind;
+use crate::error::ParseError;
+use crate::internal::{Err, IResult, Needed};
+#[cfg(feature = "alloc")]
+use crate::lib::std::boxed::Box;
+use crate::number::complete::u8;
+
+macro_rules! assert_parse(
+  ($left: expr, $right: expr) => {
+    let res: $crate::IResult<_, _, (_, ErrorKind)> = $left;
+    assert_eq!(res, $right);
+  };
+);
+
+/*#[test]
+fn t1() {
+  let v1:Vec<u8> = vec![1,2,3];
+  let v2:Vec<u8> = vec![4,5,6];
+  let d = Ok((&v1[..], &v2[..]));
+  let res = d.flat_map(print);
+  assert_eq!(res, Ok((&v2[..], ())));
+}*/
+
+#[test]
+fn eof_on_slices() {
+  let not_over: &[u8] = &b"Hello, world!"[..];
+  let is_over: &[u8] = &b""[..];
+
+  let res_not_over = eof(not_over);
+  assert_parse!(
+    res_not_over,
+    Err(Err::Error(error_position!(not_over, ErrorKind::Eof)))
+  );
+
+  let res_over = eof(is_over);
+  assert_parse!(res_over, Ok((is_over, is_over)));
+}
+
+#[test]
+fn eof_on_strs() {
+  let not_over: &str = "Hello, world!";
+  let is_over: &str = "";
+
+  let res_not_over = eof(not_over);
+  assert_parse!(
+    res_not_over,
+    Err(Err::Error(error_position!(not_over, ErrorKind::Eof)))
+  );
+
+  let res_over = eof(is_over);
+  assert_parse!(res_over, Ok((is_over, is_over)));
+}
+
+/*
+#[test]
+fn end_of_input() {
+    let not_over = &b"Hello, world!"[..];
+    let is_over = &b""[..];
+    named!(eof_test, eof!());
+
+    let res_not_over = eof_test(not_over);
+    assert_eq!(res_not_over, Err(Err::Error(error_position!(not_over, ErrorKind::Eof))));
+
+    let res_over = eof_test(is_over);
+    assert_eq!(res_over, Ok((is_over, is_over)));
+}
+*/
+
+#[test]
+fn rest_on_slices() {
+  let input: &[u8] = &b"Hello, world!"[..];
+  let empty: &[u8] = &b""[..];
+  assert_parse!(rest(input), Ok((empty, input)));
+}
+
+#[test]
+fn rest_on_strs() {
+  let input: &str = "Hello, world!";
+  let empty: &str = "";
+  assert_parse!(rest(input), Ok((empty, input)));
+}
+
+#[test]
+fn rest_len_on_slices() {
+  let input: &[u8] = &b"Hello, world!"[..];
+  assert_parse!(rest_len(input), Ok((input, input.len())));
+}
+
+use crate::lib::std::convert::From;
+impl From<u32> for CustomError {
+  fn from(_: u32) -> Self {
+    CustomError
+  }
+}
+
+impl<I> ParseError<I> for CustomError {
+  fn from_error_kind(_: I, _: ErrorKind) -> Self {
+    CustomError
+  }
+
+  fn append(_: I, _: ErrorKind, _: CustomError) -> Self {
+    CustomError
+  }
+}
+
+struct CustomError;
+#[allow(dead_code)]
+fn custom_error(input: &[u8]) -> IResult<&[u8], &[u8], CustomError> {
+  //fix_error!(input, CustomError, alphanumeric)
+  crate::character::streaming::alphanumeric1(input)
+}
+
+#[test]
+fn test_flat_map() {
+  let input: &[u8] = &[3, 100, 101, 102, 103, 104][..];
+  assert_parse!(
+    flat_map(u8, take)(input),
+    Ok((&[103, 104][..], &[100, 101, 102][..]))
+  );
+}
+
+#[test]
+fn test_map_opt() {
+  let input: &[u8] = &[50][..];
+  assert_parse!(
+    map_opt(u8, |u| if u < 20 { Some(u) } else { None })(input),
+    Err(Err::Error((&[50][..], ErrorKind::MapOpt)))
+  );
+  assert_parse!(
+    map_opt(u8, |u| if u > 20 { Some(u) } else { None })(input),
+    Ok((&[][..], 50))
+  );
+}
+
+#[test]
+fn test_map_parser() {
+  let input: &[u8] = &[100, 101, 102, 103, 104][..];
+  assert_parse!(
+    map_parser(take(4usize), take(2usize))(input),
+    Ok((&[104][..], &[100, 101][..]))
+  );
+}
+
+#[test]
+fn test_all_consuming() {
+  let input: &[u8] = &[100, 101, 102][..];
+  assert_parse!(
+    all_consuming(take(2usize))(input),
+    Err(Err::Error((&[102][..], ErrorKind::Eof)))
+  );
+  assert_parse!(
+    all_consuming(take(3usize))(input),
+    Ok((&[][..], &[100, 101, 102][..]))
+  );
+}
+
+#[test]
+#[allow(unused)]
+fn test_verify_ref() {
+  use crate::bytes::complete::take;
+
+  let mut parser1 = verify(take(3u8), |s: &[u8]| s == &b"abc"[..]);
+
+  assert_eq!(parser1(&b"abcd"[..]), Ok((&b"d"[..], &b"abc"[..])));
+  assert_eq!(
+    parser1(&b"defg"[..]),
+    Err(Err::Error((&b"defg"[..], ErrorKind::Verify)))
+  );
+
+  fn parser2(i: &[u8]) -> IResult<&[u8], u32> {
+    verify(crate::number::streaming::be_u32, |val: &u32| *val < 3)(i)
+  }
+}
+
+#[test]
+#[cfg(feature = "alloc")]
+fn test_verify_alloc() {
+  use crate::bytes::complete::take;
+  let mut parser1 = verify(map(take(3u8), |s: &[u8]| s.to_vec()), |s: &[u8]| {
+    s == &b"abc"[..]
+  });
+
+  assert_eq!(parser1(&b"abcd"[..]), Ok((&b"d"[..], (&b"abc").to_vec())));
+  assert_eq!(
+    parser1(&b"defg"[..]),
+    Err(Err::Error((&b"defg"[..], ErrorKind::Verify)))
+  );
+}
+
+#[test]
+#[cfg(feature = "std")]
+fn test_into() {
+  use crate::bytes::complete::take;
+  use crate::{
+    error::{Error, ParseError},
+    Err,
+  };
+
+  let mut parser = into(take::<_, _, Error<_>>(3u8));
+  let result: IResult<&[u8], Vec<u8>> = parser(&b"abcdefg"[..]);
+
+  assert_eq!(result, Ok((&b"defg"[..], vec![97, 98, 99])));
+}
+
+#[test]
+fn opt_test() {
+  fn opt_abcd(i: &[u8]) -> IResult<&[u8], Option<&[u8]>> {
+    opt(tag("abcd"))(i)
+  }
+
+  let a = &b"abcdef"[..];
+  let b = &b"bcdefg"[..];
+  let c = &b"ab"[..];
+  assert_eq!(opt_abcd(a), Ok((&b"ef"[..], Some(&b"abcd"[..]))));
+  assert_eq!(opt_abcd(b), Ok((&b"bcdefg"[..], None)));
+  assert_eq!(opt_abcd(c), Err(Err::Incomplete(Needed::new(2))));
+}
+
+#[test]
+fn peek_test() {
+  fn peek_tag(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    peek(tag("abcd"))(i)
+  }
+
+  assert_eq!(peek_tag(&b"abcdef"[..]), Ok((&b"abcdef"[..], &b"abcd"[..])));
+  assert_eq!(peek_tag(&b"ab"[..]), Err(Err::Incomplete(Needed::new(2))));
+  assert_eq!(
+    peek_tag(&b"xxx"[..]),
+    Err(Err::Error(error_position!(&b"xxx"[..], ErrorKind::Tag)))
+  );
+}
+
+#[test]
+fn not_test() {
+  fn not_aaa(i: &[u8]) -> IResult<&[u8], ()> {
+    not(tag("aaa"))(i)
+  }
+
+  assert_eq!(
+    not_aaa(&b"aaa"[..]),
+    Err(Err::Error(error_position!(&b"aaa"[..], ErrorKind::Not)))
+  );
+  assert_eq!(not_aaa(&b"aa"[..]), Err(Err::Incomplete(Needed::new(1))));
+  assert_eq!(not_aaa(&b"abcd"[..]), Ok((&b"abcd"[..], ())));
+}
+
+#[test]
+fn verify_test() {
+  use crate::bytes::streaming::take;
+
+  fn test(i: &[u8]) -> IResult<&[u8], &[u8]> {
+    verify(take(5u8), |slice: &[u8]| slice[0] == b'a')(i)
+  }
+  assert_eq!(test(&b"bcd"[..]), Err(Err::Incomplete(Needed::new(2))));
+  assert_eq!(
+    test(&b"bcdefg"[..]),
+    Err(Err::Error(error_position!(
+      &b"bcdefg"[..],
+      ErrorKind::Verify
+    )))
+  );
+  assert_eq!(test(&b"abcdefg"[..]), Ok((&b"fg"[..], &b"abcde"[..])));
+}
diff --git a/src/multi/tests.rs b/src/multi/tests.rs
index 8c3a2d0..7976244 100644
--- a/src/multi/tests.rs
+++ b/src/multi/tests.rs
@@ -329,13 +329,17 @@ impl<I> ParseError<I> for NilError {
   }
 }
 
-named!(pub number<u32>, map_res!(
-  map_res!(
-    digit,
-    str::from_utf8
-  ),
-  FromStr::from_str
-));
+fn number(i: &[u8]) -> IResult<&[u8], u32> {
+    use crate::combinator::map_res;
+
+    map_res(
+        map_res(
+            digit,
+            str::from_utf8
+        ),
+        FromStr::from_str
+    )(i)
+}
 
 #[test]
 #[cfg(feature = "alloc")]