]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/spirit/home/x3/operator/sequence.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / 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=============================================================================*/
11fdf7f2
TL
7#if !defined(BOOST_SPIRIT_X3_SEQUENCE_JAN_06_2013_1015AM)
8#define BOOST_SPIRIT_X3_SEQUENCE_JAN_06_2013_1015AM
7c673cae 9
20effc67 10#include <boost/spirit/home/x3/support/traits/attribute_of_binary.hpp>
7c673cae
FG
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
20effc67
TL
15#include <boost/fusion/include/deque_fwd.hpp>
16
7c673cae
FG
17namespace boost { namespace spirit { namespace x3
18{
19 template <typename Left, typename Right>
20 struct sequence : binary_parser<Left, Right, sequence<Left, Right>>
21 {
22 typedef binary_parser<Left, Right, sequence<Left, Right>> base_type;
23
f67539c2 24 constexpr sequence(Left const& left, Right const& right)
7c673cae
FG
25 : base_type(left, right) {}
26
27 template <typename Iterator, typename Context, typename RContext>
28 bool parse(
29 Iterator& first, Iterator const& last
30 , Context const& context, RContext& rcontext, unused_type) const
31 {
32 Iterator save = first;
33 if (this->left.parse(first, last, context, rcontext, unused)
34 && this->right.parse(first, last, context, rcontext, unused))
35 return true;
36 first = save;
37 return false;
38 }
39
40 template <typename Iterator, typename Context
41 , typename RContext, typename Attribute>
42 bool parse(
43 Iterator& first, Iterator const& last
44 , Context const& context, RContext& rcontext, Attribute& attr) const
45 {
46 return detail::parse_sequence(*this, first, last, context, rcontext, attr
47 , typename traits::attribute_category<Attribute>::type());
48 }
49 };
50
51 template <typename Left, typename Right>
f67539c2 52 constexpr sequence<
7c673cae
FG
53 typename extension::as_parser<Left>::value_type
54 , typename extension::as_parser<Right>::value_type>
55 operator>>(Left const& left, Right const& right)
56 {
57 return { as_parser(left), as_parser(right) };
58 }
59
60 template <typename Left, typename Right>
f67539c2 61 constexpr auto operator>(Left const& left, Right const& right)
7c673cae
FG
62 {
63 return left >> expect[right];
64 }
65}}}
66
67namespace boost { namespace spirit { namespace x3 { namespace traits
68{
69 template <typename Left, typename Right, typename Context>
70 struct attribute_of<x3::sequence<Left, Right>, Context>
20effc67 71 : x3::detail::attribute_of_binary<fusion::deque, x3::sequence, Left, Right, Context> {};
7c673cae
FG
72}}}}
73
74#endif