]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/x3/operator/alternative.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / x3 / operator / alternative.hpp
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_ALTERNATIVE_JAN_07_2013_1131AM)
8 #define SPIRIT_ALTERNATIVE_JAN_07_2013_1131AM
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/alternative.hpp>
13
14 namespace boost { namespace spirit { namespace x3
15 {
16 template <typename Left, typename Right>
17 struct alternative : binary_parser<Left, Right, alternative<Left, Right>>
18 {
19 typedef binary_parser<Left, Right, alternative<Left, Right>> base_type;
20
21 alternative(Left const& left, Right const& right)
22 : base_type(left, right) {}
23
24 template <typename Iterator, typename Context, typename RContext>
25 bool parse(
26 Iterator& first, Iterator const& last
27 , Context const& context, RContext& rcontext, unused_type) const
28 {
29 return this->left.parse(first, last, context, rcontext, unused)
30 || this->right.parse(first, last, context, rcontext, unused);
31 }
32
33 template <typename Iterator, typename Context
34 , typename RContext, typename Attribute>
35 bool parse(
36 Iterator& first, Iterator const& last
37 , Context const& context, RContext& rcontext, Attribute& attr) const
38 {
39 return detail::parse_alternative(this->left, first, last, context, rcontext, attr)
40 || detail::parse_alternative(this->right, first, last, context, rcontext, attr);
41 }
42 };
43
44 template <typename Left, typename Right>
45 inline alternative<
46 typename extension::as_parser<Left>::value_type
47 , typename extension::as_parser<Right>::value_type>
48 operator|(Left const& left, Right const& right)
49 {
50 return { as_parser(left), as_parser(right) };
51 }
52 }}}
53
54 namespace boost { namespace spirit { namespace x3 { namespace traits
55 {
56 template <typename Left, typename Right, typename Context>
57 struct attribute_of<x3::alternative<Left, Right>, Context>
58 : x3::detail::attribute_of_alternative<Left, Right, Context> {};
59 }}}}
60
61 #endif