[][src]Macro nom::escaped

macro_rules! escaped {
    ($i:expr, $submac1:ident!( $($args:tt)* ), $control_char: expr, $submac2:ident!( $($args2:tt)*) ) => { ... };
    ($i:expr, $normal:expr, $control_char: expr, $submac2:ident!( $($args2:tt)*) ) => { ... };
    ($i:expr, $submac1:ident!( $($args:tt)* ), $control_char: expr, $escapable:expr ) => { ... };
    ($i:expr, $normal:expr, $control_char: expr, $escapable:expr) => { ... };
}

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

Example

 named!(esc, escaped!(call!(digit1), '\\', one_of!("\"n\\")));
 assert_eq!(esc(&b"123;"[..]), Ok((&b";"[..], &b"123"[..])));
 assert_eq!(esc(&b"12\\\"34;"[..]), Ok((&b";"[..], &b"12\\\"34"[..])));