]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/spirit/home/x3/directive/lexeme.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / spirit / home / x3 / directive / lexeme.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_LEXEME_MARCH_24_2007_0802AM)
8 #define SPIRIT_LEXEME_MARCH_24_2007_0802AM
9
10 #include <boost/spirit/home/x3/support/context.hpp>
11 #include <boost/spirit/home/x3/support/unused.hpp>
12 #include <boost/spirit/home/x3/core/skip_over.hpp>
13 #include <boost/spirit/home/x3/core/parser.hpp>
14 #include <boost/type_traits/remove_reference.hpp>
15 #include <boost/utility/enable_if.hpp>
16
17 namespace boost { namespace spirit { namespace x3
18 {
19 template <typename Subject>
20 struct lexeme_directive : unary_parser<Subject, lexeme_directive<Subject>>
21 {
22 typedef unary_parser<Subject, lexeme_directive<Subject> > base_type;
23 static bool const is_pass_through_unary = true;
24 static bool const handles_container = Subject::handles_container;
25
26 lexeme_directive(Subject const& subject)
27 : base_type(subject) {}
28
29 template <typename Iterator, typename Context
30 , typename RContext, typename Attribute>
31 typename enable_if<has_skipper<Context>, bool>::type
32 parse(Iterator& first, Iterator const& last
33 , Context const& context, RContext& rcontext, Attribute& attr) const
34 {
35 x3::skip_over(first, last, context);
36 auto const& skipper = x3::get<skipper_tag>(context);
37
38 typedef unused_skipper<
39 typename remove_reference<decltype(skipper)>::type>
40 unused_skipper_type;
41 unused_skipper_type unused_skipper(skipper);
42
43 return this->subject.parse(
44 first, last
45 , make_context<skipper_tag>(unused_skipper, context)
46 , rcontext
47 , attr);
48 }
49
50 template <typename Iterator, typename Context
51 , typename RContext, typename Attribute>
52 typename disable_if<has_skipper<Context>, bool>::type
53 parse(Iterator& first, Iterator const& last
54 , Context const& context, RContext& rcontext, Attribute& attr) const
55 {
56 // no need to pre-skip if skipper is unused
57 return this->subject.parse(
58 first, last
59 , context
60 , rcontext
61 , attr);
62 }
63 };
64
65 struct lexeme_gen
66 {
67 template <typename Subject>
68 lexeme_directive<typename extension::as_parser<Subject>::value_type>
69 operator[](Subject const& subject) const
70 {
71 return { as_parser(subject) };
72 }
73 };
74
75 auto const lexeme = lexeme_gen{};
76 }}}
77
78 #endif