]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/x3/auxiliary/eps.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / x3 / auxiliary / eps.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(BOOST_SPIRIT_X3_EPS_MARCH_23_2007_0454PM)
8 #define BOOST_SPIRIT_X3_EPS_MARCH_23_2007_0454PM
9
10 #include <boost/spirit/home/x3/core/skip_over.hpp>
11 #include <boost/spirit/home/x3/core/parser.hpp>
12 #include <boost/spirit/home/x3/support/unused.hpp>
13
14 namespace boost { namespace spirit { namespace x3
15 {
16 struct rule_context_tag;
17
18 struct semantic_predicate : parser<semantic_predicate>
19 {
20 typedef unused_type attribute_type;
21 static bool const has_attribute = false;
22
23 semantic_predicate(bool predicate)
24 : predicate(predicate) {}
25
26 template <typename Iterator, typename Context, typename Attribute>
27 bool parse(Iterator& first, Iterator const& last
28 , Context const& context, unused_type, Attribute&) const
29 {
30 x3::skip_over(first, last, context);
31 return predicate;
32 }
33
34 bool predicate;
35 };
36
37 template <typename F>
38 struct lazy_semantic_predicate : parser<lazy_semantic_predicate<F>>
39 {
40 typedef unused_type attribute_type;
41 static bool const has_attribute = false;
42
43 lazy_semantic_predicate(F f)
44 : f(f) {}
45
46 template <typename Iterator, typename Context, typename Attribute>
47 bool parse(Iterator& first, Iterator const& last
48 , Context const& context, unused_type, Attribute& attr) const
49 {
50 x3::skip_over(first, last, context);
51 return f(x3::get<rule_context_tag>(context));
52 }
53
54 F f;
55 };
56
57 struct eps_parser : parser<eps_parser>
58 {
59 typedef unused_type attribute_type;
60 static bool const has_attribute = false;
61
62 template <typename Iterator, typename Context
63 , typename RuleContext, typename Attribute>
64 bool parse(Iterator& first, Iterator const& last
65 , Context const& context, RuleContext&, Attribute&) const
66 {
67 x3::skip_over(first, last, context);
68 return true;
69 }
70
71 inline semantic_predicate operator()(bool predicate) const
72 {
73 return { predicate };
74 }
75
76 template <typename F>
77 lazy_semantic_predicate<F> operator()(F f) const
78 {
79 return { f };
80 }
81 };
82
83 auto const eps = eps_parser{};
84 }}}
85
86 #endif