4.6.0
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
fcppt::parse::alternative< Left, Right > Class Template Reference

Detailed Description

template<typename Left, typename Right>
class fcppt::parse::alternative< Left, Right >

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.

Inheritance diagram for fcppt::parse::alternative< Left, Right >:
fcppt::parse::tag

Public Types

using result_type
 

Public Member Functions

 alternative (Left &&, Right &&)
 
template<typename Ch , typename Skipper >
fcppt::parse::result< Ch, result_typeparse (fcppt::reference< fcppt::parse::basic_stream< Ch > >, Skipper const &) const
 

Member Typedef Documentation

◆ result_type

template<typename Left , typename Right >
using fcppt::parse::alternative< Left, Right >::result_type
Initial value:
fcppt::parse::
alternative_result<fcppt::parse::result_of<Left>, fcppt::parse::result_of<Right>>

Constructor & Destructor Documentation

◆ alternative()

template<typename Left , typename Right >
fcppt::parse::alternative< Left, Right >::alternative ( Left && ,
Right &&  )

Member Function Documentation

◆ parse()

template<typename Left , typename Right >
template<typename Ch , typename Skipper >
fcppt::parse::result< Ch, result_type > fcppt::parse::alternative< Left, Right >::parse ( fcppt::reference< fcppt::parse::basic_stream< Ch > > ,
Skipper const &  ) const
nodiscard