Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/spirit/home/x3/directive/skip.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 Copyright (c) 2013 Agustin Berge | |
4 | |
5 Distributed under the Boost Software License, Version 1.0. (See accompanying | |
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
7 =============================================================================*/ | |
8 #if !defined(SPIRIT_SKIP_JANUARY_26_2008_0422PM) | |
9 #define SPIRIT_SKIP_JANUARY_26_2008_0422PM | |
10 | |
11 #if defined(_MSC_VER) | |
12 #pragma once | |
13 #endif | |
14 | |
15 #include <boost/spirit/home/x3/support/context.hpp> | |
16 #include <boost/spirit/home/x3/support/unused.hpp> | |
17 #include <boost/spirit/home/x3/core/skip_over.hpp> | |
18 #include <boost/spirit/home/x3/core/parser.hpp> | |
19 #include <boost/utility/enable_if.hpp> | |
20 | |
21 namespace boost { namespace spirit { namespace x3 | |
22 { | |
23 template <typename Subject> | |
24 struct reskip_directive : unary_parser<Subject, reskip_directive<Subject>> | |
25 { | |
26 typedef unary_parser<Subject, reskip_directive<Subject>> base_type; | |
27 static bool const is_pass_through_unary = true; | |
28 static bool const handles_container = Subject::handles_container; | |
29 | |
30 reskip_directive(Subject const& subject) | |
31 : base_type(subject) {} | |
32 | |
33 template <typename Iterator, typename Context | |
34 , typename RContext, typename Attribute> | |
35 typename disable_if<has_skipper<Context>, bool>::type | |
36 parse(Iterator& first, Iterator const& last | |
37 , Context const& context, RContext& rcontext, Attribute& attr) const | |
38 { | |
39 auto const& skipper = | |
40 detail::get_unused_skipper(x3::get<skipper_tag>(context)); | |
41 | |
42 return this->subject.parse( | |
43 first, last | |
44 , make_context<skipper_tag>(skipper, context) | |
45 , rcontext | |
46 , attr); | |
47 } | |
48 template <typename Iterator, typename Context | |
49 , typename RContext, typename Attribute> | |
50 typename enable_if<has_skipper<Context>, bool>::type | |
51 parse(Iterator& first, Iterator const& last | |
52 , Context const& context, RContext& rcontext, Attribute& attr) const | |
53 { | |
54 return this->subject.parse( | |
55 first, last | |
56 , context | |
57 , rcontext | |
58 , attr); | |
59 } | |
60 }; | |
61 | |
62 template <typename Subject, typename Skipper> | |
63 struct skip_directive : unary_parser<Subject, skip_directive<Subject, Skipper>> | |
64 { | |
65 typedef unary_parser<Subject, skip_directive<Subject, Skipper>> base_type; | |
66 static bool const is_pass_through_unary = true; | |
67 static bool const handles_container = Subject::handles_container; | |
68 | |
69 skip_directive(Subject const& subject, Skipper const& skipper) | |
70 : base_type(subject) | |
71 , skipper(skipper) | |
72 {} | |
73 | |
74 template <typename Iterator, typename Context | |
75 , typename RContext, typename Attribute> | |
76 bool parse(Iterator& first, Iterator const& last | |
77 , Context const& context, RContext& rcontext, Attribute& attr) const | |
78 { | |
79 return this->subject.parse( | |
80 first, last | |
81 , make_context<skipper_tag>(skipper, context) | |
82 , rcontext | |
83 , attr); | |
84 } | |
85 | |
86 Skipper const skipper; | |
87 }; | |
88 | |
89 struct reskip_gen | |
90 { | |
91 template <typename Skipper> | |
92 struct skip_gen | |
93 { | |
94 explicit skip_gen(Skipper const& skipper) | |
95 : skipper_(skipper) {} | |
96 | |
97 template <typename Subject> | |
98 skip_directive<typename extension::as_parser<Subject>::value_type, Skipper> | |
99 operator[](Subject const& subject) const | |
100 { | |
101 return {as_parser(subject), skipper_}; | |
102 } | |
103 | |
104 Skipper skipper_; | |
105 }; | |
106 | |
107 template <typename Skipper> | |
108 skip_gen<Skipper> const operator()(Skipper const& skipper) const | |
109 { | |
110 return skip_gen<Skipper>(skipper); | |
111 } | |
112 | |
113 template <typename Subject> | |
114 reskip_directive<typename extension::as_parser<Subject>::value_type> | |
115 operator[](Subject const& subject) const | |
116 { | |
117 return {as_parser(subject)}; | |
118 } | |
119 }; | |
120 | |
121 reskip_gen const skip = reskip_gen(); | |
122 }}} | |
123 | |
124 #endif |