1 /*=============================================================================
2 Copyright (c) 1998-2003 Joel de Guzman
3 Copyright (c) 2003 Vaclav Vesely
4 http://spirit.sourceforge.net/
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
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>
18 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
20 //-----------------------------------------------------------------------------
21 // no_actions_action_policy
23 template<typename BaseT = action_policy>
24 struct no_actions_action_policy:
29 no_actions_action_policy():
33 template<typename PolicyT>
34 no_actions_action_policy(PolicyT const& other):
38 template<typename ActorT, typename AttrT, typename IteratorT>
43 IteratorT const& first,
44 IteratorT const& last) const
48 //-----------------------------------------------------------------------------
54 template <typename ActionPolicy>
55 struct compute_no_actions_action_policy
57 typedef no_actions_action_policy<ActionPolicy> type;
60 template <typename ActionPolicy>
61 struct compute_no_actions_action_policy<no_actions_action_policy<ActionPolicy> >
63 typedef no_actions_action_policy<ActionPolicy> type;
67 template<typename ScannerT = scanner<> >
68 struct no_actions_scanner
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
77 rebind_scanner_policies<ScannerT, policies_t>::type type;
80 #if BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1
82 template<typename ScannerT = scanner<> >
83 struct no_actions_scanner_list
88 typename no_actions_scanner<ScannerT>::type
93 #endif // BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1
95 //-----------------------------------------------------------------------------
98 struct no_actions_parser_gen;
100 template<typename ParserT>
101 struct no_actions_parser:
102 public unary<ParserT, parser<no_actions_parser<ParserT> > >
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;
109 template<typename ScannerT>
112 typedef typename parser_result<ParserT, ScannerT>::type type;
115 no_actions_parser(ParserT const& p)
119 template<typename ScannerT>
120 typename result<ScannerT>::type
121 parse(ScannerT const& scan) const
123 typedef typename no_actions_scanner<ScannerT>::policies_t policies_t;
125 return this->subject().parse(scan.change_policies(policies_t(scan)));
129 //-----------------------------------------------------------------------------
130 // no_actions_parser_gen
132 struct no_actions_parser_gen
134 template<typename ParserT>
137 typedef no_actions_parser<ParserT> type;
140 template<typename ParserT>
141 static no_actions_parser<ParserT>
142 generate(parser<ParserT> const& subject)
144 return no_actions_parser<ParserT>(subject.derived());
147 template<typename ParserT>
148 no_actions_parser<ParserT>
149 operator[](parser<ParserT> const& subject) const
151 return no_actions_parser<ParserT>(subject.derived());
155 //-----------------------------------------------------------------------------
158 const no_actions_parser_gen no_actions_d = no_actions_parser_gen();
160 //-----------------------------------------------------------------------------
161 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
162 } // namespace spirit
165 #endif // !defined(BOOST_SPIRIT_NO_ACTIONS_HPP)