12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142 |
- #if !defined(BOOST_SPIRIT_UTILITY_RULE_PARSER_HPP_INCLUDED)
- # define BOOST_SPIRIT_UTILITY_RULE_PARSER_HPP_INCLUDED
- # include <boost/config.hpp>
- # include <boost/detail/workaround.hpp>
- # include <boost/call_traits.hpp>
- # include <boost/typeof/typeof.hpp>
- # include <boost/spirit/home/classic/namespace.hpp>
- # include <boost/spirit/home/classic/core/parser.hpp>
- # include <boost/preprocessor/cat.hpp>
- # include <boost/preprocessor/seq/seq.hpp>
- # include <boost/preprocessor/seq/for_each_i.hpp>
- # include <boost/preprocessor/tuple/eat.hpp>
- # include <boost/preprocessor/tuple/to_seq.hpp>
- # include <boost/preprocessor/array/size.hpp>
- # include <boost/preprocessor/control/if.hpp>
- # include <boost/preprocessor/control/iif.hpp>
- # include <boost/preprocessor/control/expr_iif.hpp>
- # include <boost/preprocessor/logical/or.hpp>
- # include <boost/preprocessor/logical/nor.hpp>
- # include <boost/preprocessor/logical/not.hpp>
- # include <boost/preprocessor/logical/compl.hpp>
- # include <boost/preprocessor/arithmetic/inc.hpp>
- # include <boost/preprocessor/arithmetic/dec.hpp>
- # include <boost/preprocessor/arithmetic/add.hpp>
- # include <boost/preprocessor/detail/is_unary.hpp>
- # include <boost/preprocessor/detail/is_binary.hpp>
- # include <boost/preprocessor/repetition/repeat.hpp>
- # include <boost/preprocessor/repetition/enum_params.hpp>
- # include <boost/preprocessor/repetition/enum_binary_params.hpp>
- # include <boost/preprocessor/repetition/enum_shifted_params.hpp>
- # include <boost/preprocessor/repetition/enum_trailing_params.hpp>
- # include <boost/preprocessor/punctuation/comma.hpp>
- # include <boost/preprocessor/punctuation/comma_if.hpp>
- # include <boost/preprocessor/facilities/empty.hpp>
- # include <boost/preprocessor/facilities/identity.hpp>
- # include <boost/preprocessor/facilities/intercept.hpp>
- # define BOOST_SPIRIT_RULE_PARSER(name,params,actions,members,rule) \
- BOOST_SPIRIT_RP_IMPL_I(name,params,actions,members,rule)
- # define BOOST_SPIRIT_OPAQUE_RULE_PARSER(name,params,members,rule) \
- BOOST_SPIRIT_RP_OPAQUE_IMPL_I(name,params,members,rule)
- # define BOOST_SPIRIT_ACTION_PLACEHOLDER(name) \
- BOOST_SPIRIT_RP_AP_IMPL(name,::BOOST_SPIRIT_CLASSIC_NS::type_of)
- namespace boost
- {
- namespace spirit
- {
- BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
- template<class P> class parser_reference;
- template<class P> parser_reference<P> embed_by_reference(parser<P> const &);
- BOOST_SPIRIT_CLASSIC_NAMESPACE_END
- }
- }
- #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
- # define BOOST_SPIRIT_RP_REGISTER_TEMPLATE(name,params) \
- BOOST_SPIRIT_RP_EMIT(NS_CLOSE,BOOST_SPIRIT__NAMESPACE,-) \
- BOOST_TYPEOF_REGISTER_TEMPLATE( \
- BOOST_SPIRIT_RP_EMIT(NS_QUALIFY,BOOST_SPIRIT__NAMESPACE,-) name, \
- params) \
- BOOST_SPIRIT_RP_EMIT(NS_OPEN,BOOST_SPIRIT__NAMESPACE,-)
- # define BOOST_SPIRIT_RP_REGISTER_TYPE(name) \
- BOOST_SPIRIT_RP_EMIT(NS_CLOSE,BOOST_SPIRIT__NAMESPACE,-) \
- BOOST_TYPEOF_REGISTER_TYPE( \
- BOOST_SPIRIT_RP_EMIT(NS_QUALIFY,BOOST_SPIRIT__NAMESPACE,-) name ) \
- BOOST_SPIRIT_RP_EMIT(NS_OPEN,BOOST_SPIRIT__NAMESPACE,-)
- # define BOOST_SPIRIT_RP_AP_IMPL(name,ns) \
- namespace __action_placeholder \
- { \
- struct name \
- { \
- template<typename Action> \
- ns :: action_chain< name, ns :: replace, Action> \
- operator=(Action const & __a) const \
- { return ns :: action_chain< name, ns :: replace, Action>(__a); } \
- \
- template<typename Action> \
- ns :: action_chain< name, ns :: append, Action> \
- operator+=(Action const & __a) const \
- { return ns :: action_chain< name, ns :: append, Action> (__a); } \
- }; \
- } \
- __action_placeholder:: name const name = __action_placeholder:: name ();
- # define BOOST_SPIRIT_RP_IMPL_I(name,pars,acts,mbrs,expr) \
- BOOST_SPIRIT_RP_IMPL_II(name, name ## _t , \
- pars, BOOST_SPIRIT_RP_ARRAY_SIZE(pars), \
- acts, BOOST_SPIRIT_RP_ARRAY_SIZE(acts), \
- mbrs, BOOST_SPIRIT_RP_ARRAY_SIZE(mbrs), expr)
- # define BOOST_SPIRIT_RP_IMPL_II(name,name_t,pars,np,acts,na,mbrs,nm,x) \
- BOOST_PP_IIF(BOOST_PP_OR(np,na),BOOST_SPIRIT_RP_IMPL_III, \
- BOOST_SPIRIT_RP_OPAQUE_IMPL_II) \
- (name,name_t,pars,np,acts,na,mbrs,nm,x)
- # define BOOST_SPIRIT_RP_IMPL_III(name,name_t,pars,np,acts,na,mbrs,nm,x) \
- \
- template< BOOST_SPIRIT_RP_TPL_PARAMS(pars,acts,typename __,1) > \
- class name_t \
- : public ::BOOST_SPIRIT_CLASSIC_NS::parser< name_t \
- < BOOST_SPIRIT_RP_TPL_PARAMS(pars,acts,__,0) > > \
- { \
- class __rule \
- { \
- BOOST_SPIRIT_RP_EMIT(PM_STATIC,pars,__T) \
- BOOST_SPIRIT_RP_EMIT(AP_STATIC,acts,-) \
- BOOST_SPIRIT_RP_EMIT(MV_STATIC,mbrs,BOOST_PP_IDENTITY(typename)) \
- public: \
- BOOST_TYPEOF_NESTED_TYPEDEF_TPL(__expr, \
- ::BOOST_SPIRIT_CLASSIC_NS::type_of::depend_on_type<__Dummy>(x) ) \
- }; \
- \
- public: \
- \
- typedef name_t self_t; \
- typedef typename __rule::__expr::type::parser_category_t \
- parser_category_t; \
- \
- BOOST_PP_EXPR_IIF(BOOST_PP_NOR(np,na),typedef self_t const & embed_t;) \
- \
- protected: \
- \
- BOOST_SPIRIT_RP_EMIT(MV_NONSTATIC,mbrs,BOOST_PP_IDENTITY(typename)) \
- BOOST_SPIRIT_RP_IF(na,SPIRIT_RP_AP_EXTRA_MBRS,2)(np,na) \
- \
- typename __rule::__expr::type::embed_t __parser; \
- \
- public: \
- \
- explicit name_t ( BOOST_SPIRIT_RP_CTOR(PARAMS,pars,np,acts) ) \
- : BOOST_SPIRIT_RP_EMIT(MV_CTOR_INIT_LIST,mbrs,-) \
- BOOST_PP_COMMA_IF(nm) \
- BOOST_SPIRIT_RP_IF(na,SPIRIT_RP_CTOR_COMMA,4)(INIT_LIST,pars,np,acts)\
- __parser(x) \
- { } \
- \
- name_t( name_t const & that) \
- : BOOST_SPIRIT_RP_EMIT(MV_CTOR_COPY_INIT_LIST,mbrs,that) \
- BOOST_PP_COMMA_IF(nm) \
- BOOST_SPIRIT_RP_IF(na,SPIRIT_RP_CTOR_COMMA,4) \
- (COPY_INIT_LIST,pars,np,acts) \
- __parser(that.__parser) \
- { } \
- \
- template<typename Scanner> struct result \
- { \
- typedef typename ::BOOST_SPIRIT_CLASSIC_NS::parser_result< \
- typename __rule::__expr::type, Scanner>::type type; \
- }; \
- \
- template<typename Scanner> \
- typename ::BOOST_SPIRIT_CLASSIC_NS::parser_result<self_t, Scanner>::type \
- parse(Scanner const & s) const { return __parser.parse(s); } \
- \
- BOOST_SPIRIT_RP_IF(na,SPIRIT_RP_AP_HANDLER,5) \
- (name_t,np,acts,na,::BOOST_SPIRIT_CLASSIC_NS::type_of) \
- }; \
- \
- BOOST_PP_IF(np,BOOST_SPIRIT_RP_GEN_FUNC,BOOST_SPIRIT_RP_GLOB_VAR) \
- (name,name_t,np,na) \
- BOOST_SPIRIT_RP_REGISTER_TEMPLATE \
- (name_t,BOOST_PP_INC(BOOST_PP_ADD(np,na)))
- # define BOOST_SPIRIT_RP_OPAQUE_IMPL_I(name,pars,mbrs,expr) \
- BOOST_SPIRIT_RP_OPAQUE_IMPL_II(name, name ## _t, \
- pars,BOOST_SPIRIT_RP_ARRAY_SIZE(pars),-,-,\
- mbrs,BOOST_SPIRIT_RP_ARRAY_SIZE(mbrs),expr)
- # define BOOST_SPIRIT_RP_OPAQUE_IMPL_II(name,name_t,pars,np,_1,_2,mbrs,nm,x) \
- class name_t; \
- \
- BOOST_SPIRIT_RP_REGISTER_TYPE(name_t) \
- \
- class name_t \
- : public ::BOOST_SPIRIT_CLASSIC_NS::parser< name_t > \
- { \
- class __rule \
- { \
- BOOST_SPIRIT_RP_EMIT(PM_OPAQUE_STATIC,pars,-) \
- BOOST_SPIRIT_RP_EMIT(MV_STATIC,mbrs,BOOST_PP_EMPTY) \
- public: \
- BOOST_TYPEOF_NESTED_TYPEDEF(__expr,x) \
- }; \
- \
- public: \
- \
- typedef name_t self_t; \
- typedef __rule::__expr::type::parser_category_t parser_category_t; \
- BOOST_PP_EXPR_IIF(BOOST_PP_NOT(np),typedef self_t const & embed_t;) \
- \
- protected: \
- \
- BOOST_SPIRIT_RP_EMIT(MV_NONSTATIC,mbrs,BOOST_PP_EMPTY) \
- \
- __rule::__expr::type::embed_t __parser; \
- \
- public: \
- \
- explicit name_t (BOOST_SPIRIT_RP_EMIT(PM_OPAQUE_CTOR_PARAMS,pars,-)) \
- : BOOST_SPIRIT_RP_EMIT(MV_CTOR_INIT_LIST,mbrs,-) \
- BOOST_PP_COMMA_IF(nm) __parser(x) \
- { } \
- \
- name_t(name_t const & that) \
- : BOOST_SPIRIT_RP_EMIT(MV_CTOR_COPY_INIT_LIST,mbrs,that) \
- BOOST_PP_COMMA_IF(nm) __parser(that.__parser) \
- { } \
- \
- template<typename Scanner> struct result \
- { \
- typedef typename ::BOOST_SPIRIT_CLASSIC_NS::parser_result< \
- __rule::__expr::type, Scanner>::type type; \
- }; \
- \
- template<typename Scanner> \
- typename ::BOOST_SPIRIT_CLASSIC_NS::parser_result<self_t, Scanner>::type \
- parse(Scanner const & s) const { return __parser.parse(s); } \
- }; \
- \
- BOOST_PP_IF(np,BOOST_SPIRIT_RP_GEN_OPAQUE,BOOST_SPIRIT_RP_GLOB_OPAQUE) \
- (name,name_t,np,pars)
- # define BOOST_SPIRIT_RP_AP_HANDLER(name_t,np,acts,na,ns) \
- private: \
- template<typename A> struct __rebound_1st \
- { \
- typedef name_t < void BOOST_PP_ENUM_TRAILING_PARAMS(np,__T) , \
- typename ns ::action_concatenator<__A0,A>::type \
- BOOST_PP_COMMA_IF(BOOST_PP_DEC(na)) \
- BOOST_PP_ENUM_SHIFTED_PARAMS(na,__A) \
- > type; \
- }; \
- \
- template<typename X> struct __rebound \
- { \
- typedef name_t < \
- void BOOST_PP_ENUM_TRAILING_PARAMS(np,__T) \
- BOOST_SPIRIT_RP_EMIT(AP_REBOUND_TPL_ARGS,acts,X) \
- > type; \
- }; \
- public: \
- template<typename A> \
- typename __rebound_1st<A>::type const operator[](A const & a) const \
- { \
- return typename __rebound_1st<A>::type ( \
- BOOST_PP_ENUM_PARAMS(np,__p) BOOST_PP_COMMA_IF(np) \
- ns ::concatenate_actions(__a0,a) \
- BOOST_PP_COMMA_IF(BOOST_PP_DEC(na)) \
- BOOST_PP_ENUM_SHIFTED_PARAMS(na,__a) ); \
- } \
- template<class PH, ns ::action_chain_mode M, typename A> \
- typename __rebound< ns ::action_chain<PH,M,A> >::type const \
- operator[]( ns ::action_chain<PH,M,A> const & x) const \
- { \
- return typename __rebound< ns ::action_chain<PH,M,A> >::type ( \
- BOOST_PP_ENUM_PARAMS(np,__p) BOOST_PP_COMMA_IF(np) \
- BOOST_SPIRIT_RP_EMIT(AP_REBOUND_ARGS,acts,x) ); \
- } \
- template<class Head, class Tail> \
- typename __rebound< ns ::action_chains<Head,Tail> >::type const \
- operator[]( ns ::action_chains<Head,Tail> const & x) const \
- { \
- return typename __rebound< ns ::action_chains<Head,Tail> >::type ( \
- BOOST_PP_ENUM_PARAMS(np,__p) BOOST_PP_COMMA_IF(np) \
- BOOST_SPIRIT_RP_EMIT(AP_REBOUND_ARGS,acts,x) ); \
- }
- # define BOOST_SPIRIT_RP_AP_EXTRA_MBRS(np,na) \
- private: \
- BOOST_PP_REPEAT(np,BOOST_SPIRIT_RP_PM_MBRS,-) \
- BOOST_PP_REPEAT(na,BOOST_SPIRIT_RP_AP_MBRS,-)
- # define BOOST_SPIRIT_RP_PM_MBRS(z,i,d) __T ## i __p ## i ;
- # define BOOST_SPIRIT_RP_AP_MBRS(z,i,d) __A ## i __a ## i ;
- # define BOOST_SPIRIT_RP_CTOR(what,pars,np,acts) \
- BOOST_SPIRIT_RP_EMIT(PM_CTOR_ ## what,pars,__T) \
- BOOST_SPIRIT_RP_EMIT(AP_CTOR_ ## what,acts,np)
- # define BOOST_SPIRIT_RP_CTOR_COMMA(what,pars,np,acts) \
- BOOST_SPIRIT_RP_CTOR(what,pars,np,acts) ,
- # define BOOST_SPIRIT_RP_TPL_PARAMS(pars,acts,prefix,defaults) \
- prefix ## Dummy \
- BOOST_SPIRIT_RP_EMIT(PM_TEMPLATE_PARAMS,pars,prefix ## T) \
- BOOST_SPIRIT_RP_EMIT(AP_TEMPLATE_PARAMS,acts,(prefix ## A,defaults))
- # define BOOST_SPIRIT_RP_GEN_FUNC(name,name_t,np,na) \
- template< BOOST_PP_ENUM_PARAMS(np,typename T) > \
- inline name_t < void BOOST_PP_ENUM_TRAILING_PARAMS(np,T) > \
- name( BOOST_PP_ENUM_BINARY_PARAMS(np,T, const & p) ) \
- { return name_t < void BOOST_PP_ENUM_TRAILING_PARAMS(np,T) > \
- (BOOST_PP_ENUM_PARAMS(np,p) BOOST_PP_ENUM_TRAILING_PARAMS(na, \
- ::BOOST_SPIRIT_CLASSIC_NS::type_of::nop_functor() BOOST_PP_INTERCEPT) ); \
- }
- # define BOOST_SPIRIT_RP_GEN_OPAQUE(name,name_t,np,pars) \
- inline name_t name( BOOST_SPIRIT_RP_EMIT(PM_OPAQUE_GEN_PARAMS,pars,p)) \
- { return name_t (BOOST_PP_ENUM_PARAMS(np,p)); }
- # define BOOST_SPIRIT_RP_GLOB_VAR(name,name_t,np,na) \
- static name_t <void> const name = name_t <void>(BOOST_PP_ENUM_PARAMS(na, \
- ::BOOST_SPIRIT_CLASSIC_NS::type_of::nop_functor() BOOST_PP_INTERCEPT) );
- # define BOOST_SPIRIT_RP_GLOB_OPAQUE(name,name_t,np,pars) \
- static name_t const name = name_t () ;
- # define BOOST_SPIRIT_RP__NS_OPEN(r,data,i,elem) \
- namespace BOOST_SPIRIT_RP_OPTIONAL(elem) {
- # define BOOST_SPIRIT_RP__NS_QUALIFY(r,data,i,elem) \
- BOOST_SPIRIT_RP_OPTIONAL(elem ::)
- # define BOOST_SPIRIT_RP__NS_CLOSE(r,data,i,elem) }
- # define BOOST_SPIRIT_RP__PM_STATIC(r,data,i,elem) \
- static typename ::boost::call_traits< data ## i >::reference elem ;
- # define BOOST_SPIRIT_RP__PM_CTOR_PARAMS(r,data,i,elem) \
- BOOST_PP_COMMA_IF(i) \
- typename ::boost::call_traits< data ## i >::param_type elem
- # define BOOST_SPIRIT_RP__PM_CTOR_ARGS(r,data,i,elem) \
- BOOST_PP_COMMA_IF(i) elem
- # define BOOST_SPIRIT_RP__PM_CTOR_INIT_LIST(r,data,i,elem) \
- BOOST_PP_COMMA_IF(i) __p ## i ( elem )
- # define BOOST_SPIRIT_RP__PM_CTOR_COPY_INIT_LIST(r,data,i,elem) \
- BOOST_PP_COMMA_IF(i) __p ## i ( that. __p ## i )
- # define BOOST_SPIRIT_RP__PM_TEMPLATE_PARAMS(r,data,i,elem) , data ## i
- # define BOOST_SPIRIT_RP__PM_OPAQUE_STATIC(r,data,i,elem) \
- static ::boost::call_traits< \
- BOOST_SPIRIT_RP_TYPE(BOOST_PP_TUPLE_ELEM(2,0,elem)) \
- >::reference BOOST_PP_TUPLE_ELEM(2,1,elem) ;
- # define BOOST_SPIRIT_RP__PM_OPAQUE_CTOR_PARAMS(r,data,i,elem) \
- BOOST_PP_COMMA_IF(i) ::boost::call_traits< \
- BOOST_SPIRIT_RP_TYPE(BOOST_PP_TUPLE_ELEM(2,0,elem)) \
- >::param_type BOOST_PP_TUPLE_ELEM(2,1,elem)
- # define BOOST_SPIRIT_RP__PM_OPAQUE_GEN_PARAMS(r,data,i,elem) \
- BOOST_PP_COMMA_IF(i) ::boost::call_traits< \
- BOOST_SPIRIT_RP_TYPE(BOOST_PP_TUPLE_ELEM(2,0,elem)) \
- >::param_type data ## i
- # define BOOST_SPIRIT_RP__MV_NONSTATIC(r,data,i,elem) \
- data() BOOST_SPIRIT_RP_TYPE(BOOST_PP_TUPLE_ELEM(3,0,elem)) \
- BOOST_PP_TUPLE_ELEM(3,1,elem) ;
- # define BOOST_SPIRIT_RP__MV_STATIC(r,data,i,elem) \
- static data() ::boost::call_traits< \
- data() BOOST_SPIRIT_RP_TYPE(BOOST_PP_TUPLE_ELEM(3,0,elem)) \
- >::reference BOOST_PP_TUPLE_ELEM(3,1,elem) ;
- # define BOOST_SPIRIT_RP__MV_CTOR_INIT_LIST(r,data,i,elem) \
- BOOST_PP_COMMA_IF(i) \
- BOOST_PP_TUPLE_ELEM(3,1,elem) BOOST_PP_TUPLE_ELEM(3,2,elem)
- # define BOOST_SPIRIT_RP__MV_CTOR_COPY_INIT_LIST(r,data,i,elem) \
- BOOST_PP_COMMA_IF(i) \
- BOOST_PP_TUPLE_ELEM(3,1,elem) (data . BOOST_PP_TUPLE_ELEM(3,1,elem))
- # define BOOST_SPIRIT_RP__AP_STATIC(r,data,i,elem) static __A ## i & elem ;
- # define BOOST_SPIRIT_RP__AP_CTOR_PARAMS(r,data,i,elem) \
- BOOST_SPIRIT_RP_COMMA_IF_OR(data,i) \
- typename ::boost::call_traits< __A ## i >::param_type elem
- # define BOOST_SPIRIT_RP__AP_CTOR_ARGS(r,data,i,elem) \
- BOOST_SPIRIT_RP_COMMA_IF_OR(data,i) elem
- # define BOOST_SPIRIT_RP__AP_CTOR_INIT_LIST(r,data,i,elem) \
- BOOST_SPIRIT_RP_COMMA_IF_OR(data,i) __a ## i ( elem )
- # define BOOST_SPIRIT_RP__AP_CTOR_COPY_INIT_LIST(r,data,i,elem) \
- BOOST_SPIRIT_RP_COMMA_IF_OR(data,i) __a ## i ( that. __a ## i )
- # define BOOST_SPIRIT_RP__AP_TEMPLATE_PARAMS(r,data,i,elem) \
- , BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2,0,data),i) \
- BOOST_PP_EXPR_IIF(BOOST_PP_TUPLE_ELEM(2,1,data), \
- = ::BOOST_SPIRIT_CLASSIC_NS::type_of::nop_functor)
- # define BOOST_SPIRIT_RP__AP_REBOUND_ARGS(r,data,i,elem) \
- BOOST_PP_COMMA_IF(i) \
- ::BOOST_SPIRIT_CLASSIC_NS::type_of::get_placeholdee< __action_placeholder:: elem > \
- ( __a ## i , data )
- # define BOOST_SPIRIT_RP__AP_REBOUND_TPL_ARGS(r,data,i,elem) \
- , typename ::BOOST_SPIRIT_CLASSIC_NS::type_of::placeholdee< \
- __action_placeholder:: elem , __A ## i, data >::type
- # define BOOST_SPIRIT_RP_EMIT(op, array, data) \
- BOOST_SPIRIT_RP_ARRAY_FOR_EACH_I(BOOST_SPIRIT_RP__ ## op,data,array)
- # define BOOST_SPIRIT_RP_ARRAY_FOR_EACH_I(macro,data,optional_array) \
- BOOST_PP_IIF(BOOST_PP_IS_BINARY(optional_array), \
- BOOST_SPIRIT_RP_ARRAY_FOR_EACH_I_IMPL, \
- BOOST_PP_TUPLE_EAT(3))(macro,data,optional_array)
- # define BOOST_SPIRIT_RP_ARRAY_FOR_EACH_I_IMPL(macro,data,array) \
- BOOST_SPIRIT_RP_IF(BOOST_PP_ARRAY_SIZE(array),PP_SEQ_FOR_EACH_I,3) \
- (macro,data, BOOST_SPIRIT_RP_IF(BOOST_PP_ARRAY_SIZE(array), \
- PP_TUPLE_TO_SEQ,2) array)
- # define BOOST_SPIRIT_RP_ARRAY_SIZE(optional_array) \
- BOOST_PP_IIF(BOOST_PP_IS_BINARY(optional_array), \
- BOOST_PP_ARRAY_SIZE, 0 BOOST_PP_TUPLE_EAT(1))(optional_array)
- # define BOOST_SPIRIT_RP_OPTIONAL(elem) \
- BOOST_PP_EXPR_IIF(BOOST_PP_COMPL(BOOST_PP_IS_UNARY(elem)),elem)
- # define BOOST_SPIRIT_RP_COMMA_IF_OR(a,b) \
- BOOST_PP_IIF(BOOST_PP_OR(a,b),BOOST_PP_COMMA,BOOST_PP_EMPTY)()
- # define BOOST_SPIRIT_RP_IF(cond,name,arity) \
- BOOST_PP_IF(cond,BOOST_ ## name,BOOST_PP_TUPLE_EAT(arity))
- namespace boost { namespace spirit {
- BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
-
- template<class P> class parser_reference
- : public parser< parser_reference<P> >
- {
- P const & ref_that;
- public:
- parser_reference(P & that)
-
- : ref_that(that)
- { }
- typedef parser_reference<P> self_t;
- typedef self_t const & embed_t;
- typedef typename P::parser_category_t parser_category_t;
- template<typename ScannerT> struct result
- { typedef typename P::BOOST_NESTED_TEMPLATE result<ScannerT>::type type; };
- template<typename ScannerT>
- typename result<ScannerT>::type
- parse(ScannerT const & scan) const
- { return this->ref_that.parse(scan); }
- };
- template<class P> parser_reference<P>
- embed_by_reference(::BOOST_SPIRIT_CLASSIC_NS::parser<P> & p)
- { return p; }
- BOOST_SPIRIT_CLASSIC_NAMESPACE_END
- } }
- BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::parser_reference, 1)
- namespace boost { namespace spirit {
- BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
- namespace type_of {
-
- struct nop_functor
- {
- template<typename T>
- bool operator()(T const &) const
- { return false; }
- template<typename T, typename U>
- bool operator()(T const &, U const &) const
- { return false; }
- typedef bool result_type;
- };
-
- template<typename Action1, typename Action2>
- class composite_action
- {
- Action1 fnc_a1;
- Action2 fnc_a2;
- public:
- composite_action(Action1 const & a1, Action2 const & a2)
- : fnc_a1(a1), fnc_a2(a2)
- { }
- template<typename T>
- void operator()(T const & inp) const
- { fnc_a1(inp); fnc_a2(inp); }
- template<typename T, typename U>
- void operator()(T const & inp1, U const inp2) const
- { fnc_a1(inp1, inp2); fnc_a2(inp1, inp2); }
- };
-
- template<typename Action1, typename Action2>
- struct action_concatenator
- {
- typedef composite_action<Action1,Action2> type;
- static type concatenate(Action1 const & a1, Action2 const & a2)
- { return composite_action<Action1,Action2>(a1,a2); }
- };
- template<typename Action> struct action_concatenator<nop_functor, Action>
- {
- typedef Action type;
- static type concatenate(nop_functor const &, Action const & a)
- { return a; }
- };
- template<typename Action> struct action_concatenator<Action, nop_functor>
- {
- typedef Action type;
- static type concatenate(Action const & a, nop_functor const &)
- { return a; }
- };
- template<> struct action_concatenator<nop_functor, nop_functor>
- {
- typedef nop_functor type;
- static type concatenate(nop_functor const &, nop_functor const &)
- { return nop_functor(); }
- };
- template<typename Action1, typename Action2>
- typename action_concatenator<Action1,Action2>::type
- concatenate_actions(Action1 const & a1, Action2 const & a2)
- {
- return action_concatenator<Action1,Action2>::concatenate(a1,a2);
- }
-
- enum action_chain_mode { replace, append };
- template<class Placeholder, action_chain_mode Mode, typename Action>
- class action_chain
- {
- Action fnc_action;
- public:
- action_chain(Action const & a)
- : fnc_action(a)
- { }
- typedef Action action_type;
- Action const & action() const { return fnc_action; }
- };
-
- template<class PH, action_chain_mode M, typename A1, typename A2>
- action_chain<PH, M, typename action_concatenator<A1,A2>::type>
- operator, (action_chain<PH,M,A1> const & chain, A2 const & a)
- {
- return action_chain<PH,M,typename action_concatenator<A1,A2>::type>
- ( concatenate_actions(chain.action(), a) );
- }
-
- template<class ChainOrChains, class LastChain>
- class action_chains
- {
- ChainOrChains obj_head;
- LastChain obj_tail;
- public:
- action_chains(ChainOrChains const & head, LastChain const & tail)
- : obj_head(head), obj_tail(tail)
- { }
- typedef ChainOrChains head_type;
- typedef LastChain tail_type;
- head_type const & head() const { return obj_head; }
- tail_type const & tail() const { return obj_tail; }
- };
-
- template<class Head, class Tail>
- action_chains<Head,Tail> make_chain(Head const & h, Tail const & t)
- { return action_chains<Head,Tail>(h,t); }
- template<class PH1, action_chain_mode M1, typename A1,
- class PH2, action_chain_mode M2, typename A2>
- action_chains< action_chain<PH1,M1,A1>, action_chain<PH2,M2,A2> >
- operator, (action_chain<PH1,M1,A1> const & h,
- action_chain<PH2,M2,A2> const & t)
- { return make_chain(h,t); }
- template<class Head, class Tail,class PH, action_chain_mode M, typename A>
- action_chains< action_chains<Head,Tail>, action_chain<PH,M,A> >
- operator, (action_chains<Head,Tail> const & h, action_chain<PH,M,A> const & t)
- { return make_chain(h,t); }
-
-
- template<class Placeholder, typename StartAction, class NewChainOrChains>
- struct placeholdee
- {
- typedef StartAction type;
- static type get(StartAction const & a, NewChainOrChains const &)
- { return a; }
- };
- template<class Placeholder,
- typename StartAction, class NewChainOrChains>
- typename placeholdee<Placeholder,StartAction,NewChainOrChains>::type
- get_placeholdee(StartAction const & a, NewChainOrChains const & c)
- { return placeholdee<Placeholder,StartAction,NewChainOrChains>::get(a,c); }
- template<class Placeholder, typename StartAction, class Head, class Tail>
- struct placeholdee
- < Placeholder, StartAction, action_chains<Head,Tail> >
- {
- typedef typename placeholdee<Placeholder,
- typename placeholdee<Placeholder,StartAction,Head>::type, Tail >::type
- type;
- static type get(StartAction const & a, action_chains<Head,Tail> const & c)
- {
- return get_placeholdee<Placeholder>(
- get_placeholdee<Placeholder>(a,c.head()), c.tail() );
- }
- };
- template<class Placeholder, typename StartAction, typename A>
- struct placeholdee
- < Placeholder, StartAction, action_chain<Placeholder,replace,A> >
- {
- typedef A type;
- static type get(StartAction const &,
- action_chain<Placeholder,replace,A> const & c)
- { return c.action(); }
- };
- template<class Placeholder, typename StartAction, typename A>
- struct placeholdee
- < Placeholder, StartAction, action_chain<Placeholder,append,A> >
- {
- typedef typename action_concatenator<StartAction,A>::type type;
- static type get(StartAction const & a,
- action_chain<Placeholder,append,A> const & c)
- { return concatenate_actions(a,c.action()); }
- };
- }
- BOOST_SPIRIT_CLASSIC_NAMESPACE_END
- } }
- BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::type_of::nop_functor)
- BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::type_of::composite_action,2)
- namespace boost { namespace spirit {
- BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
- namespace type_of {
-
- template<typename T, typename X>
- X const & depend_on_type(X const & x)
- { return x; }
-
-
-
- #define BOOST_SPIRIT_RP_TYPE(x) \
- ::BOOST_SPIRIT_CLASSIC_NS::type_of::remove_special_fptr \
- < ::BOOST_SPIRIT_CLASSIC_NS::type_of::special_result & (*) x >::type
- struct special_result;
- template<typename T> struct remove_special_fptr { };
- template<typename T> struct remove_special_fptr< special_result & (*)(T) >
- { typedef T type; };
- }
- BOOST_SPIRIT_CLASSIC_NAMESPACE_END
- } }
- #endif
|