Macro pear::parse_try

source ·
macro_rules! parse_try {
    ([$n:expr; $input:ident; $m:expr; $T:ty] $e:expr) => { ... };
    ([$n:expr; $input:ident; $m:expr; $T:ty] $e:expr => $r:expr) => { ... };
    ([$n:expr; $input:ident; $m:expr; $T:ty] $e:expr => $r:expr => || $f:expr) => { ... };
    ([$n:expr; $input:ident; $m:expr; $T:ty] $pat:ident@$e:expr => $r:expr) => { ... };
}
Expand description

Runs a parser returning Some if it succeeds or None otherwise.

Take a single parser expression as input. Without additional arguments, returns the output in Some on success. If called as parse_try!(parse_expr => result_expr), returns result_expr in Some on success. The result of the parse expression can be pattern-binded as parse_try!(pat@pexpr => rexpr).