1/*=============================================================================
2 Copyright (c) 1998-2003 Joel de Guzman
3 Copyright (c) 2003 Vaclav Vesely
4 http://spirit.sourceforge.net/
5
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8=============================================================================*/
9#if !defined(BOOST_SPIRIT_NO_ACTIONS_HPP)
10#define BOOST_SPIRIT_NO_ACTIONS_HPP
11
12#include <boost/spirit/home/classic/core/parser.hpp>
13#include <boost/spirit/home/classic/core/composite/composite.hpp>
14#include <boost/spirit/home/classic/core/non_terminal/rule.hpp>
15
16namespace boost {
17namespace spirit {
18BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
19
20//-----------------------------------------------------------------------------
21// no_actions_action_policy
22
23template<typename BaseT = action_policy>
24struct no_actions_action_policy:
25 public BaseT
26{
27 typedef BaseT base_t;
28
29 no_actions_action_policy():
30 BaseT()
31 {}
32
33 template<typename PolicyT>
34 no_actions_action_policy(PolicyT const& other):
35 BaseT(other)
36 {}
37
38 template<typename ActorT, typename AttrT, typename IteratorT>
39 void
40 do_action(
41 ActorT const& /*actor*/,
42 AttrT& /*val*/,
43 IteratorT const& /*first*/,
44 IteratorT const& /*last*/) const
45 {}
46};
47
48//-----------------------------------------------------------------------------
49// no_actions_scanner
50
51
52namespace detail
53{
54 template <typename ActionPolicy>
55 struct compute_no_actions_action_policy
56 {
57 typedef no_actions_action_policy<ActionPolicy> type;
58 };
59
60 template <typename ActionPolicy>
61 struct compute_no_actions_action_policy<no_actions_action_policy<ActionPolicy> >
62 {
63 typedef no_actions_action_policy<ActionPolicy> type;
64 };
65}
66
67template<typename ScannerT = scanner<> >
68struct no_actions_scanner
69{
70 typedef scanner_policies<
71 typename ScannerT::iteration_policy_t,
72 typename ScannerT::match_policy_t,
73 typename detail::compute_no_actions_action_policy<typename ScannerT::action_policy_t>::type
74 > policies_t;
75
76 typedef typename
77 rebind_scanner_policies<ScannerT, policies_t>::type type;
78};
79
80#if BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1
81
82template<typename ScannerT = scanner<> >
83struct no_actions_scanner_list
84{
85 typedef
86 scanner_list<
87 ScannerT,
88 typename no_actions_scanner<ScannerT>::type
89 >
90 type;
91};
92
93#endif // BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1
94
95//-----------------------------------------------------------------------------
96// no_actions_parser
97
98struct no_actions_parser_gen;
99
100template<typename ParserT>
101struct no_actions_parser:
102 public unary<ParserT, parser<no_actions_parser<ParserT> > >
103{
104 typedef no_actions_parser<ParserT> self_t;
105 typedef unary_parser_category parser_category_t;
106 typedef no_actions_parser_gen parser_generator_t;
107 typedef unary<ParserT, parser<self_t> > base_t;
108
109 template<typename ScannerT>
110 struct result
111 {
112 typedef typename parser_result<ParserT, ScannerT>::type type;
113 };
114
115 no_actions_parser(ParserT const& p)
116 : base_t(p)
117 {}
118
119 template<typename ScannerT>
120 typename result<ScannerT>::type
121 parse(ScannerT const& scan) const
122 {
123 typedef typename no_actions_scanner<ScannerT>::policies_t policies_t;
124
125 return this->subject().parse(scan.change_policies(policies_t(scan)));
126 }
127};
128
129//-----------------------------------------------------------------------------
130// no_actions_parser_gen
131
132struct no_actions_parser_gen
133{
134 template<typename ParserT>
135 struct result
136 {
137 typedef no_actions_parser<ParserT> type;
138 };
139
140 template<typename ParserT>
141 static no_actions_parser<ParserT>
142 generate(parser<ParserT> const& subject)
143 {
144 return no_actions_parser<ParserT>(subject.derived());
145 }
146
147 template<typename ParserT>
148 no_actions_parser<ParserT>
149 operator[](parser<ParserT> const& subject) const
150 {
151 return no_actions_parser<ParserT>(subject.derived());
152 }
153};
154
155//-----------------------------------------------------------------------------
156// no_actions_d
157
158const no_actions_parser_gen no_actions_d = no_actions_parser_gen();
159
160//-----------------------------------------------------------------------------
161BOOST_SPIRIT_CLASSIC_NAMESPACE_END
162} // namespace spirit
163} // namespace boost
164
165#endif // !defined(BOOST_SPIRIT_NO_ACTIONS_HPP)
166

source code of boost/libs/spirit/include/boost/spirit/home/classic/core/composite/no_actions.hpp