]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/spirit/include/boost/spirit/repository/home/qi/directive/confix.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / repository / home / qi / directive / confix.hpp
CommitLineData
7c673cae
FG
1// Copyright (c) 2009 Chris Hoeppler
2//
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#if !defined(BOOST_SPIRIT_REPOSITORY_QI_CONFIX_JUN_22_2009_1041AM)
7#define BOOST_SPIRIT_REPOSITORY_QI_CONFIX_JUN_22_2009_1041AM
8
9#if defined(_MSC_VER)
10#pragma once
11#endif
12
13#include <boost/spirit/home/qi/domain.hpp>
14#include <boost/spirit/home/qi/meta_compiler.hpp>
15#include <boost/spirit/home/qi/auxiliary/lazy.hpp>
16#include <boost/spirit/home/support/common_terminals.hpp>
17#include <boost/spirit/home/support/info.hpp>
18#include <boost/spirit/home/support/unused.hpp>
19#include <boost/spirit/home/qi/detail/attributes.hpp>
20
21#include <boost/spirit/repository/home/support/confix.hpp>
22
23#include <boost/fusion/include/vector.hpp>
24#include <boost/mpl/or.hpp>
25
26///////////////////////////////////////////////////////////////////////////////
27namespace boost { namespace spirit
28{
29 ///////////////////////////////////////////////////////////////////////////
30 // Enablers
31 ///////////////////////////////////////////////////////////////////////////
32
33 // enables confix(..., ...)[]
34 template <typename Prefix, typename Suffix>
35 struct use_directive<qi::domain
36 , terminal_ex<repository::tag::confix, fusion::vector2<Prefix, Suffix> > >
37 : mpl::true_ {};
38
39 // enables *lazy* confix(..., ...)[]
40 template <>
41 struct use_lazy_directive<qi::domain, repository::tag::confix, 2>
42 : mpl::true_ {};
43
44}}
45
46///////////////////////////////////////////////////////////////////////////////
47namespace boost { namespace spirit { namespace repository { namespace qi
48{
49 using repository::confix_type;
50 using repository::confix;
51
52 ///////////////////////////////////////////////////////////////////////////
53 // the confix() generated parser
54 template <typename Subject, typename Prefix, typename Suffix>
55 struct confix_parser
56 : spirit::qi::unary_parser<confix_parser<Subject, Prefix, Suffix> >
57 {
58 typedef Subject subject_type;
59
60 template <typename Context, typename Iterator>
61 struct attribute
62 : traits::attribute_of<subject_type, Context, Iterator>
63 {};
64
65 confix_parser(Subject const& subject, Prefix const& prefix
66 , Suffix const& suffix)
67 : subject(subject), prefix(prefix), suffix(suffix) {}
68
69 template <typename Iterator, typename Context
70 , typename Skipper, typename Attribute>
71 bool parse(Iterator& first, Iterator const& last
72 , Context& context, Skipper const& skipper
73 , Attribute& attr) const
74 {
75 Iterator iter = first;
76
77 if (!(prefix.parse(iter, last, context, skipper, unused) &&
78 subject.parse(iter, last, context, skipper, attr) &&
79 suffix.parse(iter, last, context, skipper, unused)))
80 {
81 return false;
82 }
83
84 first = iter;
85 return true;
86 }
87
88 template <typename Context>
89 info what(Context const& ctx) const
90 {
91 return info("confix", subject.what(ctx));
92 }
93
94 Subject subject;
95 Prefix prefix;
96 Suffix suffix;
97 };
98
99}}}}
100
101///////////////////////////////////////////////////////////////////////////////
102namespace boost { namespace spirit { namespace qi
103{
104 ///////////////////////////////////////////////////////////////////////////
105 // Parser generators: make_xxx function (objects)
106 ///////////////////////////////////////////////////////////////////////////
107
108 // creates confix(..., ...)[] directive
109 template <typename Prefix, typename Suffix, typename Subject
110 , typename Modifiers>
111 struct make_directive<
112 terminal_ex<repository::tag::confix, fusion::vector2<Prefix, Suffix> >
113 , Subject, Modifiers>
114 {
115 typedef typename
116 result_of::compile<qi::domain, Prefix, Modifiers>::type
117 prefix_type;
118 typedef typename
119 result_of::compile<qi::domain, Suffix, Modifiers>::type
120 suffix_type;
121
122 typedef repository::qi::confix_parser<
123 Subject, prefix_type, suffix_type> result_type;
124
125 template <typename Terminal>
126 result_type operator()(Terminal const& term, Subject const& subject
127 , Modifiers const& modifiers) const
128 {
129 return result_type(subject
130 , compile<qi::domain>(fusion::at_c<0>(term.args), modifiers)
131 , compile<qi::domain>(fusion::at_c<1>(term.args), modifiers));
132 }
133 };
134
135}}}
136
137namespace boost { namespace spirit { namespace traits
138{
139 template <typename Subject, typename Prefix, typename Suffix>
140 struct has_semantic_action<
141 repository::qi::confix_parser<Subject, Prefix, Suffix> >
142 : mpl::or_<
143 has_semantic_action<Subject>
144 , has_semantic_action<Prefix>
145 , has_semantic_action<Suffix>
146 > {};
147}}}
148
149#endif
150