comparison DEPENDENCIES/generic/include/boost/spirit/home/x3/operator/alternative.hpp @ 102:f46d142149f5

Whoops, finish that update
author Chris Cannam
date Mon, 07 Sep 2015 11:13:41 +0100
parents
children
comparison
equal deleted inserted replaced
101:c530137014c0 102:f46d142149f5
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 #if defined(_MSC_VER)
11 #pragma once
12 #endif
13
14 #include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
15 #include <boost/spirit/home/x3/core/parser.hpp>
16 #include <boost/spirit/home/x3/operator/detail/alternative.hpp>
17
18 namespace boost { namespace spirit { namespace x3
19 {
20 template <typename Left, typename Right>
21 struct alternative : binary_parser<Left, Right, alternative<Left, Right>>
22 {
23 typedef binary_parser<Left, Right, alternative<Left, Right>> base_type;
24
25 alternative(Left left, Right right)
26 : base_type(left, right) {}
27
28 template <typename Iterator, typename Context, typename RContext>
29 bool parse(
30 Iterator& first, Iterator const& last
31 , Context const& context, RContext& rcontext, unused_type) const
32 {
33 return this->left.parse(first, last, context, rcontext, unused)
34 || this->right.parse(first, last, context, rcontext, unused);
35 }
36
37 template <typename Iterator, typename Context
38 , typename RContext, typename Attribute>
39 bool parse(
40 Iterator& first, Iterator const& last
41 , Context const& context, RContext& rcontext, Attribute& attr) const
42 {
43 if (detail::parse_alternative(this->left, first, last, context, rcontext, attr))
44 return true;
45 if (detail::parse_alternative(this->right, first, last, context, rcontext, attr))
46 return true;
47 return false;
48 }
49 };
50
51 template <typename Left, typename Right>
52 inline alternative<
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
61 namespace boost { namespace spirit { namespace x3 { namespace traits
62 {
63 template <typename Left, typename Right, typename Context>
64 struct attribute_of<x3::alternative<Left, Right>, Context>
65 : x3::detail::attribute_of_alternative<Left, Right, Context> {};
66 }}}}
67
68 #endif