Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:49

0001 #ifndef BOOST_METAPARSE_V1_FOLDL_REJECT_INCOMPLETE_HPP
0002 #define BOOST_METAPARSE_V1_FOLDL_REJECT_INCOMPLETE_HPP
0003 
0004 // Copyright Abel Sinkovics (abel@sinkovics.hu)  2015.
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #include <boost/metaparse/v1/fail_at_first_char_expected.hpp>
0010 #include <boost/metaparse/v1/is_error.hpp>
0011 #include <boost/metaparse/v1/get_position.hpp>
0012 #include <boost/metaparse/v1/get_result.hpp>
0013 #include <boost/metaparse/v1/get_remaining.hpp>
0014 
0015 #include <boost/mpl/eval_if.hpp>
0016 #include <boost/mpl/equal_to.hpp>
0017 
0018 namespace boost
0019 {
0020   namespace metaparse
0021   {
0022     namespace v1
0023     {
0024       template <class P, class State, class ForwardOp>
0025       struct foldl_reject_incomplete
0026       {
0027       private:
0028         template <class Res>
0029         struct apply_unchecked :
0030           // I need to use apply_wrap, and not apply, because apply would
0031           // build a metafunction class from foldl<P, State, ForwardOp>
0032           // when ForwardOp is a lambda expression.
0033           foldl_reject_incomplete<
0034             P,
0035             typename ForwardOp::template apply<
0036               typename State::type,
0037               typename get_result<Res>::type
0038             >,
0039             ForwardOp
0040           >::template apply<
0041             typename get_remaining<Res>::type,
0042             typename get_position<Res>::type
0043           >
0044         {};
0045 
0046       template <class S, class Pos>
0047       struct accept_state : accept<typename State::type, S, Pos> {};
0048 
0049       template <class S, class Pos>
0050       struct end_of_folding :
0051         boost::mpl::eval_if<
0052           typename boost::mpl::equal_to<
0053             typename Pos::type,
0054             typename get_position<typename P::template apply<S, Pos> >::type
0055           >::type,
0056           accept_state<S, Pos>,
0057           typename P::template apply<S, Pos>
0058         >
0059       {};
0060       public:
0061         typedef foldl_reject_incomplete type;
0062       
0063         template <class S, class Pos>
0064         struct apply :
0065           boost::mpl::eval_if<
0066             typename is_error<typename P::template apply<S, Pos> >::type,
0067             end_of_folding<S, Pos>,
0068             apply_unchecked<typename P::template apply<S, Pos> >
0069           >
0070         {};
0071       };
0072     }
0073   }
0074 }
0075 
0076 #endif
0077