Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:02:35

0001 /*=============================================================================
0002     Copyright (c) 2001-2014 Joel de Guzman
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 =============================================================================*/
0007 #if !defined(BOOST_SPIRIT_X3_LEXEME_MARCH_24_2007_0802AM)
0008 #define BOOST_SPIRIT_X3_LEXEME_MARCH_24_2007_0802AM
0009 
0010 #include <boost/spirit/home/x3/support/context.hpp>
0011 #include <boost/spirit/home/x3/support/unused.hpp>
0012 #include <boost/spirit/home/x3/core/skip_over.hpp>
0013 #include <boost/spirit/home/x3/core/parser.hpp>
0014 #include <boost/type_traits/remove_reference.hpp>
0015 #include <boost/utility/enable_if.hpp>
0016 
0017 namespace boost { namespace spirit { namespace x3
0018 {
0019     template <typename Subject>
0020     struct lexeme_directive : unary_parser<Subject, lexeme_directive<Subject>>
0021     {
0022         typedef unary_parser<Subject, lexeme_directive<Subject> > base_type;
0023         static bool const is_pass_through_unary = true;
0024         static bool const handles_container = Subject::handles_container;
0025 
0026         constexpr lexeme_directive(Subject const& subject)
0027           : base_type(subject) {}
0028 
0029         template <typename Iterator, typename Context
0030           , typename RContext, typename Attribute>
0031         typename enable_if<has_skipper<Context>, bool>::type
0032         parse(Iterator& first, Iterator const& last
0033           , Context const& context, RContext& rcontext, Attribute& attr) const
0034         {
0035             x3::skip_over(first, last, context);
0036             auto const& skipper = x3::get<skipper_tag>(context);
0037 
0038             typedef unused_skipper<
0039                 typename remove_reference<decltype(skipper)>::type>
0040             unused_skipper_type;
0041             unused_skipper_type unused_skipper(skipper);
0042 
0043             return this->subject.parse(
0044                 first, last
0045               , make_context<skipper_tag>(unused_skipper, context)
0046               , rcontext
0047               , attr);
0048         }
0049 
0050         template <typename Iterator, typename Context
0051           , typename RContext, typename Attribute>
0052         typename disable_if<has_skipper<Context>, bool>::type
0053         parse(Iterator& first, Iterator const& last
0054           , Context const& context, RContext& rcontext, Attribute& attr) const
0055         {
0056             //  no need to pre-skip if skipper is unused
0057             return this->subject.parse(
0058                 first, last
0059               , context
0060               , rcontext
0061               , attr);
0062         }
0063     };
0064 
0065     struct lexeme_gen
0066     {
0067         template <typename Subject>
0068         constexpr lexeme_directive<typename extension::as_parser<Subject>::value_type>
0069         operator[](Subject const& subject) const
0070         {
0071             return { as_parser(subject) };
0072         }
0073     };
0074 
0075     constexpr auto lexeme = lexeme_gen{};
0076 }}}
0077 
0078 #endif