]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/spirit/include/boost/spirit/home/x3/operator/sequence.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / x3 / operator / sequence.hpp
CommitLineData
7c673cae
FG
1/*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6=============================================================================*/
7#if !defined(SPIRIT_SEQUENCE_JAN_06_2013_1015AM)
8#define SPIRIT_SEQUENCE_JAN_06_2013_1015AM
9
10#include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
11#include <boost/spirit/home/x3/core/parser.hpp>
12#include <boost/spirit/home/x3/operator/detail/sequence.hpp>
13#include <boost/spirit/home/x3/directive/expect.hpp>
14
15namespace boost { namespace spirit { namespace x3
16{
17 template <typename Left, typename Right>
18 struct sequence : binary_parser<Left, Right, sequence<Left, Right>>
19 {
20 typedef binary_parser<Left, Right, sequence<Left, Right>> base_type;
21
22 sequence(Left const& left, Right const& right)
23 : base_type(left, right) {}
24
25 template <typename Iterator, typename Context, typename RContext>
26 bool parse(
27 Iterator& first, Iterator const& last
28 , Context const& context, RContext& rcontext, unused_type) const
29 {
30 Iterator save = first;
31 if (this->left.parse(first, last, context, rcontext, unused)
32 && this->right.parse(first, last, context, rcontext, unused))
33 return true;
34 first = save;
35 return false;
36 }
37
38 template <typename Iterator, typename Context
39 , typename RContext, typename Attribute>
40 bool parse(
41 Iterator& first, Iterator const& last
42 , Context const& context, RContext& rcontext, Attribute& attr) const
43 {
44 return detail::parse_sequence(*this, first, last, context, rcontext, attr
45 , typename traits::attribute_category<Attribute>::type());
46 }
47 };
48
49 template <typename Left, typename Right>
50 inline sequence<
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 template <typename Left, typename Right>
59 auto operator>(Left const& left, Right const& right)
60 {
61 return left >> expect[right];
62 }
63}}}
64
65namespace boost { namespace spirit { namespace x3 { namespace traits
66{
67 template <typename Left, typename Right, typename Context>
68 struct attribute_of<x3::sequence<Left, Right>, Context>
69 : x3::detail::attribute_of_sequence<Left, Right, Context> {};
70}}}}
71
72#endif