File indexing completed on 2025-01-31 10:02:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
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
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
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
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
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
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277 #if !defined(BOOST_SPIRIT_UTILITY_RULE_PARSER_HPP_INCLUDED)
0278 # define BOOST_SPIRIT_UTILITY_RULE_PARSER_HPP_INCLUDED
0279
0280
0281
0282 # include <boost/config.hpp>
0283 # include <boost/detail/workaround.hpp>
0284 # include <boost/call_traits.hpp>
0285 # include <boost/typeof/typeof.hpp>
0286 # include <boost/spirit/home/classic/namespace.hpp>
0287 # include <boost/spirit/home/classic/core/parser.hpp>
0288
0289 # include <boost/preprocessor/cat.hpp>
0290 # include <boost/preprocessor/seq/seq.hpp>
0291 # include <boost/preprocessor/seq/for_each_i.hpp>
0292 # include <boost/preprocessor/tuple/eat.hpp>
0293 # include <boost/preprocessor/tuple/to_seq.hpp>
0294 # include <boost/preprocessor/array/size.hpp>
0295 # include <boost/preprocessor/control/if.hpp>
0296 # include <boost/preprocessor/control/iif.hpp>
0297 # include <boost/preprocessor/control/expr_iif.hpp>
0298 # include <boost/preprocessor/logical/or.hpp>
0299 # include <boost/preprocessor/logical/nor.hpp>
0300 # include <boost/preprocessor/logical/not.hpp>
0301 # include <boost/preprocessor/logical/compl.hpp>
0302 # include <boost/preprocessor/arithmetic/inc.hpp>
0303 # include <boost/preprocessor/arithmetic/dec.hpp>
0304 # include <boost/preprocessor/arithmetic/add.hpp>
0305 # include <boost/preprocessor/detail/is_unary.hpp>
0306 # include <boost/preprocessor/detail/is_binary.hpp>
0307 # include <boost/preprocessor/repetition/repeat.hpp>
0308 # include <boost/preprocessor/repetition/enum_params.hpp>
0309 # include <boost/preprocessor/repetition/enum_binary_params.hpp>
0310 # include <boost/preprocessor/repetition/enum_shifted_params.hpp>
0311 # include <boost/preprocessor/repetition/enum_trailing_params.hpp>
0312 # include <boost/preprocessor/punctuation/comma.hpp>
0313 # include <boost/preprocessor/punctuation/comma_if.hpp>
0314 # include <boost/preprocessor/facilities/empty.hpp>
0315 # include <boost/preprocessor/facilities/identity.hpp>
0316 # include <boost/preprocessor/facilities/intercept.hpp>
0317
0318
0319
0320
0321 # define BOOST_SPIRIT_RULE_PARSER(name,params,actions,members,rule) \
0322 BOOST_SPIRIT_RP_IMPL_I(name,params,actions,members,rule)
0323
0324
0325 # define BOOST_SPIRIT_OPAQUE_RULE_PARSER(name,params,members,rule) \
0326 BOOST_SPIRIT_RP_OPAQUE_IMPL_I(name,params,members,rule)
0327
0328
0329 # define BOOST_SPIRIT_ACTION_PLACEHOLDER(name) \
0330 BOOST_SPIRIT_RP_AP_IMPL(name,::BOOST_SPIRIT_CLASSIC_NS::type_of)
0331
0332
0333 namespace boost
0334 {
0335 namespace spirit
0336 {
0337 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0338
0339 template<class P> class parser_reference;
0340 template<class P> parser_reference<P> embed_by_reference(parser<P> const &);
0341
0342 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0343 }
0344 }
0345
0346
0347
0348 #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
0349
0350
0351
0352
0353 # define BOOST_SPIRIT_RP_REGISTER_TEMPLATE(name,params) \
0354 BOOST_SPIRIT_RP_EMIT(NS_CLOSE,BOOST_SPIRIT__NAMESPACE,-) \
0355 BOOST_TYPEOF_REGISTER_TEMPLATE( \
0356 BOOST_SPIRIT_RP_EMIT(NS_QUALIFY,BOOST_SPIRIT__NAMESPACE,-) name, \
0357 params) \
0358 BOOST_SPIRIT_RP_EMIT(NS_OPEN,BOOST_SPIRIT__NAMESPACE,-)
0359
0360
0361
0362
0363 # define BOOST_SPIRIT_RP_REGISTER_TYPE(name) \
0364 BOOST_SPIRIT_RP_EMIT(NS_CLOSE,BOOST_SPIRIT__NAMESPACE,-) \
0365 BOOST_TYPEOF_REGISTER_TYPE( \
0366 BOOST_SPIRIT_RP_EMIT(NS_QUALIFY,BOOST_SPIRIT__NAMESPACE,-) name ) \
0367 BOOST_SPIRIT_RP_EMIT(NS_OPEN,BOOST_SPIRIT__NAMESPACE,-)
0368
0369
0370
0371
0372 # define BOOST_SPIRIT_RP_AP_IMPL(name,ns) \
0373 namespace __action_placeholder \
0374 { \
0375 struct name \
0376 { \
0377 template<typename Action> \
0378 ns :: action_chain< name, ns :: replace, Action> \
0379 operator=(Action const & __a) const \
0380 { return ns :: action_chain< name, ns :: replace, Action>(__a); } \
0381 \
0382 template<typename Action> \
0383 ns :: action_chain< name, ns :: append, Action> \
0384 operator+=(Action const & __a) const \
0385 { return ns :: action_chain< name, ns :: append, Action> (__a); } \
0386 }; \
0387 } \
0388 __action_placeholder:: name const name = __action_placeholder:: name ();
0389
0390
0391
0392
0393 # define BOOST_SPIRIT_RP_IMPL_I(name,pars,acts,mbrs,expr) \
0394 BOOST_SPIRIT_RP_IMPL_II(name, name ## _t , \
0395 pars, BOOST_SPIRIT_RP_ARRAY_SIZE(pars), \
0396 acts, BOOST_SPIRIT_RP_ARRAY_SIZE(acts), \
0397 mbrs, BOOST_SPIRIT_RP_ARRAY_SIZE(mbrs), expr)
0398
0399
0400 # define BOOST_SPIRIT_RP_IMPL_II(name,name_t,pars,np,acts,na,mbrs,nm,x) \
0401 BOOST_PP_IIF(BOOST_PP_OR(np,na),BOOST_SPIRIT_RP_IMPL_III, \
0402 BOOST_SPIRIT_RP_OPAQUE_IMPL_II) \
0403 (name,name_t,pars,np,acts,na,mbrs,nm,x)
0404
0405
0406
0407
0408 # define BOOST_SPIRIT_RP_IMPL_III(name,name_t,pars,np,acts,na,mbrs,nm,x) \
0409 \
0410 template< BOOST_SPIRIT_RP_TPL_PARAMS(pars,acts,typename __,1) > \
0411 class name_t \
0412 : public ::BOOST_SPIRIT_CLASSIC_NS::parser< name_t \
0413 < BOOST_SPIRIT_RP_TPL_PARAMS(pars,acts,__,0) > > \
0414 { \
0415 class __rule \
0416 { \
0417 BOOST_SPIRIT_RP_EMIT(PM_STATIC,pars,__T) \
0418 BOOST_SPIRIT_RP_EMIT(AP_STATIC,acts,-) \
0419 BOOST_SPIRIT_RP_EMIT(MV_STATIC,mbrs,BOOST_PP_IDENTITY(typename)) \
0420 public: \
0421 BOOST_TYPEOF_NESTED_TYPEDEF_TPL(__expr, \
0422 ::BOOST_SPIRIT_CLASSIC_NS::type_of::depend_on_type<__Dummy>(x) ) \
0423 }; \
0424 \
0425 public: \
0426 \
0427 typedef name_t self_t; \
0428 typedef typename __rule::__expr::type::parser_category_t \
0429 parser_category_t; \
0430 \
0431 BOOST_PP_EXPR_IIF(BOOST_PP_NOR(np,na),typedef self_t const & embed_t;) \
0432 \
0433 protected: \
0434 \
0435 BOOST_SPIRIT_RP_EMIT(MV_NONSTATIC,mbrs,BOOST_PP_IDENTITY(typename)) \
0436 BOOST_SPIRIT_RP_IF(na,SPIRIT_RP_AP_EXTRA_MBRS,2)(np,na) \
0437 \
0438 typename __rule::__expr::type::embed_t __parser; \
0439 \
0440 public: \
0441 \
0442 explicit name_t ( BOOST_SPIRIT_RP_CTOR(PARAMS,pars,np,acts) ) \
0443 : BOOST_SPIRIT_RP_EMIT(MV_CTOR_INIT_LIST,mbrs,-) \
0444 BOOST_PP_COMMA_IF(nm) \
0445 BOOST_SPIRIT_RP_IF(na,SPIRIT_RP_CTOR_COMMA,4)(INIT_LIST,pars,np,acts)\
0446 __parser(x) \
0447 { } \
0448 \
0449 name_t( name_t const & that) \
0450 : BOOST_SPIRIT_RP_EMIT(MV_CTOR_COPY_INIT_LIST,mbrs,that) \
0451 BOOST_PP_COMMA_IF(nm) \
0452 BOOST_SPIRIT_RP_IF(na,SPIRIT_RP_CTOR_COMMA,4) \
0453 (COPY_INIT_LIST,pars,np,acts) \
0454 __parser(that.__parser) \
0455 { } \
0456 \
0457 template<typename Scanner> struct result \
0458 { \
0459 typedef typename ::BOOST_SPIRIT_CLASSIC_NS::parser_result< \
0460 typename __rule::__expr::type, Scanner>::type type; \
0461 }; \
0462 \
0463 template<typename Scanner> \
0464 typename ::BOOST_SPIRIT_CLASSIC_NS::parser_result<self_t, Scanner>::type \
0465 parse(Scanner const & s) const { return __parser.parse(s); } \
0466 \
0467 BOOST_SPIRIT_RP_IF(na,SPIRIT_RP_AP_HANDLER,5) \
0468 (name_t,np,acts,na,::BOOST_SPIRIT_CLASSIC_NS::type_of) \
0469 }; \
0470 \
0471 BOOST_PP_IF(np,BOOST_SPIRIT_RP_GEN_FUNC,BOOST_SPIRIT_RP_GLOB_VAR) \
0472 (name,name_t,np,na) \
0473 BOOST_SPIRIT_RP_REGISTER_TEMPLATE \
0474 (name_t,BOOST_PP_INC(BOOST_PP_ADD(np,na)))
0475
0476
0477
0478 # define BOOST_SPIRIT_RP_OPAQUE_IMPL_I(name,pars,mbrs,expr) \
0479 BOOST_SPIRIT_RP_OPAQUE_IMPL_II(name, name ## _t, \
0480 pars,BOOST_SPIRIT_RP_ARRAY_SIZE(pars),-,-,\
0481 mbrs,BOOST_SPIRIT_RP_ARRAY_SIZE(mbrs),expr)
0482
0483
0484
0485 # define BOOST_SPIRIT_RP_OPAQUE_IMPL_II(name,name_t,pars,np,_1,_2,mbrs,nm,x) \
0486 class name_t; \
0487 \
0488 BOOST_SPIRIT_RP_REGISTER_TYPE(name_t) \
0489 \
0490 class name_t \
0491 : public ::BOOST_SPIRIT_CLASSIC_NS::parser< name_t > \
0492 { \
0493 class __rule \
0494 { \
0495 BOOST_SPIRIT_RP_EMIT(PM_OPAQUE_STATIC,pars,-) \
0496 BOOST_SPIRIT_RP_EMIT(MV_STATIC,mbrs,BOOST_PP_EMPTY) \
0497 public: \
0498 BOOST_TYPEOF_NESTED_TYPEDEF(__expr,x) \
0499 }; \
0500 \
0501 public: \
0502 \
0503 typedef name_t self_t; \
0504 typedef __rule::__expr::type::parser_category_t parser_category_t; \
0505 BOOST_PP_EXPR_IIF(BOOST_PP_NOT(np),typedef self_t const & embed_t;) \
0506 \
0507 protected: \
0508 \
0509 BOOST_SPIRIT_RP_EMIT(MV_NONSTATIC,mbrs,BOOST_PP_EMPTY) \
0510 \
0511 __rule::__expr::type::embed_t __parser; \
0512 \
0513 public: \
0514 \
0515 explicit name_t (BOOST_SPIRIT_RP_EMIT(PM_OPAQUE_CTOR_PARAMS,pars,-)) \
0516 : BOOST_SPIRIT_RP_EMIT(MV_CTOR_INIT_LIST,mbrs,-) \
0517 BOOST_PP_COMMA_IF(nm) __parser(x) \
0518 { } \
0519 \
0520 name_t(name_t const & that) \
0521 : BOOST_SPIRIT_RP_EMIT(MV_CTOR_COPY_INIT_LIST,mbrs,that) \
0522 BOOST_PP_COMMA_IF(nm) __parser(that.__parser) \
0523 { } \
0524 \
0525 template<typename Scanner> struct result \
0526 { \
0527 typedef typename ::BOOST_SPIRIT_CLASSIC_NS::parser_result< \
0528 __rule::__expr::type, Scanner>::type type; \
0529 }; \
0530 \
0531 template<typename Scanner> \
0532 typename ::BOOST_SPIRIT_CLASSIC_NS::parser_result<self_t, Scanner>::type \
0533 parse(Scanner const & s) const { return __parser.parse(s); } \
0534 }; \
0535 \
0536 BOOST_PP_IF(np,BOOST_SPIRIT_RP_GEN_OPAQUE,BOOST_SPIRIT_RP_GLOB_OPAQUE) \
0537 (name,name_t,np,pars)
0538
0539
0540
0541
0542 # define BOOST_SPIRIT_RP_AP_HANDLER(name_t,np,acts,na,ns) \
0543 private: \
0544 template<typename A> struct __rebound_1st \
0545 { \
0546 typedef name_t < void BOOST_PP_ENUM_TRAILING_PARAMS(np,__T) , \
0547 typename ns ::action_concatenator<__A0,A>::type \
0548 BOOST_PP_COMMA_IF(BOOST_PP_DEC(na)) \
0549 BOOST_PP_ENUM_SHIFTED_PARAMS(na,__A) \
0550 > type; \
0551 }; \
0552 \
0553 template<typename X> struct __rebound \
0554 { \
0555 typedef name_t < \
0556 void BOOST_PP_ENUM_TRAILING_PARAMS(np,__T) \
0557 BOOST_SPIRIT_RP_EMIT(AP_REBOUND_TPL_ARGS,acts,X) \
0558 > type; \
0559 }; \
0560 public: \
0561 template<typename A> \
0562 typename __rebound_1st<A>::type const operator[](A const & a) const \
0563 { \
0564 return typename __rebound_1st<A>::type ( \
0565 BOOST_PP_ENUM_PARAMS(np,__p) BOOST_PP_COMMA_IF(np) \
0566 ns ::concatenate_actions(__a0,a) \
0567 BOOST_PP_COMMA_IF(BOOST_PP_DEC(na)) \
0568 BOOST_PP_ENUM_SHIFTED_PARAMS(na,__a) ); \
0569 } \
0570 template<class PH, ns ::action_chain_mode M, typename A> \
0571 typename __rebound< ns ::action_chain<PH,M,A> >::type const \
0572 operator[]( ns ::action_chain<PH,M,A> const & x) const \
0573 { \
0574 return typename __rebound< ns ::action_chain<PH,M,A> >::type ( \
0575 BOOST_PP_ENUM_PARAMS(np,__p) BOOST_PP_COMMA_IF(np) \
0576 BOOST_SPIRIT_RP_EMIT(AP_REBOUND_ARGS,acts,x) ); \
0577 } \
0578 template<class Head, class Tail> \
0579 typename __rebound< ns ::action_chains<Head,Tail> >::type const \
0580 operator[]( ns ::action_chains<Head,Tail> const & x) const \
0581 { \
0582 return typename __rebound< ns ::action_chains<Head,Tail> >::type ( \
0583 BOOST_PP_ENUM_PARAMS(np,__p) BOOST_PP_COMMA_IF(np) \
0584 BOOST_SPIRIT_RP_EMIT(AP_REBOUND_ARGS,acts,x) ); \
0585 }
0586
0587
0588
0589
0590 # define BOOST_SPIRIT_RP_AP_EXTRA_MBRS(np,na) \
0591 private: \
0592 BOOST_PP_REPEAT(np,BOOST_SPIRIT_RP_PM_MBRS,-) \
0593 BOOST_PP_REPEAT(na,BOOST_SPIRIT_RP_AP_MBRS,-)
0594
0595
0596
0597
0598 # define BOOST_SPIRIT_RP_PM_MBRS(z,i,d) __T ## i __p ## i ;
0599
0600
0601
0602
0603 # define BOOST_SPIRIT_RP_AP_MBRS(z,i,d) __A ## i __a ## i ;
0604
0605
0606
0607
0608 # define BOOST_SPIRIT_RP_CTOR(what,pars,np,acts) \
0609 BOOST_SPIRIT_RP_EMIT(PM_CTOR_ ## what,pars,__T) \
0610 BOOST_SPIRIT_RP_EMIT(AP_CTOR_ ## what,acts,np)
0611
0612
0613
0614
0615 # define BOOST_SPIRIT_RP_CTOR_COMMA(what,pars,np,acts) \
0616 BOOST_SPIRIT_RP_CTOR(what,pars,np,acts) ,
0617
0618
0619
0620
0621 # define BOOST_SPIRIT_RP_TPL_PARAMS(pars,acts,prefix,defaults) \
0622 prefix ## Dummy \
0623 BOOST_SPIRIT_RP_EMIT(PM_TEMPLATE_PARAMS,pars,prefix ## T) \
0624 BOOST_SPIRIT_RP_EMIT(AP_TEMPLATE_PARAMS,acts,(prefix ## A,defaults))
0625
0626
0627
0628
0629 # define BOOST_SPIRIT_RP_GEN_FUNC(name,name_t,np,na) \
0630 template< BOOST_PP_ENUM_PARAMS(np,typename T) > \
0631 inline name_t < void BOOST_PP_ENUM_TRAILING_PARAMS(np,T) > \
0632 name( BOOST_PP_ENUM_BINARY_PARAMS(np,T, const & p) ) \
0633 { return name_t < void BOOST_PP_ENUM_TRAILING_PARAMS(np,T) > \
0634 (BOOST_PP_ENUM_PARAMS(np,p) BOOST_PP_ENUM_TRAILING_PARAMS(na, \
0635 ::BOOST_SPIRIT_CLASSIC_NS::type_of::nop_functor() BOOST_PP_INTERCEPT) ); \
0636 }
0637
0638
0639
0640 # define BOOST_SPIRIT_RP_GEN_OPAQUE(name,name_t,np,pars) \
0641 inline name_t name( BOOST_SPIRIT_RP_EMIT(PM_OPAQUE_GEN_PARAMS,pars,p)) \
0642 { return name_t (BOOST_PP_ENUM_PARAMS(np,p)); }
0643
0644
0645
0646
0647
0648 # define BOOST_SPIRIT_RP_GLOB_VAR(name,name_t,np,na) \
0649 static name_t <void> const name = name_t <void>(BOOST_PP_ENUM_PARAMS(na, \
0650 ::BOOST_SPIRIT_CLASSIC_NS::type_of::nop_functor() BOOST_PP_INTERCEPT) );
0651
0652
0653
0654
0655 # define BOOST_SPIRIT_RP_GLOB_OPAQUE(name,name_t,np,pars) \
0656 static name_t const name = name_t () ;
0657
0658
0659
0660
0661
0662
0663 # define BOOST_SPIRIT_RP__NS_OPEN(r,data,i,elem) \
0664 namespace BOOST_SPIRIT_RP_OPTIONAL(elem) {
0665
0666
0667 # define BOOST_SPIRIT_RP__NS_QUALIFY(r,data,i,elem) \
0668 BOOST_SPIRIT_RP_OPTIONAL(elem ::)
0669
0670
0671 # define BOOST_SPIRIT_RP__NS_CLOSE(r,data,i,elem) }
0672
0673
0674
0675
0676 # define BOOST_SPIRIT_RP__PM_STATIC(r,data,i,elem) \
0677 static typename ::boost::call_traits< data ## i >::reference elem ;
0678
0679
0680 # define BOOST_SPIRIT_RP__PM_CTOR_PARAMS(r,data,i,elem) \
0681 BOOST_PP_COMMA_IF(i) \
0682 typename ::boost::call_traits< data ## i >::param_type elem
0683
0684
0685 # define BOOST_SPIRIT_RP__PM_CTOR_ARGS(r,data,i,elem) \
0686 BOOST_PP_COMMA_IF(i) elem
0687
0688
0689 # define BOOST_SPIRIT_RP__PM_CTOR_INIT_LIST(r,data,i,elem) \
0690 BOOST_PP_COMMA_IF(i) __p ## i ( elem )
0691
0692
0693 # define BOOST_SPIRIT_RP__PM_CTOR_COPY_INIT_LIST(r,data,i,elem) \
0694 BOOST_PP_COMMA_IF(i) __p ## i ( that. __p ## i )
0695
0696
0697
0698 # define BOOST_SPIRIT_RP__PM_TEMPLATE_PARAMS(r,data,i,elem) , data ## i
0699
0700
0701
0702
0703 # define BOOST_SPIRIT_RP__PM_OPAQUE_STATIC(r,data,i,elem) \
0704 static ::boost::call_traits< \
0705 BOOST_SPIRIT_RP_TYPE(BOOST_PP_TUPLE_ELEM(2,0,elem)) \
0706 >::reference BOOST_PP_TUPLE_ELEM(2,1,elem) ;
0707
0708
0709 # define BOOST_SPIRIT_RP__PM_OPAQUE_CTOR_PARAMS(r,data,i,elem) \
0710 BOOST_PP_COMMA_IF(i) ::boost::call_traits< \
0711 BOOST_SPIRIT_RP_TYPE(BOOST_PP_TUPLE_ELEM(2,0,elem)) \
0712 >::param_type BOOST_PP_TUPLE_ELEM(2,1,elem)
0713
0714
0715 # define BOOST_SPIRIT_RP__PM_OPAQUE_GEN_PARAMS(r,data,i,elem) \
0716 BOOST_PP_COMMA_IF(i) ::boost::call_traits< \
0717 BOOST_SPIRIT_RP_TYPE(BOOST_PP_TUPLE_ELEM(2,0,elem)) \
0718 >::param_type data ## i
0719
0720
0721
0722
0723 # define BOOST_SPIRIT_RP__MV_NONSTATIC(r,data,i,elem) \
0724 data() BOOST_SPIRIT_RP_TYPE(BOOST_PP_TUPLE_ELEM(3,0,elem)) \
0725 BOOST_PP_TUPLE_ELEM(3,1,elem) ;
0726
0727
0728 # define BOOST_SPIRIT_RP__MV_STATIC(r,data,i,elem) \
0729 static data() ::boost::call_traits< \
0730 data() BOOST_SPIRIT_RP_TYPE(BOOST_PP_TUPLE_ELEM(3,0,elem)) \
0731 >::reference BOOST_PP_TUPLE_ELEM(3,1,elem) ;
0732
0733
0734 # define BOOST_SPIRIT_RP__MV_CTOR_INIT_LIST(r,data,i,elem) \
0735 BOOST_PP_COMMA_IF(i) \
0736 BOOST_PP_TUPLE_ELEM(3,1,elem) BOOST_PP_TUPLE_ELEM(3,2,elem)
0737
0738
0739 # define BOOST_SPIRIT_RP__MV_CTOR_COPY_INIT_LIST(r,data,i,elem) \
0740 BOOST_PP_COMMA_IF(i) \
0741 BOOST_PP_TUPLE_ELEM(3,1,elem) (data . BOOST_PP_TUPLE_ELEM(3,1,elem))
0742
0743
0744
0745
0746 # define BOOST_SPIRIT_RP__AP_STATIC(r,data,i,elem) static __A ## i & elem ;
0747
0748
0749 # define BOOST_SPIRIT_RP__AP_CTOR_PARAMS(r,data,i,elem) \
0750 BOOST_SPIRIT_RP_COMMA_IF_OR(data,i) \
0751 typename ::boost::call_traits< __A ## i >::param_type elem
0752
0753
0754 # define BOOST_SPIRIT_RP__AP_CTOR_ARGS(r,data,i,elem) \
0755 BOOST_SPIRIT_RP_COMMA_IF_OR(data,i) elem
0756
0757
0758 # define BOOST_SPIRIT_RP__AP_CTOR_INIT_LIST(r,data,i,elem) \
0759 BOOST_SPIRIT_RP_COMMA_IF_OR(data,i) __a ## i ( elem )
0760
0761
0762 # define BOOST_SPIRIT_RP__AP_CTOR_COPY_INIT_LIST(r,data,i,elem) \
0763 BOOST_SPIRIT_RP_COMMA_IF_OR(data,i) __a ## i ( that. __a ## i )
0764
0765
0766 # define BOOST_SPIRIT_RP__AP_TEMPLATE_PARAMS(r,data,i,elem) \
0767 , BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2,0,data),i) \
0768 BOOST_PP_EXPR_IIF(BOOST_PP_TUPLE_ELEM(2,1,data), \
0769 = ::BOOST_SPIRIT_CLASSIC_NS::type_of::nop_functor)
0770
0771
0772 # define BOOST_SPIRIT_RP__AP_REBOUND_ARGS(r,data,i,elem) \
0773 BOOST_PP_COMMA_IF(i) \
0774 ::BOOST_SPIRIT_CLASSIC_NS::type_of::get_placeholdee< __action_placeholder:: elem > \
0775 ( __a ## i , data )
0776
0777
0778 # define BOOST_SPIRIT_RP__AP_REBOUND_TPL_ARGS(r,data,i,elem) \
0779 , typename ::BOOST_SPIRIT_CLASSIC_NS::type_of::placeholdee< \
0780 __action_placeholder:: elem , __A ## i, data >::type
0781
0782
0783
0784
0785
0786
0787 # define BOOST_SPIRIT_RP_EMIT(op, array, data) \
0788 BOOST_SPIRIT_RP_ARRAY_FOR_EACH_I(BOOST_SPIRIT_RP__ ## op,data,array)
0789
0790
0791
0792
0793
0794 # define BOOST_SPIRIT_RP_ARRAY_FOR_EACH_I(macro,data,optional_array) \
0795 BOOST_PP_IIF(BOOST_PP_IS_BINARY(optional_array), \
0796 BOOST_SPIRIT_RP_ARRAY_FOR_EACH_I_IMPL, \
0797 BOOST_PP_TUPLE_EAT(3))(macro,data,optional_array)
0798
0799
0800 # define BOOST_SPIRIT_RP_ARRAY_FOR_EACH_I_IMPL(macro,data,array) \
0801 BOOST_SPIRIT_RP_IF(BOOST_PP_ARRAY_SIZE(array),PP_SEQ_FOR_EACH_I,3) \
0802 (macro,data, BOOST_SPIRIT_RP_IF(BOOST_PP_ARRAY_SIZE(array), \
0803 PP_TUPLE_TO_SEQ,2) array)
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816 # define BOOST_SPIRIT_RP_ARRAY_SIZE(optional_array) \
0817 BOOST_PP_IIF(BOOST_PP_IS_BINARY(optional_array), \
0818 BOOST_PP_ARRAY_SIZE, 0 BOOST_PP_TUPLE_EAT(1))(optional_array)
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829 # define BOOST_SPIRIT_RP_OPTIONAL(elem) \
0830 BOOST_PP_EXPR_IIF(BOOST_PP_COMPL(BOOST_PP_IS_UNARY(elem)),elem)
0831
0832
0833
0834
0835
0836 # define BOOST_SPIRIT_RP_COMMA_IF_OR(a,b) \
0837 BOOST_PP_IIF(BOOST_PP_OR(a,b),BOOST_PP_COMMA,BOOST_PP_EMPTY)()
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847 # define BOOST_SPIRIT_RP_IF(cond,name,arity) \
0848 BOOST_PP_IF(cond,BOOST_ ## name,BOOST_PP_TUPLE_EAT(arity))
0849
0850
0851
0852
0853
0854 namespace boost { namespace spirit {
0855
0856 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0857
0858
0859
0860 template<class P> class parser_reference
0861 : public parser< parser_reference<P> >
0862 {
0863 P const & ref_that;
0864 public:
0865 parser_reference(P & that)
0866
0867 : ref_that(that)
0868 { }
0869
0870 typedef parser_reference<P> self_t;
0871 typedef self_t const & embed_t;
0872 typedef typename P::parser_category_t parser_category_t;
0873
0874 template<typename ScannerT> struct result
0875 { typedef typename P::BOOST_NESTED_TEMPLATE result<ScannerT>::type type; };
0876
0877 template<typename ScannerT>
0878 typename result<ScannerT>::type
0879 parse(ScannerT const & scan) const
0880 { return this->ref_that.parse(scan); }
0881 };
0882
0883 template<class P> parser_reference<P>
0884 embed_by_reference(::BOOST_SPIRIT_CLASSIC_NS::parser<P> & p)
0885 { return p; }
0886
0887 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0888
0889 } }
0890
0891 BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::parser_reference, 1)
0892
0893
0894
0895
0896
0897 namespace boost { namespace spirit {
0898
0899 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0900
0901 namespace type_of {
0902
0903
0904
0905 struct nop_functor
0906 {
0907 template<typename T>
0908 bool operator()(T const &) const
0909 { return false; }
0910 template<typename T, typename U>
0911 bool operator()(T const &, U const &) const
0912 { return false; }
0913
0914 typedef bool result_type;
0915 };
0916
0917
0918
0919 template<typename Action1, typename Action2>
0920 class composite_action
0921 {
0922 Action1 fnc_a1;
0923 Action2 fnc_a2;
0924 public:
0925 composite_action(Action1 const & a1, Action2 const & a2)
0926 : fnc_a1(a1), fnc_a2(a2)
0927 { }
0928
0929 template<typename T>
0930 void operator()(T const & inp) const
0931 { fnc_a1(inp); fnc_a2(inp); }
0932
0933 template<typename T, typename U>
0934 void operator()(T const & inp1, U const inp2) const
0935 { fnc_a1(inp1, inp2); fnc_a2(inp1, inp2); }
0936 };
0937
0938
0939
0940 template<typename Action1, typename Action2>
0941 struct action_concatenator
0942 {
0943 typedef composite_action<Action1,Action2> type;
0944
0945 static type concatenate(Action1 const & a1, Action2 const & a2)
0946 { return composite_action<Action1,Action2>(a1,a2); }
0947 };
0948 template<typename Action> struct action_concatenator<nop_functor, Action>
0949 {
0950 typedef Action type;
0951
0952 static type concatenate(nop_functor const &, Action const & a)
0953 { return a; }
0954 };
0955 template<typename Action> struct action_concatenator<Action, nop_functor>
0956 {
0957 typedef Action type;
0958
0959 static type concatenate(Action const & a, nop_functor const &)
0960 { return a; }
0961 };
0962 template<> struct action_concatenator<nop_functor, nop_functor>
0963 {
0964 typedef nop_functor type;
0965
0966 static type concatenate(nop_functor const &, nop_functor const &)
0967 { return nop_functor(); }
0968 };
0969
0970 template<typename Action1, typename Action2>
0971 typename action_concatenator<Action1,Action2>::type
0972 concatenate_actions(Action1 const & a1, Action2 const & a2)
0973 {
0974 return action_concatenator<Action1,Action2>::concatenate(a1,a2);
0975 }
0976
0977
0978
0979 enum action_chain_mode { replace, append };
0980
0981 template<class Placeholder, action_chain_mode Mode, typename Action>
0982 class action_chain
0983 {
0984 Action fnc_action;
0985 public:
0986 action_chain(Action const & a)
0987 : fnc_action(a)
0988 { }
0989
0990 typedef Action action_type;
0991
0992 Action const & action() const { return fnc_action; }
0993 };
0994
0995
0996 template<class PH, action_chain_mode M, typename A1, typename A2>
0997 action_chain<PH, M, typename action_concatenator<A1,A2>::type>
0998 operator, (action_chain<PH,M,A1> const & chain, A2 const & a)
0999 {
1000 return action_chain<PH,M,typename action_concatenator<A1,A2>::type>
1001 ( concatenate_actions(chain.action(), a) );
1002 }
1003
1004
1005 template<class ChainOrChains, class LastChain>
1006 class action_chains
1007 {
1008 ChainOrChains obj_head;
1009 LastChain obj_tail;
1010 public:
1011 action_chains(ChainOrChains const & head, LastChain const & tail)
1012 : obj_head(head), obj_tail(tail)
1013 { }
1014
1015 typedef ChainOrChains head_type;
1016 typedef LastChain tail_type;
1017
1018 head_type const & head() const { return obj_head; }
1019 tail_type const & tail() const { return obj_tail; }
1020 };
1021
1022
1023 template<class Head, class Tail>
1024 action_chains<Head,Tail> make_chain(Head const & h, Tail const & t)
1025 { return action_chains<Head,Tail>(h,t); }
1026
1027 template<class PH1, action_chain_mode M1, typename A1,
1028 class PH2, action_chain_mode M2, typename A2>
1029 action_chains< action_chain<PH1,M1,A1>, action_chain<PH2,M2,A2> >
1030 operator, (action_chain<PH1,M1,A1> const & h,
1031 action_chain<PH2,M2,A2> const & t)
1032 { return make_chain(h,t); }
1033
1034 template<class Head, class Tail,class PH, action_chain_mode M, typename A>
1035 action_chains< action_chains<Head,Tail>, action_chain<PH,M,A> >
1036 operator, (action_chains<Head,Tail> const & h, action_chain<PH,M,A> const & t)
1037 { return make_chain(h,t); }
1038
1039
1040
1041
1042 template<class Placeholder, typename StartAction, class NewChainOrChains>
1043 struct placeholdee
1044 {
1045 typedef StartAction type;
1046
1047 static type get(StartAction const & a, NewChainOrChains const &)
1048 { return a; }
1049 };
1050
1051 template<class Placeholder,
1052 typename StartAction, class NewChainOrChains>
1053 typename placeholdee<Placeholder,StartAction,NewChainOrChains>::type
1054 get_placeholdee(StartAction const & a, NewChainOrChains const & c)
1055 { return placeholdee<Placeholder,StartAction,NewChainOrChains>::get(a,c); }
1056
1057 template<class Placeholder, typename StartAction, class Head, class Tail>
1058 struct placeholdee
1059 < Placeholder, StartAction, action_chains<Head,Tail> >
1060 {
1061 typedef typename placeholdee<Placeholder,
1062 typename placeholdee<Placeholder,StartAction,Head>::type, Tail >::type
1063 type;
1064
1065 static type get(StartAction const & a, action_chains<Head,Tail> const & c)
1066 {
1067 return get_placeholdee<Placeholder>(
1068 get_placeholdee<Placeholder>(a,c.head()), c.tail() );
1069 }
1070 };
1071
1072 template<class Placeholder, typename StartAction, typename A>
1073 struct placeholdee
1074 < Placeholder, StartAction, action_chain<Placeholder,replace,A> >
1075 {
1076 typedef A type;
1077
1078 static type get(StartAction const &,
1079 action_chain<Placeholder,replace,A> const & c)
1080 { return c.action(); }
1081 };
1082
1083 template<class Placeholder, typename StartAction, typename A>
1084 struct placeholdee
1085 < Placeholder, StartAction, action_chain<Placeholder,append,A> >
1086 {
1087 typedef typename action_concatenator<StartAction,A>::type type;
1088
1089 static type get(StartAction const & a,
1090 action_chain<Placeholder,append,A> const & c)
1091 { return concatenate_actions(a,c.action()); }
1092 };
1093
1094 }
1095
1096 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
1097
1098 } }
1099
1100 BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::type_of::nop_functor)
1101 BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::type_of::composite_action,2)
1102
1103
1104
1105
1106
1107 namespace boost { namespace spirit {
1108
1109 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
1110
1111 namespace type_of {
1112
1113
1114
1115 template<typename T, typename X>
1116 X const & depend_on_type(X const & x)
1117 { return x; }
1118
1119
1120
1121
1122
1123 #define BOOST_SPIRIT_RP_TYPE(x) \
1124 ::BOOST_SPIRIT_CLASSIC_NS::type_of::remove_special_fptr \
1125 < ::BOOST_SPIRIT_CLASSIC_NS::type_of::special_result & (*) x >::type
1126
1127 struct special_result;
1128
1129 template<typename T> struct remove_special_fptr { };
1130 template<typename T> struct remove_special_fptr< special_result & (*)(T) >
1131 { typedef T type; };
1132
1133 }
1134
1135 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
1136
1137 } }
1138
1139
1140 #endif
1141
1142