Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:50:37

0001 /*=============================================================================
0002     Copyright (c) 2001-2014 Joel de Guzman
0003     Copyright (c) 2001-2011 Hartmut Kaiser
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_LIST_MARCH_24_2007_1031AM)
0011 #define BOOST_SPIRIT_X3_LIST_MARCH_24_2007_1031AM
0012 
0013 #include <boost/spirit/home/x3/core/parser.hpp>
0014 #include <boost/spirit/home/x3/support/traits/container_traits.hpp>
0015 #include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
0016 #include <boost/spirit/home/x3/support/expectation.hpp>
0017 #include <boost/spirit/home/x3/core/detail/parse_into_container.hpp>
0018 
0019 namespace boost { namespace spirit { namespace x3
0020 {
0021     template <typename Left, typename Right>
0022     struct list : binary_parser<Left, Right, list<Left, Right>>
0023     {
0024         typedef binary_parser<Left, Right, list<Left, Right>> base_type;
0025         static bool const handles_container = true;
0026 
0027         constexpr list(Left const& left, Right const& right)
0028           : base_type(left, right) {}
0029 
0030         template <typename Iterator, typename Context
0031           , typename RContext, typename Attribute>
0032         bool parse(Iterator& first, Iterator const& last
0033           , Context const& context, RContext& rcontext, Attribute& attr) const
0034         {
0035             // in order to succeed we need to match at least one element
0036             if (!detail::parse_into_container(
0037                 this->left, first, last, context, rcontext, attr))
0038                 return false;
0039 
0040             Iterator iter = first;
0041             while (this->right.parse(iter, last, context, rcontext, unused)
0042                 && detail::parse_into_container(
0043                     this->left, iter, last, context, rcontext, attr))
0044             {
0045                 first = iter;
0046             }
0047 
0048             return !has_expectation_failure(context);
0049         }
0050     };
0051 
0052     template <typename Left, typename Right>
0053     constexpr list<
0054         typename extension::as_parser<Left>::value_type
0055       , typename extension::as_parser<Right>::value_type>
0056     operator%(Left const& left, Right const& right)
0057     {
0058         return { as_parser(left), as_parser(right) };
0059     }
0060 }}}
0061 
0062 namespace boost { namespace spirit { namespace x3 { namespace traits
0063 {
0064     template <typename Left, typename Right, typename Context>
0065     struct attribute_of<x3::list<Left, Right>, Context>
0066         : traits::build_container<
0067             typename attribute_of<Left, Context>::type> {};
0068 
0069     template <typename Left, typename Right, typename Context>
0070     struct has_attribute<x3::list<Left, Right>, Context>
0071         : has_attribute<Left, Context> {};
0072 }}}}
0073 
0074 #endif