1 /*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
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
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>
15 namespace boost { namespace spirit { namespace x3
17 template <typename Left, typename Right>
18 struct sequence : binary_parser<Left, Right, sequence<Left, Right>>
20 typedef binary_parser<Left, Right, sequence<Left, Right>> base_type;
22 sequence(Left const& left, Right const& right)
23 : base_type(left, right) {}
25 template <typename Iterator, typename Context, typename RContext>
27 Iterator& first, Iterator const& last
28 , Context const& context, RContext& rcontext, unused_type) const
30 Iterator save = first;
31 if (this->left.parse(first, last, context, rcontext, unused)
32 && this->right.parse(first, last, context, rcontext, unused))
38 template <typename Iterator, typename Context
39 , typename RContext, typename Attribute>
41 Iterator& first, Iterator const& last
42 , Context const& context, RContext& rcontext, Attribute& attr) const
44 return detail::parse_sequence(*this, first, last, context, rcontext, attr
45 , typename traits::attribute_category<Attribute>::type());
49 template <typename Left, typename Right>
51 typename extension::as_parser<Left>::value_type
52 , typename extension::as_parser<Right>::value_type>
53 operator>>(Left const& left, Right const& right)
55 return { as_parser(left), as_parser(right) };
58 template <typename Left, typename Right>
59 auto operator>(Left const& left, Right const& right)
61 return left >> expect[right];
65 namespace boost { namespace spirit { namespace x3 { namespace traits
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> {};