Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:56:15

0001 #ifndef BOOST_METAPARSE_V1_KEYWORD_HPP
0002 #define BOOST_METAPARSE_V1_KEYWORD_HPP
0003 
0004 // Copyright Abel Sinkovics (abel@sinkovics.hu)  2009 - 2010.
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/impl/void_.hpp>
0010 #include <boost/metaparse/v1/lit.hpp>
0011 #include <boost/metaparse/v1/return_.hpp>
0012 #include <boost/metaparse/v1/is_error.hpp>
0013 #include <boost/metaparse/v1/get_remaining.hpp>
0014 #include <boost/metaparse/v1/get_position.hpp>
0015 
0016 #include <boost/mpl/if.hpp>
0017 #include <boost/mpl/eval_if.hpp>
0018 #include <boost/mpl/empty.hpp>
0019 #include <boost/mpl/pop_front.hpp>
0020 #include <boost/mpl/front.hpp>
0021 
0022 namespace boost
0023 {
0024   namespace metaparse
0025   {
0026     namespace v1
0027     {
0028       // Does not consume/check anything after the keyword
0029       template <class Kw, class ResultType = impl::void_>
0030       struct keyword
0031       {
0032       private:
0033         struct nonempty
0034         {
0035         private:
0036           typedef lit<typename boost::mpl::front<Kw>::type> next_char_parser;
0037 
0038           typedef
0039             keyword<typename boost::mpl::pop_front<Kw>::type, ResultType>
0040             rest_parser;
0041           
0042           template <class S, class Pos>
0043           struct apply_unchecked :
0044             rest_parser::template apply<
0045               typename get_remaining<
0046                 typename next_char_parser::template apply<S, Pos>
0047               >::type,
0048               typename get_position<
0049                 typename next_char_parser::template apply<S, Pos>
0050               >::type
0051             >
0052           {};
0053         public:
0054           template <class S, class Pos>
0055           struct apply :
0056             boost::mpl::eval_if<
0057               typename is_error<
0058                 typename next_char_parser::template apply<S, Pos>
0059               >::type,
0060               typename next_char_parser::template apply<S, Pos>,
0061               apply_unchecked<S, Pos>
0062             >
0063           {};
0064         };
0065       public:
0066         typedef keyword type;
0067         
0068         template <class S, class Pos>
0069         struct apply :
0070           boost::mpl::if_<
0071             boost::mpl::empty<Kw>,
0072             return_<ResultType>,
0073             nonempty
0074           >::type::template apply<S, Pos>
0075         {};
0076       };
0077     }
0078   }
0079 }
0080 
0081 #endif
0082