Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/spirit/home/x3/operator/difference.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_DIFFERENCE_FEBRUARY_11_2007_1250PM) | |
8 #define SPIRIT_DIFFERENCE_FEBRUARY_11_2007_1250PM | |
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/support/traits/has_attribute.hpp> | |
16 #include <boost/spirit/home/x3/core/parser.hpp> | |
17 | |
18 namespace boost { namespace spirit { namespace x3 | |
19 { | |
20 template <typename Left, typename Right> | |
21 struct difference : binary_parser<Left, Right, difference<Left, Right>> | |
22 { | |
23 typedef binary_parser<Left, Right, difference<Left, Right>> base_type; | |
24 static bool const handles_container = Left::handles_container; | |
25 | |
26 difference(Left const& left, Right const& right) | |
27 : base_type(left, right) {} | |
28 | |
29 template <typename Iterator, typename Context | |
30 , typename RContext, typename Attribute> | |
31 bool parse(Iterator& first, Iterator const& last | |
32 , Context const& context, RContext& rcontext, Attribute& attr) const | |
33 { | |
34 // Try Right first | |
35 Iterator start = first; | |
36 if (this->right.parse(first, last, context, rcontext, unused)) | |
37 { | |
38 // Right succeeds, we fail. | |
39 first = start; | |
40 return false; | |
41 } | |
42 // Right fails, now try Left | |
43 return this->left.parse(first, last, context, rcontext, attr); | |
44 } | |
45 | |
46 template <typename Left_, typename Right_> | |
47 difference<Left_, Right_> | |
48 make(Left_ const& left, Right_ const& right) const | |
49 { | |
50 return difference<Left_, Right_>(left, right); | |
51 } | |
52 }; | |
53 | |
54 template <typename Left, typename Right> | |
55 inline difference< | |
56 typename extension::as_parser<Left>::value_type | |
57 , typename extension::as_parser<Right>::value_type> | |
58 operator-(Left const& left, Right const& right) | |
59 { | |
60 return {as_parser(left), as_parser(right)}; | |
61 } | |
62 }}} | |
63 | |
64 namespace boost { namespace spirit { namespace x3 { namespace traits | |
65 { | |
66 template <typename Left, typename Right, typename Context> | |
67 struct attribute_of<x3::difference<Left, Right>, Context> | |
68 : attribute_of<Left, Context> {}; | |
69 | |
70 template <typename Left, typename Right, typename Context> | |
71 struct has_attribute<x3::difference<Left, Right>, Context> | |
72 : has_attribute<Left, Context> {}; | |
73 }}}} | |
74 | |
75 #endif |