File indexing completed on 2025-01-31 10:01:58
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_SPIRIT_REFACTORING_HPP
0009 #define BOOST_SPIRIT_REFACTORING_HPP
0010
0011
0012 #include <boost/static_assert.hpp>
0013 #include <boost/spirit/home/classic/namespace.hpp>
0014 #include <boost/spirit/home/classic/meta/as_parser.hpp>
0015 #include <boost/spirit/home/classic/core/parser.hpp>
0016 #include <boost/spirit/home/classic/core/composite/composite.hpp>
0017 #include <boost/spirit/home/classic/meta/impl/refactoring.ipp>
0018
0019
0020 namespace boost { namespace spirit {
0021
0022 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0023
0024 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
0025 #pragma warning(push)
0026 #pragma warning(disable:4512)
0027 #endif
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 template <typename NestedT = non_nested_refactoring>
0054 class refactor_unary_gen;
0055
0056 template <typename BinaryT, typename NestedT = non_nested_refactoring>
0057 class refactor_unary_parser :
0058 public parser<refactor_unary_parser<BinaryT, NestedT> > {
0059
0060 public:
0061
0062
0063 BOOST_STATIC_ASSERT((
0064 boost::is_convertible<typename BinaryT::parser_category_t,
0065 binary_parser_category>::value
0066 ));
0067
0068 refactor_unary_parser(BinaryT const& binary_, NestedT const& nested_)
0069 : binary(binary_), nested(nested_) {}
0070
0071 typedef refactor_unary_parser<BinaryT, NestedT> self_t;
0072 typedef refactor_unary_gen<NestedT> parser_generator_t;
0073 typedef typename BinaryT::left_t::parser_category_t parser_category_t;
0074
0075 template <typename ScannerT>
0076 typename parser_result<self_t, ScannerT>::type
0077 parse(ScannerT const& scan) const
0078 {
0079 return impl::refactor_unary_type<NestedT>::
0080 parse(*this, scan, binary, nested);
0081 }
0082
0083 private:
0084 typename as_parser<BinaryT>::type::embed_t binary;
0085 typename NestedT::embed_t nested;
0086 };
0087
0088
0089 template <typename NestedT>
0090 class refactor_unary_gen {
0091
0092 public:
0093 typedef refactor_unary_gen<NestedT> embed_t;
0094
0095 refactor_unary_gen(NestedT const& nested_ = non_nested_refactoring())
0096 : nested(nested_) {}
0097
0098 template <typename ParserT>
0099 refactor_unary_parser<ParserT, NestedT>
0100 operator[](parser<ParserT> const& subject) const
0101 {
0102 return refactor_unary_parser<ParserT, NestedT>
0103 (subject.derived(), nested);
0104 }
0105
0106 private:
0107 typename NestedT::embed_t nested;
0108 };
0109
0110 const refactor_unary_gen<> refactor_unary_d = refactor_unary_gen<>();
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 template <typename NestedT = non_nested_refactoring>
0137 class refactor_action_gen;
0138
0139 template <typename BinaryT, typename NestedT = non_nested_refactoring>
0140 class refactor_action_parser :
0141 public parser<refactor_action_parser<BinaryT, NestedT> > {
0142
0143 public:
0144
0145
0146 BOOST_STATIC_ASSERT((
0147 boost::is_convertible<typename BinaryT::parser_category_t,
0148 binary_parser_category>::value
0149 ));
0150
0151 refactor_action_parser(BinaryT const& binary_, NestedT const& nested_)
0152 : binary(binary_), nested(nested_) {}
0153
0154 typedef refactor_action_parser<BinaryT, NestedT> self_t;
0155 typedef refactor_action_gen<NestedT> parser_generator_t;
0156 typedef typename BinaryT::left_t::parser_category_t parser_category_t;
0157
0158 template <typename ScannerT>
0159 typename parser_result<self_t, ScannerT>::type
0160 parse(ScannerT const& scan) const
0161 {
0162 return impl::refactor_action_type<NestedT>::
0163 parse(*this, scan, binary, nested);
0164 }
0165
0166 private:
0167 typename as_parser<BinaryT>::type::embed_t binary;
0168 typename NestedT::embed_t nested;
0169 };
0170
0171
0172 template <typename NestedT>
0173 class refactor_action_gen {
0174
0175 public:
0176 typedef refactor_action_gen<NestedT> embed_t;
0177
0178 refactor_action_gen(NestedT const& nested_ = non_nested_refactoring())
0179 : nested(nested_) {}
0180
0181 template <typename ParserT>
0182 refactor_action_parser<ParserT, NestedT>
0183 operator[](parser<ParserT> const& subject) const
0184 {
0185 return refactor_action_parser<ParserT, NestedT>
0186 (subject.derived(), nested);
0187 }
0188
0189 private:
0190 typename NestedT::embed_t nested;
0191 };
0192
0193 const refactor_action_gen<> refactor_action_d = refactor_action_gen<>();
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218 template <typename NestedT = non_nested_refactoring>
0219 class attach_action_gen;
0220
0221 template <typename ActionT, typename NestedT = non_nested_refactoring>
0222 class attach_action_parser :
0223 public parser<attach_action_parser<ActionT, NestedT> > {
0224
0225 public:
0226
0227
0228 BOOST_STATIC_ASSERT((
0229 boost::is_convertible<typename ActionT::parser_category_t,
0230 action_parser_category>::value
0231 ));
0232
0233 attach_action_parser(ActionT const& actor_, NestedT const& nested_)
0234 : actor(actor_), nested(nested_) {}
0235
0236 typedef attach_action_parser<ActionT, NestedT> self_t;
0237 typedef attach_action_gen<NestedT> parser_generator_t;
0238 typedef typename ActionT::parser_category_t parser_category_t;
0239
0240 template <typename ScannerT>
0241 typename parser_result<self_t, ScannerT>::type
0242 parse(ScannerT const& scan) const
0243 {
0244 return impl::attach_action_type<NestedT>::
0245 parse(*this, scan, actor, nested);
0246 }
0247
0248 private:
0249 typename as_parser<ActionT>::type::embed_t actor;
0250 typename NestedT::embed_t nested;
0251 };
0252
0253
0254 template <typename NestedT>
0255 class attach_action_gen {
0256
0257 public:
0258 typedef attach_action_gen<NestedT> embed_t;
0259
0260 attach_action_gen(NestedT const& nested_ = non_nested_refactoring())
0261 : nested(nested_) {}
0262
0263 template <typename ParserT, typename ActionT>
0264 attach_action_parser<action<ParserT, ActionT>, NestedT>
0265 operator[](action<ParserT, ActionT> const& actor) const
0266 {
0267 return attach_action_parser<action<ParserT, ActionT>, NestedT>
0268 (actor, nested);
0269 }
0270
0271 private:
0272 typename NestedT::embed_t nested;
0273 };
0274
0275 const attach_action_gen<> attach_action_d = attach_action_gen<>();
0276
0277 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
0278 #pragma warning(pop)
0279 #endif
0280
0281
0282 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0283
0284 }}
0285
0286 #endif
0287