Back to home page

EIC code displayed by LXR

 
 

    


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

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