File indexing completed on 2025-01-31 10:01:54
0001
0002
0003
0004
0005
0006
0007
0008
0009 #if !defined(BOOST_SPIRIT_NO_ACTIONS_HPP)
0010 #define BOOST_SPIRIT_NO_ACTIONS_HPP
0011
0012 #include <boost/spirit/home/classic/core/parser.hpp>
0013 #include <boost/spirit/home/classic/core/composite/composite.hpp>
0014 #include <boost/spirit/home/classic/core/non_terminal/rule.hpp>
0015
0016 namespace boost {
0017 namespace spirit {
0018 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0019
0020
0021
0022
0023 template<typename BaseT = action_policy>
0024 struct no_actions_action_policy:
0025 public BaseT
0026 {
0027 typedef BaseT base_t;
0028
0029 no_actions_action_policy():
0030 BaseT()
0031 {}
0032
0033 template<typename PolicyT>
0034 no_actions_action_policy(PolicyT const& other):
0035 BaseT(other)
0036 {}
0037
0038 template<typename ActorT, typename AttrT, typename IteratorT>
0039 void
0040 do_action(
0041 ActorT const& ,
0042 AttrT& ,
0043 IteratorT const& ,
0044 IteratorT const& ) const
0045 {}
0046 };
0047
0048
0049
0050
0051
0052 namespace detail
0053 {
0054 template <typename ActionPolicy>
0055 struct compute_no_actions_action_policy
0056 {
0057 typedef no_actions_action_policy<ActionPolicy> type;
0058 };
0059
0060 template <typename ActionPolicy>
0061 struct compute_no_actions_action_policy<no_actions_action_policy<ActionPolicy> >
0062 {
0063 typedef no_actions_action_policy<ActionPolicy> type;
0064 };
0065 }
0066
0067 template<typename ScannerT = scanner<> >
0068 struct no_actions_scanner
0069 {
0070 typedef scanner_policies<
0071 typename ScannerT::iteration_policy_t,
0072 typename ScannerT::match_policy_t,
0073 typename detail::compute_no_actions_action_policy<typename ScannerT::action_policy_t>::type
0074 > policies_t;
0075
0076 typedef typename
0077 rebind_scanner_policies<ScannerT, policies_t>::type type;
0078 };
0079
0080 #if BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT > 1
0081
0082 template<typename ScannerT = scanner<> >
0083 struct no_actions_scanner_list
0084 {
0085 typedef
0086 scanner_list<
0087 ScannerT,
0088 typename no_actions_scanner<ScannerT>::type
0089 >
0090 type;
0091 };
0092
0093 #endif
0094
0095
0096
0097
0098 struct no_actions_parser_gen;
0099
0100 template<typename ParserT>
0101 struct no_actions_parser:
0102 public unary<ParserT, parser<no_actions_parser<ParserT> > >
0103 {
0104 typedef no_actions_parser<ParserT> self_t;
0105 typedef unary_parser_category parser_category_t;
0106 typedef no_actions_parser_gen parser_generator_t;
0107 typedef unary<ParserT, parser<self_t> > base_t;
0108
0109 template<typename ScannerT>
0110 struct result
0111 {
0112 typedef typename parser_result<ParserT, ScannerT>::type type;
0113 };
0114
0115 no_actions_parser(ParserT const& p)
0116 : base_t(p)
0117 {}
0118
0119 template<typename ScannerT>
0120 typename result<ScannerT>::type
0121 parse(ScannerT const& scan) const
0122 {
0123 typedef typename no_actions_scanner<ScannerT>::policies_t policies_t;
0124
0125 return this->subject().parse(scan.change_policies(policies_t(scan)));
0126 }
0127 };
0128
0129
0130
0131
0132 struct no_actions_parser_gen
0133 {
0134 template<typename ParserT>
0135 struct result
0136 {
0137 typedef no_actions_parser<ParserT> type;
0138 };
0139
0140 template<typename ParserT>
0141 static no_actions_parser<ParserT>
0142 generate(parser<ParserT> const& subject)
0143 {
0144 return no_actions_parser<ParserT>(subject.derived());
0145 }
0146
0147 template<typename ParserT>
0148 no_actions_parser<ParserT>
0149 operator[](parser<ParserT> const& subject) const
0150 {
0151 return no_actions_parser<ParserT>(subject.derived());
0152 }
0153 };
0154
0155
0156
0157
0158 const no_actions_parser_gen no_actions_d = no_actions_parser_gen();
0159
0160
0161 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0162 }
0163 }
0164
0165 #endif