]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/spirit/home/x3/operator/list.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / spirit / home / x3 / operator / list.hpp
CommitLineData
7c673cae
FG
1/*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
3 Copyright (c) 2001-2011 Hartmut Kaiser
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7=============================================================================*/
11fdf7f2
TL
8#if !defined(BOOST_SPIRIT_X3_LIST_MARCH_24_2007_1031AM)
9#define BOOST_SPIRIT_X3_LIST_MARCH_24_2007_1031AM
7c673cae
FG
10
11#include <boost/spirit/home/x3/core/parser.hpp>
12#include <boost/spirit/home/x3/support/traits/container_traits.hpp>
13#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
14#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp>
15
16namespace boost { namespace spirit { namespace x3
17{
18 template <typename Left, typename Right>
19 struct list : binary_parser<Left, Right, list<Left, Right>>
20 {
21 typedef binary_parser<Left, Right, list<Left, Right>> base_type;
22 static bool const handles_container = true;
7c673cae 23
f67539c2 24 constexpr list(Left const& left, Right const& right)
7c673cae
FG
25 : base_type(left, right) {}
26
27 template <typename Iterator, typename Context
28 , typename RContext, typename Attribute>
29 bool parse(Iterator& first, Iterator const& last
30 , Context const& context, RContext& rcontext, Attribute& attr) const
31 {
32 // in order to succeed we need to match at least one element
33 if (!detail::parse_into_container(
34 this->left, first, last, context, rcontext, attr))
35 return false;
36
92f5a8d4
TL
37 Iterator iter = first;
38 while (this->right.parse(iter, last, context, rcontext, unused)
7c673cae 39 && detail::parse_into_container(
92f5a8d4 40 this->left, iter, last, context, rcontext, attr))
7c673cae 41 {
92f5a8d4 42 first = iter;
7c673cae
FG
43 }
44
7c673cae
FG
45 return true;
46 }
47 };
48
49 template <typename Left, typename Right>
f67539c2 50 constexpr list<
7c673cae
FG
51 typename extension::as_parser<Left>::value_type
52 , typename extension::as_parser<Right>::value_type>
53 operator%(Left const& left, Right const& right)
54 {
55 return { as_parser(left), as_parser(right) };
56 }
57}}}
58
59namespace boost { namespace spirit { namespace x3 { namespace traits
60{
61 template <typename Left, typename Right, typename Context>
62 struct attribute_of<x3::list<Left, Right>, Context>
63 : traits::build_container<
64 typename attribute_of<Left, Context>::type> {};
1e59de90
TL
65
66 template <typename Left, typename Right, typename Context>
67 struct has_attribute<x3::list<Left, Right>, Context>
68 : has_attribute<Left, Context> {};
7c673cae
FG
69}}}}
70
71#endif