nom::alt_parser! [] [src]

macro_rules! alt_parser (
  ($i:expr, $e:ident | $($rest:tt)*) => (
    alt_parser!($i, call!($e) | $($rest)*);
  );

  ($i:expr, $submac:ident!( $($args:tt)*) | $($rest:tt)*) => (
    {
      if let $crate::IResult::Done(i,o) = $submac!($i, $($args)*) {
        $crate::IResult::Done(i,o)
      } else {
        alt_parser!($i, $($rest)*)
      }
    }
  );

  ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr } | $($rest:tt)+) => (
    {
      if let $crate::IResult::Done(i,o) = $subrule!($i, $($args)*) {
        $crate::IResult::Done(i, $gen( o ))
      } else {
        alt_parser!($i, $($rest)+)
      }
    }
  );

  ($i:expr, $e:ident => { $gen:expr } | $($rest:tt)*) => (
    alt_parser!($i, call!($e) => { $gen } | $($rest)*);
  );

  ($i:expr, $e:ident => { $gen:expr }) => (
    alt_parser!($i, call!($e) => { $gen });
  );

  ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr }) => (
    match $subrule!( $i, $($args)* ) {
      $crate::IResult::Incomplete(x) => $crate::IResult::Incomplete(x),
      $crate::IResult::Error(e)      => $crate::IResult::Error(e),
      $crate::IResult::Done(i,o)     => $crate::IResult::Done(i, $gen( o )),
    }
  );

  ($i:expr, $e:ident) => (
    alt_parser!($i, call!($e));
  );

  ($i:expr, $submac:ident!( $($args:tt)*)) => (
    {
      if let $crate::IResult::Done(i,o) = $submac!($i, $($args)*) {
        $crate::IResult::Done(i,o)
      } else {
        alt_parser!($i)
      }
    }
  );

  ($i:expr) => (
    $crate::IResult::Error($crate::Err::Position($crate::ErrorCode::Alt as u32,$i))
  );
);

Internal parser, do not use directly