4.4.1
|
|
Freundlich's C++ toolkit |
Tries the left parser, and if that fails also the right parser. Uses the result of the first one that does not fail.
Let l
and r
be parsers and al = alternative{l,r}
. First, al
saves the current position pos
. Then, al
tries the parser l
. If it succeeds, then its result is returned. If it returns a fatal error then this error is returned. Otherwise, al
backtracks to pos
and returns the result of r
.
See fcppt::parse::alternative_result for this parser's result type.
Public Types | |
using | result_type = fcppt::parse::alternative_result< fcppt::parse::result_of< Left >, fcppt::parse::result_of< Right > > |
Public Member Functions | |
alternative (Left &&, Right &&) | |
template<typename Ch , typename Skipper > | |
fcppt::parse::result< Ch, result_type > | parse (fcppt::reference< fcppt::parse::basic_stream< Ch > >, Skipper const &) const |
using fcppt::parse::alternative< Left, Right >::result_type = fcppt::parse:: alternative_result<fcppt::parse::result_of<Left>, fcppt::parse::result_of<Right> > |
fcppt::parse::alternative< Left, Right >::alternative | ( | Left && | , |
Right && | |||
) |
fcppt::parse::result< Ch, result_type > fcppt::parse::alternative< Left, Right >::parse | ( | fcppt::reference< fcppt::parse::basic_stream< Ch > > | , |
Skipper const & | |||
) | const |