Macro nom::alt_complete [] [src]

macro_rules! alt_complete {
    ($i:expr, $e:ident | $($rest:tt)*) => { ... };
    ($i:expr, $subrule:ident!( $($args:tt)*) | $($rest:tt)*) => { ... };
    ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr } | $($rest:tt)+) => { ... };
    ($i:expr, $e:ident => { $gen:expr } | $($rest:tt)*) => { ... };
    ($i:expr, $e:ident => { $gen:expr }) => { ... };
    ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr }) => { ... };
    ($i:expr, $e:ident) => { ... };
    ($i:expr, $subrule:ident!( $($args:tt)*)) => { ... };
}

Is equivalent to the alt! combinator, except that it will not return Incomplete when one of the constituting parsers returns Incomplete. Instead, it will try the next alternative in the chain.

You should use this combinator only if you know you will not receive partial input for the rules you're trying to match (this is almost always the case for parsing programming languages).

alt_complete!(I -> IResult<I,O> | I -> IResult<I,O> | ... | I -> IResult<I,O> ) => I -> IResult<I, O>

All the parsers must have the same return type.

If one of the parsers return Incomplete, alt_complete! will try the next alternative. If there is no other parser left to try, an Error will be returned.

alt_complete!(parser_1 | parser_2 | ... | parser_n)

For more in depth examples, refer to the documentation of alt!