Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:51:24

0001 /*=============================================================================
0002     Copyright (c) 2011 Jamboree
0003     Copyright (c) 2014 Lee Clagett
0004     Copyright (c) 2017 wanghan02
0005     Copyright (c) 2024 Nana Sakisaka
0006 
0007     Distributed under the Boost Software License, Version 1.0. (See accompanying
0008     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 ==============================================================================*/
0010 #if !defined(BOOST_SPIRIT_X3_SEEK_APRIL_13_2014_1920PM)
0011 #define BOOST_SPIRIT_X3_SEEK_APRIL_13_2014_1920PM
0012 
0013 #include <boost/spirit/home/x3/core/parser.hpp>
0014 #include <boost/spirit/home/x3/support/expectation.hpp>
0015 
0016 namespace boost { namespace spirit { namespace x3
0017 {
0018     template<typename Subject>
0019     struct seek_directive : unary_parser<Subject, seek_directive<Subject>>
0020     {
0021         typedef unary_parser<Subject, seek_directive<Subject>> base_type;
0022         static bool const is_pass_through_unary = true;
0023         static bool const handles_container = Subject::handles_container;
0024 
0025         constexpr seek_directive(Subject const& subject) :
0026             base_type(subject) {}
0027 
0028         template<typename Iterator, typename Context
0029           , typename RContext, typename Attribute>
0030         bool parse(
0031             Iterator& first, Iterator const& last
0032           , Context const& context, RContext& rcontext, Attribute& attr) const
0033         {
0034             for (Iterator current(first);; ++current)
0035             {
0036                 if (this->subject.parse(current, last, context, rcontext, attr))
0037                 {
0038                     first = current;
0039                     return true;
0040                 }
0041 
0042             #if !BOOST_SPIRIT_X3_THROW_EXPECTATION_FAILURE
0043                 if (has_expectation_failure(context))
0044                 {
0045                     return false;
0046                 }
0047             #endif
0048 
0049                 // fail only after subject fails & no input
0050                 if (current == last)
0051                     return false;
0052             }
0053         }
0054     };
0055 
0056     struct seek_gen
0057     {
0058         template<typename Subject>
0059         constexpr seek_directive<typename extension::as_parser<Subject>::value_type>
0060         operator[](Subject const& subject) const
0061         {
0062             return { as_parser(subject) };
0063         }
0064     };
0065 
0066     constexpr auto seek = seek_gen{};
0067 }}}
0068 
0069 #endif