diff --git a/boost/ChangeLog b/boost/ChangeLog index 5937455900..01711ce0c1 100644 --- a/boost/ChangeLog +++ b/boost/ChangeLog @@ -1,3 +1,7 @@ +2004-11-24 Lars Gullik Bjønnes + + * add spirit to the collection + 2004-11-20 Lars Gullik Bjonnes * update boost to version 1.32.0 diff --git a/boost/boost/spirit/actor/assign_actor.hpp b/boost/boost/spirit/actor/assign_actor.hpp new file mode 100644 index 0000000000..6eb58c9e20 --- /dev/null +++ b/boost/boost/spirit/actor/assign_actor.hpp @@ -0,0 +1,96 @@ +/*============================================================================= + Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com) + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_ACTOR_ASSIGN_ACTOR_HPP +#define BOOST_SPIRIT_ACTOR_ASSIGN_ACTOR_HPP + +#include +#include + +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // Summary: + // A semantic action policy that applies the assignement operator. + // (This doc uses convention available in actors.hpp) + // + // Actions (what it does): + // ref = value; + // ref = T(first,last); + // ref = value_ref; + // + // Policy name: + // assign_action + // + // Policy holder, corresponding helper method: + // ref_value_actor, assign_a( ref ); + // ref_const_ref_actor, assign_a( ref, value_ref ); + // + // () operators: both + // + // See also ref_value_actor and ref_const_ref_actor for more details. + /////////////////////////////////////////////////////////////////////////// + struct assign_action + { + template< + typename T, + typename ValueT + > + void act(T& ref_, ValueT const& value_) const + { + ref_ = value_; + } + template< + typename T, + typename IteratorT + > + void act( + T& ref_, + IteratorT const& first_, + IteratorT const& last_ + ) const + { + typedef T value_type; +#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS + value_type value(first_,last_); +#else + value_type value; + std::copy(first_, last_, std::inserter(value, value.end())); +#endif + ref_ = value; + } + }; + + // Deprecated. Please use assign_a + template + inline ref_value_actor assign(T& ref_) + { + return ref_value_actor(ref_); + } + + template + inline ref_value_actor assign_a(T& ref_) + { + return ref_value_actor(ref_); + } + + template< + typename T, + typename ValueT + > + inline ref_const_ref_actor assign_a( + T& ref_, + ValueT const& value_ + ) + { + return ref_const_ref_actor(ref_,value_); + } + +}} + +#endif diff --git a/boost/boost/spirit/actor/push_back_actor.hpp b/boost/boost/spirit/actor/push_back_actor.hpp new file mode 100644 index 0000000000..6fbd24f464 --- /dev/null +++ b/boost/boost/spirit/actor/push_back_actor.hpp @@ -0,0 +1,97 @@ +/*============================================================================= + Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com) + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_ACTOR_PUSH_BACK_ACTOR_HPP +#define BOOST_SPIRIT_ACTOR_PUSH_BACK_ACTOR_HPP + +#include +#include + +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // Summary: + // + // A semantic action policy that appends a value to the back of a + // container. + // (This doc uses convention available in actors.hpp) + // + // Actions (what it does and what ref, value_ref must support): + // ref.push_back( value ); + // ref.push_back( T::value_type(first,last) ); + // ref.push_back( value_ref ); + // + // Policy name: + // push_back_action + // + // Policy holder, corresponding helper method: + // ref_value_actor, push_back_a( ref ); + // ref_const_ref_actor, push_back_a( ref, value_ref ); + // + // () operators: both + // + // See also ref_value_actor and ref_const_ref_actor for more details. + /////////////////////////////////////////////////////////////////////////// + struct push_back_action + { + template< + typename T, + typename ValueT + > + void act(T& ref_, ValueT const& value_) const + { + ref_.push_back( value_ ); + } + template< + typename T, + typename IteratorT + > + void act( + T& ref_, + IteratorT const& first_, + IteratorT const& last_ + ) const + { + typedef typename T::value_type value_type; + value_type value(first_,last_); + + ref_.push_back( value ); + } + }; + +// Deprecated interface. Use push_back_a + template + inline ref_value_actor + append(T& ref_) + { + return ref_value_actor(ref_); + } + + template + inline ref_value_actor + push_back_a(T& ref_) + { + return ref_value_actor(ref_); + } + + template< + typename T, + typename ValueT + > + inline ref_const_ref_actor + push_back_a( + T& ref_, + ValueT const& value_ + ) + { + return ref_const_ref_actor(ref_,value_); + } + +}} + +#endif diff --git a/boost/boost/spirit/actor/ref_const_ref_actor.hpp b/boost/boost/spirit/actor/ref_const_ref_actor.hpp new file mode 100644 index 0000000000..3691606810 --- /dev/null +++ b/boost/boost/spirit/actor/ref_const_ref_actor.hpp @@ -0,0 +1,73 @@ +/*============================================================================= + Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com) + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_ACTOR_REF_CONST_REF_ACTOR_HPP +#define BOOST_SPIRIT_ACTOR_REF_CONST_REF_ACTOR_HPP + +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // Summary: + // A semantic action policy holder. This holder stores a reference to ref + // and a const reference to value_ref. + // act methods are feed with ref and value_ref. The parse result is + // not used by this holder. + // + // (This doc uses convention available in actors.hpp) + // + // Constructor: + // ...(T& ref_, ValueT const& value_ref_); + // where ref_ and value_ref_ are stored in the holder. + // + // Action calls: + // act(ref, value_ref); + // + // () operators: both + // + /////////////////////////////////////////////////////////////////////////// + template< + typename T, + typename ValueT, + typename ActionT + > + class ref_const_ref_actor : public ActionT + { + private: + T& ref; + ValueT const& value_ref; + public: + ref_const_ref_actor( + T& ref_, + ValueT const& value_ref_ + ) + : + ref(ref_), + value_ref(value_ref_) + {} + + + template + void operator()(T2 const& /*val*/) const + { + this->act(ref,value_ref); // defined in ActionT + } + + + template + void operator()( + IteratorT const& /*first*/, + IteratorT const& /*last*/ + ) const + { + this->act(ref,value_ref); // defined in ActionT + } + }; + +}} + +#endif diff --git a/boost/boost/spirit/actor/ref_value_actor.hpp b/boost/boost/spirit/actor/ref_value_actor.hpp new file mode 100644 index 0000000000..cd21ab8bcb --- /dev/null +++ b/boost/boost/spirit/actor/ref_value_actor.hpp @@ -0,0 +1,65 @@ +/*============================================================================= + Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com) + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_ACTOR_REF_VALUE_ACTOR_HPP +#define BOOST_SPIRIT_ACTOR_REF_VALUE_ACTOR_HPP + +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // Summary: + // A semantic action policy holder. This holder stores a reference to ref. + // act methods are feed with ref and the parse result. + // + // (This doc uses convention available in actors.hpp) + // + // Constructor: + // ...(T& ref_); + // where ref_ is stored. + // + // Action calls: + // act(ref, value); + // act(ref, first,last); + // + // () operators: both + // + /////////////////////////////////////////////////////////////////////////// + template< + typename T, + typename ActionT + > + class ref_value_actor : public ActionT + { + private: + T& ref; + public: + explicit + ref_value_actor(T& ref_) + : ref(ref_){} + + + template + void operator()(T2 const& val_) const + { + this->act(ref,val_); // defined in ActionT + } + + + template + void operator()( + IteratorT const& first_, + IteratorT const& last_ + ) const + { + this->act(ref,first_,last_); // defined in ActionT + } + }; + +}} + +#endif diff --git a/boost/boost/spirit/attribute.hpp b/boost/boost/spirit/attribute.hpp new file mode 100644 index 0000000000..48e9a5dfc5 --- /dev/null +++ b/boost/boost/spirit/attribute.hpp @@ -0,0 +1,38 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_ATTRIBUTE_MAIN_HPP) +#define BOOST_SPIRIT_ATTRIBUTE_MAIN_HPP + +#include + +/////////////////////////////////////////////////////////////////////////////// +// +// Master header for Spirit.Attributes +// +/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// +// Phoenix predefined maximum limit. This limit defines the maximum +// number of elements a tuple can hold. This number defaults to 3. The +// actual maximum is rounded up in multiples of 3. Thus, if this value +// is 4, the actual limit is 6. The ultimate maximum limit in this +// implementation is 15. +// +/////////////////////////////////////////////////////////////////////////////// +#if !defined(PHOENIX_LIMIT) +#define PHOENIX_LIMIT 3 +#endif // !defined(PHOENIX_LIMIT) + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +#endif // !defined(BOOST_SPIRIT_ATTRIBUTE_MAIN_HPP) diff --git a/boost/boost/spirit/attribute/closure.hpp b/boost/boost/spirit/attribute/closure.hpp new file mode 100644 index 0000000000..60886b8afc --- /dev/null +++ b/boost/boost/spirit/attribute/closure.hpp @@ -0,0 +1,1078 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_CLOSURE_HPP +#define BOOST_SPIRIT_CLOSURE_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +/////////////////////////////////////////////////////////////////////////////// +// +// Spirit predefined maximum closure limit. This limit defines the maximum +// number of elements a closure can hold. This number defaults to 3. The +// actual maximum is rounded up in multiples of 3. Thus, if this value +// is 4, the actual limit is 6. The ultimate maximum limit in this +// implementation is 15. +// +// It should NOT be greater than PHOENIX_LIMIT! +// +/////////////////////////////////////////////////////////////////////////////// + +#if !defined(BOOST_SPIRIT_CLOSURE_LIMIT) +#define BOOST_SPIRIT_CLOSURE_LIMIT PHOENIX_LIMIT +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// ensure BOOST_SPIRIT_CLOSURE_LIMIT <= PHOENIX_LIMIT and SPIRIT_CLOSURE_LIMIT <= 15 +// +/////////////////////////////////////////////////////////////////////////////// +BOOST_STATIC_ASSERT(BOOST_SPIRIT_CLOSURE_LIMIT <= PHOENIX_LIMIT); +BOOST_STATIC_ASSERT(BOOST_SPIRIT_CLOSURE_LIMIT <= 15); + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // + // closure_context class + // + /////////////////////////////////////////////////////////////////////////// + template + class closure_context : public parser_context_base + { + public: + + typedef typename phoenix::tuple_element<0, + typename ClosureT::tuple_t>::type attr_t; + typedef ClosureT base_t; + typedef closure_context_linker > + context_linker_t; + + closure_context(ClosureT const& clos) + : frame(clos) {} + + ~closure_context() {} + + template + void pre_parse(ParserT const&, ScannerT const&) {} + + template + ResultT& post_parse(ResultT& hit, ParserT const&, ScannerT const&) + { hit.value(frame[phoenix::tuple_index<0>()]); return hit; } + + private: + + phoenix::closure_frame frame; + }; + + /////////////////////////////////////////////////////////////////////////// + // + // init_closure_context class + // + // The init_closure_context class is a special parser context type + // which additionally initializes a closure contained in the derived + // parser with values from a given tuple. Please note, that this + // given tuple does not contain the required values directly, it + // contains phoenix::actor objects. These actors have to be + // dereferenced to gain the values to be used for initialization + // (this is done by the help of the phoenix::convert_actors<> + // template). + // + /////////////////////////////////////////////////////////////////////////// + + template + class init_closure_context : public parser_context_base + { + typedef typename ClosureT::tuple_t tuple_t; + typedef typename ClosureT::closure_t closure_t; + + public: + + init_closure_context(ClosureT const& clos) + : frame(clos.subject(), phoenix::convert_actors(clos.init)) {} + + ~init_closure_context() {} + + template + void pre_parse(ParserT const& /*p*/, ScannerT const&) {} + + template + ResultT& post_parse(ResultT& hit, ParserT const&, ScannerT const&) + { hit.value(frame[phoenix::tuple_index<0>()]); return hit; } + + private: + + phoenix::closure_frame frame; + }; + + /////////////////////////////////////////////////////////////////////////// + // + // init_closure_parser class + // + /////////////////////////////////////////////////////////////////////////// + template + struct init_closure_parser + : public unary > > + { + typedef init_closure_parser self_t; + typedef unary > base_t; + typedef typename ParserT::phoenix_closure_t closure_t; + typedef typename ParserT::tuple_t tuple_t; + typedef typename phoenix::tuple_element<0, tuple_t>::type attr_t; + + template + struct result + { + typedef typename match_result::type type; + }; + + init_closure_parser(ParserT const& p, ActorTupleT const& init_) + : base_t(p), init(init_) {} + + template + typename parser_result::type + parse_main(ScannerT const& scan) const + { + return this->subject().parse_main(scan); + } + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + typedef init_closure_context init_context_t; + typedef parser_scanner_linker scanner_t; + typedef closure_context_linker context_t; + typedef typename parser_result::type result_t; + BOOST_SPIRIT_CONTEXT_PARSE( + scan, *this, scanner_t, context_t, result_t); + } + + ActorTupleT init; + }; + + /////////////////////////////////////////////////////////////////////////// + // + // closure class + // + /////////////////////////////////////////////////////////////////////////// + template < + typename DerivedT + , typename T0 = phoenix::nil_t + , typename T1 = phoenix::nil_t + , typename T2 = phoenix::nil_t + + #if BOOST_SPIRIT_CLOSURE_LIMIT > 3 + , typename T3 = phoenix::nil_t + , typename T4 = phoenix::nil_t + , typename T5 = phoenix::nil_t + + #if BOOST_SPIRIT_CLOSURE_LIMIT > 6 + , typename T6 = phoenix::nil_t + , typename T7 = phoenix::nil_t + , typename T8 = phoenix::nil_t + + #if BOOST_SPIRIT_CLOSURE_LIMIT > 9 + , typename T9 = phoenix::nil_t + , typename T10 = phoenix::nil_t + , typename T11 = phoenix::nil_t + + #if BOOST_SPIRIT_CLOSURE_LIMIT > 12 + , typename T12 = phoenix::nil_t + , typename T13 = phoenix::nil_t + , typename T14 = phoenix::nil_t + + #endif + #endif + #endif + #endif + > + struct closure : + public phoenix::closure< + T0, T1, T2 + #if BOOST_SPIRIT_CLOSURE_LIMIT > 3 + , T3, T4, T5 + #if BOOST_SPIRIT_CLOSURE_LIMIT > 6 + , T6, T7, T8 + #if BOOST_SPIRIT_CLOSURE_LIMIT > 9 + , T9, T10, T11 + #if BOOST_SPIRIT_CLOSURE_LIMIT > 12 + , T12, T13, T14 + #endif + #endif + #endif + #endif + > + { + typedef phoenix::closure< + T0, T1, T2 + #if BOOST_SPIRIT_CLOSURE_LIMIT > 3 + , T3, T4, T5 + #if BOOST_SPIRIT_CLOSURE_LIMIT > 6 + , T6, T7, T8 + #if BOOST_SPIRIT_CLOSURE_LIMIT > 9 + , T9, T10, T11 + #if BOOST_SPIRIT_CLOSURE_LIMIT > 12 + , T12, T13, T14 + #endif + #endif + #endif + #endif + > phoenix_closure_t; + + typedef closure_context context_t; + + template + struct aux + { + DerivedT2& aux_derived() + { return *static_cast(this); } + + DerivedT2 const& aux_derived() const + { return *static_cast(this); } + + // initialization functions + template + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type + > + > + operator()(A const &a) const + { + typedef typename phoenix::as_actor::type a_t; + typedef phoenix::tuple actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a) + ) + ); + } + + template + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()(A const &a, B const &b) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef phoenix::tuple actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b) + ) + ); + } + + template + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()(A const &a, B const &b, C const &c) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef phoenix::tuple actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c) + ) + ); + } + + #if BOOST_SPIRIT_CLOSURE_LIMIT > 3 + + template < + typename A, typename B, typename C, typename D + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d) + ) + ); + } + + template < + typename A, typename B, typename C, typename D, typename E + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d, E const &e + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef typename phoenix::as_actor::type e_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t, e_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d), + phoenix::as_actor::convert(e) + ) + ); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d, E const &e, + F const &f + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef typename phoenix::as_actor::type e_t; + typedef typename phoenix::as_actor::type f_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t, e_t, f_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d), + phoenix::as_actor::convert(e), + phoenix::as_actor::convert(f) + ) + ); + } + + #if BOOST_SPIRIT_CLOSURE_LIMIT > 6 + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d, E const &e, + F const &f, G const &g + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef typename phoenix::as_actor::type e_t; + typedef typename phoenix::as_actor::type f_t; + typedef typename phoenix::as_actor::type g_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t, e_t, f_t, g_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d), + phoenix::as_actor::convert(e), + phoenix::as_actor::convert(f), + phoenix::as_actor::convert(g) + ) + ); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d, E const &e, + F const &f, G const &g, H const &h + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef typename phoenix::as_actor::type e_t; + typedef typename phoenix::as_actor::type f_t; + typedef typename phoenix::as_actor::type g_t; + typedef typename phoenix::as_actor::type h_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d), + phoenix::as_actor::convert(e), + phoenix::as_actor::convert(f), + phoenix::as_actor::convert(g), + phoenix::as_actor::convert(h) + ) + ); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d, E const &e, + F const &f, G const &g, H const &h, I const &i + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef typename phoenix::as_actor::type e_t; + typedef typename phoenix::as_actor::type f_t; + typedef typename phoenix::as_actor::type g_t; + typedef typename phoenix::as_actor::type h_t; + typedef typename phoenix::as_actor::type i_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d), + phoenix::as_actor::convert(e), + phoenix::as_actor::convert(f), + phoenix::as_actor::convert(g), + phoenix::as_actor::convert(h), + phoenix::as_actor::convert(i) + ) + ); + } + + #if BOOST_SPIRIT_CLOSURE_LIMIT > 9 + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d, E const &e, + F const &f, G const &g, H const &h, I const &i, J const &j + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef typename phoenix::as_actor::type e_t; + typedef typename phoenix::as_actor::type f_t; + typedef typename phoenix::as_actor::type g_t; + typedef typename phoenix::as_actor::type h_t; + typedef typename phoenix::as_actor::type i_t; + typedef typename phoenix::as_actor::type j_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d), + phoenix::as_actor::convert(e), + phoenix::as_actor::convert(f), + phoenix::as_actor::convert(g), + phoenix::as_actor::convert(h), + phoenix::as_actor::convert(i), + phoenix::as_actor::convert(j) + ) + ); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d, E const &e, + F const &f, G const &g, H const &h, I const &i, J const &j, + K const &k + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef typename phoenix::as_actor::type e_t; + typedef typename phoenix::as_actor::type f_t; + typedef typename phoenix::as_actor::type g_t; + typedef typename phoenix::as_actor::type h_t; + typedef typename phoenix::as_actor::type i_t; + typedef typename phoenix::as_actor::type j_t; + typedef typename phoenix::as_actor::type k_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t, + k_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d), + phoenix::as_actor::convert(e), + phoenix::as_actor::convert(f), + phoenix::as_actor::convert(g), + phoenix::as_actor::convert(h), + phoenix::as_actor::convert(i), + phoenix::as_actor::convert(j), + phoenix::as_actor::convert(k) + ) + ); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d, E const &e, + F const &f, G const &g, H const &h, I const &i, J const &j, + K const &k, L const &l + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef typename phoenix::as_actor::type e_t; + typedef typename phoenix::as_actor::type f_t; + typedef typename phoenix::as_actor::type g_t; + typedef typename phoenix::as_actor::type h_t; + typedef typename phoenix::as_actor::type i_t; + typedef typename phoenix::as_actor::type j_t; + typedef typename phoenix::as_actor::type k_t; + typedef typename phoenix::as_actor::type l_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t, + k_t, l_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d), + phoenix::as_actor::convert(e), + phoenix::as_actor::convert(f), + phoenix::as_actor::convert(g), + phoenix::as_actor::convert(h), + phoenix::as_actor::convert(i), + phoenix::as_actor::convert(j), + phoenix::as_actor::convert(k), + phoenix::as_actor::convert(l) + ) + ); + } + + #if BOOST_SPIRIT_CLOSURE_LIMIT > 12 + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d, E const &e, + F const &f, G const &g, H const &h, I const &i, J const &j, + K const &k, L const &l, M const &m + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef typename phoenix::as_actor::type e_t; + typedef typename phoenix::as_actor::type f_t; + typedef typename phoenix::as_actor::type g_t; + typedef typename phoenix::as_actor::type h_t; + typedef typename phoenix::as_actor::type i_t; + typedef typename phoenix::as_actor::type j_t; + typedef typename phoenix::as_actor::type k_t; + typedef typename phoenix::as_actor::type l_t; + typedef typename phoenix::as_actor::type m_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t, + k_t, l_t, m_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d), + phoenix::as_actor::convert(e), + phoenix::as_actor::convert(f), + phoenix::as_actor::convert(g), + phoenix::as_actor::convert(h), + phoenix::as_actor::convert(i), + phoenix::as_actor::convert(j), + phoenix::as_actor::convert(k), + phoenix::as_actor::convert(l), + phoenix::as_actor::convert(m) + ) + ); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d, E const &e, + F const &f, G const &g, H const &h, I const &i, J const &j, + K const &k, L const &l, M const &m, N const &n + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef typename phoenix::as_actor::type e_t; + typedef typename phoenix::as_actor::type f_t; + typedef typename phoenix::as_actor::type g_t; + typedef typename phoenix::as_actor::type h_t; + typedef typename phoenix::as_actor::type i_t; + typedef typename phoenix::as_actor::type j_t; + typedef typename phoenix::as_actor::type k_t; + typedef typename phoenix::as_actor::type l_t; + typedef typename phoenix::as_actor::type m_t; + typedef typename phoenix::as_actor::type n_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t, + k_t, l_t, m_t, n_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d), + phoenix::as_actor::convert(e), + phoenix::as_actor::convert(f), + phoenix::as_actor::convert(g), + phoenix::as_actor::convert(h), + phoenix::as_actor::convert(i), + phoenix::as_actor::convert(j), + phoenix::as_actor::convert(k), + phoenix::as_actor::convert(l), + phoenix::as_actor::convert(m), + phoenix::as_actor::convert(n) + ) + ); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N, typename O + > + init_closure_parser< + DerivedT2, + phoenix::tuple< + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type, + typename phoenix::as_actor::type + > + > + operator()( + A const &a, B const &b, C const &c, D const &d, E const &e, + F const &f, G const &g, H const &h, I const &i, J const &j, + K const &k, L const &l, M const &m, N const &n, O const &o + ) const + { + typedef typename phoenix::as_actor::type a_t; + typedef typename phoenix::as_actor::type b_t; + typedef typename phoenix::as_actor::type c_t; + typedef typename phoenix::as_actor::type d_t; + typedef typename phoenix::as_actor::type e_t; + typedef typename phoenix::as_actor::type f_t; + typedef typename phoenix::as_actor::type g_t; + typedef typename phoenix::as_actor::type h_t; + typedef typename phoenix::as_actor::type i_t; + typedef typename phoenix::as_actor::type j_t; + typedef typename phoenix::as_actor::type k_t; + typedef typename phoenix::as_actor::type l_t; + typedef typename phoenix::as_actor::type m_t; + typedef typename phoenix::as_actor::type n_t; + typedef typename phoenix::as_actor::type o_t; + typedef phoenix::tuple< + a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t, + k_t, l_t, m_t, n_t, o_t + > actor_tuple_t; + + return init_closure_parser( + aux_derived(), + actor_tuple_t( + phoenix::as_actor::convert(a), + phoenix::as_actor::convert(b), + phoenix::as_actor::convert(c), + phoenix::as_actor::convert(d), + phoenix::as_actor::convert(e), + phoenix::as_actor::convert(f), + phoenix::as_actor::convert(g), + phoenix::as_actor::convert(h), + phoenix::as_actor::convert(i), + phoenix::as_actor::convert(j), + phoenix::as_actor::convert(k), + phoenix::as_actor::convert(l), + phoenix::as_actor::convert(m), + phoenix::as_actor::convert(n), + phoenix::as_actor::convert(o) + ) + ); + } + + #endif + #endif + #endif + #endif + }; + + ~closure() {} + }; + + /////////////////////////////////////////////////////////////////////////// + // + // overloads for chseq_p and str_p taking in phoenix actors + // + /////////////////////////////////////////////////////////////////////////// + template + struct container_begin + { + typedef container_begin self_t; + + template + struct result + { + typedef typename phoenix::actor_result + ::plain_type::iterator type; + }; + + container_begin(ActorT actor_) + : actor(actor_) {} + + template + typename phoenix::actor_result::type + eval(TupleT const& /*args*/) const + { return actor().begin(); } + + ActorT actor; + }; + + template + struct container_end + { + typedef container_begin self_t; + + template + struct result + { + typedef typename phoenix::actor_result + ::plain_type::iterator type; + }; + + container_end(ActorT actor_) + : actor(actor_) {} + + template + typename phoenix::actor_result::type + eval(TupleT const& /*args*/) const + { return actor().end(); } + + ActorT actor; + }; + + template + inline f_chseq< + phoenix::actor > >, + phoenix::actor > > + > + f_chseq_p(phoenix::actor const& a) + { + typedef phoenix::actor > > + container_begin_t; + typedef phoenix::actor > > + container_end_t; + typedef f_chseq result_t; + + return result_t(container_begin_t(a), container_end_t(a)); + } + + template + inline f_strlit< + phoenix::actor > >, + phoenix::actor > > + > + f_str_p(phoenix::actor const& a) + { + typedef phoenix::actor > > + container_begin_t; + typedef phoenix::actor > > + container_end_t; + typedef f_strlit result_t; + + return result_t(container_begin_t(a), container_end_t(a)); + } + +}} // namespace boost::spirit + +#endif diff --git a/boost/boost/spirit/attribute/closure_context.hpp b/boost/boost/spirit/attribute/closure_context.hpp new file mode 100644 index 0000000000..ff46228aca --- /dev/null +++ b/boost/boost/spirit/attribute/closure_context.hpp @@ -0,0 +1,51 @@ +/*============================================================================= + Copyright (c) 2002-2003 Joel de Guzman + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_CLOSURE_CONTEXT_HPP) +#define BOOST_SPIRIT_CLOSURE_CONTEXT_HPP + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +#if !defined(BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED) +#define BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED + +/////////////////////////////////////////////////////////////////////////////// +// +// closure_context_linker +// { helper template for the closure extendability } +// +// This classes can be 'overloaded' (defined elsewhere), to plug +// in additional functionality into the closure parsing process. +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct closure_context_linker : public ContextT +{ + template + closure_context_linker(ParserT const& p) + : ContextT(p) {} + + template + void pre_parse(ParserT const& p, ScannerT const& scan) + { ContextT::pre_parse(p, scan); } + + template + ResultT& + post_parse(ResultT& hit, ParserT const& p, ScannerT const& scan) + { return ContextT::post_parse(hit, p, scan); } +}; + +#endif // !defined(BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED) + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif // BOOST_SPIRIT_CLOSURE_CONTEXT_HPP diff --git a/boost/boost/spirit/attribute/parametric.hpp b/boost/boost/spirit/attribute/parametric.hpp new file mode 100644 index 0000000000..2e2883bf2e --- /dev/null +++ b/boost/boost/spirit/attribute/parametric.hpp @@ -0,0 +1,140 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_PARAMETRIC_HPP +#define BOOST_SPIRIT_PARAMETRIC_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include + +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // + // f_chlit class [ functional version of chlit ] + // + /////////////////////////////////////////////////////////////////////////// + template + struct f_chlit : public char_parser > + { + f_chlit(ChGenT chgen_) + : chgen(chgen_) {} + + template + bool test(T ch) const + { return ch == chgen(); } + + ChGenT chgen; + }; + + template + inline f_chlit + f_ch_p(ChGenT chgen) + { return f_chlit(chgen); } + + /////////////////////////////////////////////////////////////////////////// + // + // f_range class [ functional version of range ] + // + /////////////////////////////////////////////////////////////////////////// + template + struct f_range : public char_parser > + { + f_range(ChGenAT first_, ChGenBT last_) + : first(first_), last(last_) + {} + + template + bool test(T ch) const + { + BOOST_SPIRIT_ASSERT(first() <= last()); + return (ch >= first()) && (ch <= last()); + } + + ChGenAT first; + ChGenBT last; + }; + + template + inline f_range + f_range_p(ChGenAT first, ChGenBT last) + { return f_range(first, last); } + + /////////////////////////////////////////////////////////////////////////// + // + // f_chseq class [ functional version of chseq ] + // + /////////////////////////////////////////////////////////////////////////// + template + class f_chseq : public parser > + { + public: + + typedef f_chseq self_t; + + f_chseq(IterGenAT first_, IterGenBT last_) + : first(first_), last(last_) {} + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + typedef typename parser_result::type result_t; + return impl::string_parser_parse(first(), last(), scan); + } + + private: + + IterGenAT first; + IterGenBT last; + }; + + template + inline f_chseq + f_chseq_p(IterGenAT first, IterGenBT last) + { return f_chseq(first, last); } + + /////////////////////////////////////////////////////////////////////////// + // + // f_strlit class [ functional version of strlit ] + // + /////////////////////////////////////////////////////////////////////////// + template + class f_strlit : public parser > + { + public: + + typedef f_strlit self_t; + + f_strlit(IterGenAT first, IterGenBT last) + : seq(first, last) {} + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + typedef typename parser_result::type result_t; + return impl::contiguous_parser_parse + (seq, scan, scan); + } + + private: + + f_chseq seq; + }; + + template + inline f_strlit + f_str_p(IterGenAT first, IterGenBT last) + { return f_strlit(first, last); } + +}} // namespace boost::spirit + +#endif diff --git a/boost/boost/spirit/core.hpp b/boost/boost/spirit/core.hpp new file mode 100644 index 0000000000..2bcba62fc5 --- /dev/null +++ b/boost/boost/spirit/core.hpp @@ -0,0 +1,74 @@ +/*============================================================================= + Copyright (c) 1998-2003 Joel de Guzman + Copyright (c) 2001-2003 Daniel Nuffer + Copyright (c) 2001-2003 Hartmut Kaiser + Copyright (c) 2002-2003 Martin Wille + Copyright (c) 2002 Raghavendra Satish + Copyright (c) 2001 Bruce Florman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_CORE_MAIN_HPP) +#define BOOST_SPIRIT_CORE_MAIN_HPP + +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +// +// Spirit.Core includes +// +/////////////////////////////////////////////////////////////////////////////// + +// Spirit.Core.Kernel +#include +#include +#include +#include + +// Spirit.Core.Primitives +#include +#include + +// Spirit.Core.Scanner +#include +#include + +// Spirit.Core.NonTerminal +#include +#include +#include + +// Spirit.Core.Composite +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Deprecated interface includes +#include +#include + +#if defined(BOOST_SPIRIT_DEBUG) + ////////////////////////////////// + #include + +#endif // BOOST_SPIRIT_DEBUG + +#endif // BOOST_SPIRIT_CORE_MAIN_HPP + diff --git a/boost/boost/spirit/debug.hpp b/boost/boost/spirit/debug.hpp new file mode 100644 index 0000000000..8b97edeadf --- /dev/null +++ b/boost/boost/spirit/debug.hpp @@ -0,0 +1,146 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_DEBUG_MAIN_HPP) +#define BOOST_SPIRIT_DEBUG_MAIN_HPP + +/////////////////////////////////////////////////////////////////////////// +#if defined(BOOST_SPIRIT_DEBUG) + +#include + +/////////////////////////////////////////////////////////////////////////////// +// +// Spirit.Debug includes and defines +// +/////////////////////////////////////////////////////////////////////////////// + + #include + + /////////////////////////////////////////////////////////////////////////// + // + // The BOOST_SPIRIT_DEBUG_OUT defines the stream object, which should be used + // for debug diagnostics. This defaults to std::cout. + // + /////////////////////////////////////////////////////////////////////////// + #if !defined(BOOST_SPIRIT_DEBUG_OUT) + #define BOOST_SPIRIT_DEBUG_OUT std::cout + #endif + + /////////////////////////////////////////////////////////////////////////// + // + // The BOOST_SPIRIT_DEBUG_PRINT_SOME constant defines the number of characters + // from the stream to be printed for diagnosis. This defaults to the first + // 20 characters. + // + /////////////////////////////////////////////////////////////////////////// + #if !defined(BOOST_SPIRIT_DEBUG_PRINT_SOME) + #define BOOST_SPIRIT_DEBUG_PRINT_SOME 20 + #endif + + /////////////////////////////////////////////////////////////////////////// + // + // Additional BOOST_SPIRIT_DEBUG_FLAGS control the level of diagnostics printed + // Basic constants are defined in debug/minimal.hpp. + // + /////////////////////////////////////////////////////////////////////////// + #define BOOST_SPIRIT_DEBUG_FLAGS_NODES 0x0001 // node diagnostics + #define BOOST_SPIRIT_DEBUG_FLAGS_ESCAPE_CHAR 0x0002 // escape_char_parse diagnostics + #define BOOST_SPIRIT_DEBUG_FLAGS_TREES 0x0004 // parse tree/ast diagnostics + #define BOOST_SPIRIT_DEBUG_FLAGS_CLOSURES 0x0008 // closure diagnostics + #define BOOST_SPIRIT_DEBUG_FLAGS_SLEX 0x8000 // slex diagnostics + + #define BOOST_SPIRIT_DEBUG_FLAGS_MAX 0xFFFF // print maximal diagnostics + + #if !defined(BOOST_SPIRIT_DEBUG_FLAGS) + #define BOOST_SPIRIT_DEBUG_FLAGS BOOST_SPIRIT_DEBUG_FLAGS_MAX + #endif + + /////////////////////////////////////////////////////////////////////////// + // + // By default all nodes are traced (even those, not registered with + // BOOST_SPIRIT_DEBUG_RULE et.al. - see below). The following constant may be + // used to redefine this default. + // + /////////////////////////////////////////////////////////////////////////// + #if !defined(BOOST_SPIRIT_DEBUG_TRACENODE) + #define BOOST_SPIRIT_DEBUG_TRACENODE (true) + #endif // !defined(BOOST_SPIRIT_DEBUG_TRACENODE) + + /////////////////////////////////////////////////////////////////////////// + // + // Helper macros for giving rules and subrules a name accessible through + // parser_name() functions (see parser_names.hpp). + // + // Additionally, the macros BOOST_SPIRIT_DEBUG_RULE, SPIRIT_DEBUG_NODE and + // BOOST_SPIRIT_DEBUG_GRAMMAR enable/disable the tracing of the + // correspondingnode accordingly to the PP constant + // BOOST_SPIRIT_DEBUG_TRACENODE. + // + // The macros BOOST_SPIRIT_DEBUG_TRACE_RULE, BOOST_SPIRIT_DEBUG_TRACE_NODE + // and BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR allow to specify a flag to define, + // whether the corresponding node is to be traced or not. + // + /////////////////////////////////////////////////////////////////////////// + #if !defined(BOOST_SPIRIT_DEBUG_RULE) + #define BOOST_SPIRIT_DEBUG_RULE(r) \ + ::boost::spirit::impl::get_node_registry().register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE) + #endif // !defined(BOOST_SPIRIT_DEBUG_RULE) + + #if !defined(BOOST_SPIRIT_DEBUG_NODE) + #define BOOST_SPIRIT_DEBUG_NODE(r) \ + ::boost::spirit::impl::get_node_registry().register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE) + #endif // !defined(BOOST_SPIRIT_DEBUG_NODE) + + #if !defined(BOOST_SPIRIT_DEBUG_GRAMMAR) + #define BOOST_SPIRIT_DEBUG_GRAMMAR(r) \ + ::boost::spirit::impl::get_node_registry().register_node(&r, #r, BOOST_SPIRIT_DEBUG_TRACENODE) + #endif // !defined(BOOST_SPIRIT_DEBUG_GRAMMAR) + + #if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE) + #define BOOST_SPIRIT_DEBUG_TRACE_RULE(r, t) \ + ::boost::spirit::impl::get_node_registry().register_node(&r, #r, (t)) + #endif // !defined(BOOST_SPIRIT_TRACE_RULE) + + #if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE) + #define BOOST_SPIRIT_DEBUG_TRACE_NODE(r, t) \ + ::boost::spirit::impl::get_node_registry().register_node(&r, #r, (t)) + #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE) + + #if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR) + #define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR(r, t) \ + ::boost::spirit::impl::get_node_registry().register_node(&r, #r, (t)) + #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR) + + #if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME) + #define BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME(r, n, t) \ + ::boost::spirit::impl::get_node_registry().register_node(&r, (n), (t)) + #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME) + + #if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME) + #define BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME(r, n, t) \ + ::boost::spirit::impl::get_node_registry().register_node(&r, (n), (t)) + #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME) + + #if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME) + #define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(r, n, t) \ + ::boost::spirit::impl::get_node_registry().register_node(&r, (n), (t)) + #endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME) + + ////////////////////////////////// + #include + +#else + ////////////////////////////////// + #include + +#endif // BOOST_SPIRIT_DEBUG + +#endif + diff --git a/boost/boost/spirit/debug/minimal.hpp b/boost/boost/spirit/debug/minimal.hpp new file mode 100644 index 0000000000..47b6c781eb --- /dev/null +++ b/boost/boost/spirit/debug/minimal.hpp @@ -0,0 +1,82 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_MINIMAL_DEBUG_HPP) +#define BOOST_SPIRIT_MINIMAL_DEBUG_HPP + +#if !defined(BOOST_SPIRIT_DEBUG_MAIN_HPP) +#error "You must include boost/spirit/debug.hpp, not boost/spirit/debug/minimal.hpp" +#endif +/////////////////////////////////////////////////////////////////////////////// +// +// Minimum debugging tools support +// +/////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_SPIRIT_DEBUG_OUT) +#define BOOST_SPIRIT_DEBUG_OUT std::cout +#endif + +/////////////////////////////////////////////////////////////////////////// +// +// BOOST_SPIRIT_DEBUG_FLAGS controls the level of diagnostics printed +// +/////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_SPIRIT_DEBUG_FLAGS_NONE) +#define BOOST_SPIRIT_DEBUG_FLAGS_NONE 0x0000 // no diagnostics at all +#endif + +#if !defined(BOOST_SPIRIT_DEBUG_FLAGS_MAX) +#define BOOST_SPIRIT_DEBUG_FLAGS_MAX 0xFFFF // print maximal diagnostics +#endif + +#if !defined(BOOST_SPIRIT_DEBUG_FLAGS) +#define BOOST_SPIRIT_DEBUG_FLAGS SPIRIT_DEBUG_FLAGS_MAX +#endif + +#if !defined(BOOST_SPIRIT_DEBUG_PRINT_SOME) +#define BOOST_SPIRIT_DEBUG_PRINT_SOME 20 +#endif + +#if !defined(BOOST_SPIRIT_DEBUG_RULE) +#define BOOST_SPIRIT_DEBUG_RULE(r) +#endif // !defined(BOOST_SPIRIT_DEBUG_RULE) + +#if !defined(BOOST_SPIRIT_DEBUG_NODE) +#define BOOST_SPIRIT_DEBUG_NODE(r) +#endif // !defined(BOOST_SPIRIT_DEBUG_NODE) + +#if !defined(BOOST_SPIRIT_DEBUG_GRAMMAR) +#define BOOST_SPIRIT_DEBUG_GRAMMAR(r) +#endif // !defined(BOOST_SPIRIT_DEBUG_GRAMMAR) + +#if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE) +#define BOOST_SPIRIT_DEBUG_TRACE_RULE(r, t) +#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE) + +#if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE) +#define BOOST_SPIRIT_DEBUG_TRACE_NODE(r, t) +#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE) + +#if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR) +#define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR(r, t) +#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR) + +#if !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME) +#define BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME(r, n, t) +#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME) + +#if !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME) +#define BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME(r, n, t) +#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_NODE_NAME) + +#if !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME) +#define BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(r, n, t) +#endif // !defined(BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME) + +#endif // !defined(BOOST_SPIRIT_MINIMAL_DEBUG_HPP) diff --git a/boost/boost/spirit/dynamic/if.hpp b/boost/boost/spirit/dynamic/if.hpp new file mode 100644 index 0000000000..c73d5a8471 --- /dev/null +++ b/boost/boost/spirit/dynamic/if.hpp @@ -0,0 +1,224 @@ +/*============================================================================= + Copyright (c) 2002-2003 Joel de Guzman + Copyright (c) 2002 Juan Carlos Arevalo-Baeza + Copyright (c) 2002-2003 Martin Wille + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_IF_HPP +#define BOOST_SPIRIT_IF_HPP + +#include +#include +#include + +namespace boost { namespace spirit { + + namespace impl { + + ////////////////////////////////// + // if-else-parser, holds two alternative parsers and a conditional functor + // that selects between them. + template + struct if_else_parser + : public condition_evaluator::type> + , public binary + < + typename as_parser::type, + typename as_parser::type, + parser< if_else_parser > + > + { + typedef if_else_parser self_t; + + typedef as_parser as_parser_true_t; + typedef as_parser as_parser_false_t; + typedef typename as_parser_true_t::type parser_true_t; + typedef typename as_parser_false_t::type parser_false_t; + typedef as_parser cond_as_parser_t; + typedef typename cond_as_parser_t::type condition_t; + + typedef binary > base_t; + typedef condition_evaluator eval_t; + + if_else_parser + ( + ParsableTrueT const& p_true, + ParsableFalseT const& p_false, + CondT const& cond_ + ) + : eval_t(cond_as_parser_t::convert(cond_)) + , base_t + ( + as_parser_true_t::convert(p_true), + as_parser_false_t::convert(p_false) + ) + { } + + template + struct result + { + typedef typename match_result::type type; + }; + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + typedef typename parser_result + ::type then_result_t; + typedef typename parser_result + ::type else_result_t; + + typename ScannerT::iterator_t const save(scan.first); + + std::ptrdiff_t length = this->evaluate(scan); + if (length >= 0) + { + then_result_t then_result(this->left().parse(scan)); + if (then_result) + { + length += then_result.length(); + return scan.create_match(std::size_t(length), nil_t(), save, scan.first); + } + } + else + { + else_result_t else_result(this->right().parse(scan)); + if (else_result) + { + length = else_result.length(); + return scan.create_match(std::size_t(length), nil_t(), save, scan.first); + } + } + return scan.no_match(); + } + }; + + ////////////////////////////////// + // if-else-parser generator, takes the false-parser in brackets + // and returns the if-else-parser. + template + struct if_else_parser_gen + { + if_else_parser_gen(ParsableTrueT const& p_true_, CondT const& cond_) + : p_true(p_true_) + , cond(cond_) {} + + template + if_else_parser + < + ParsableTrueT, + ParsableFalseT, + CondT + > + operator[](ParsableFalseT const& p_false) const + { + return if_else_parser + ( + p_true, + p_false, + cond + ); + } + + ParsableTrueT const &p_true; + CondT const &cond; + }; + + ////////////////////////////////// + // if-parser, conditionally runs a parser is a functor condition is true. + // If the condition is fales, it fails the parse. + // It can optionally become an if-else-parser through the member else_p. + template + struct if_parser + : public condition_evaluator::type> + , public unary + < + typename as_parser::type, + parser > > + { + typedef if_parser self_t; + typedef as_parser as_parser_t; + typedef typename as_parser_t::type parser_t; + + typedef as_parser cond_as_parser_t; + typedef typename cond_as_parser_t::type condition_t; + typedef condition_evaluator eval_t; + typedef unary > base_t; + + if_parser(ParsableT const& p, CondT const& cond_) + : eval_t(cond_as_parser_t::convert(cond_)) + , base_t(as_parser_t::convert(p)) + , else_p(p, cond_) + {} + + template + struct result + { + typedef typename match_result::type type; + }; + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + typedef typename parser_result::type t_result_t; + typename ScannerT::iterator_t const save(scan.first); + + std::ptrdiff_t length = this->evaluate(scan); + if (length >= 0) + { + t_result_t then_result(this->subject().parse(scan)); + if (then_result) + { + length += then_result.length(); + return scan.create_match(std::size_t(length), nil_t(), save, scan.first); + } + } + return scan.empty_match(); + } + + if_else_parser_gen else_p; + }; + + ////////////////////////////////// + // if-parser generator, takes the true-parser in brackets and returns the + // if-parser. + template + struct if_parser_gen + { + if_parser_gen(CondT const& cond_) : cond(cond_) {} + + template + if_parser + < + ParsableT, + CondT + > + operator[](ParsableT const& subject) const + { + return if_parser(subject, cond); + } + + CondT const &cond; + }; + +} // namespace impl + +////////////////////////////////// +// if_p function, returns "if" parser generator + +template +impl::if_parser_gen +if_p(CondT const& cond) +{ + return impl::if_parser_gen(cond); +} + +}} // namespace boost::spirit + +#endif // BOOST_SPIRIT_IF_HPP diff --git a/boost/boost/spirit/dynamic/impl/conditions.ipp b/boost/boost/spirit/dynamic/impl/conditions.ipp new file mode 100644 index 0000000000..a2fd032728 --- /dev/null +++ b/boost/boost/spirit/dynamic/impl/conditions.ipp @@ -0,0 +1,100 @@ +/*============================================================================= + Copyright (c) 2002-2003 Martin Wille + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_CONDITIONS_IPP +#define BOOST_SPIRIT_CONDITIONS_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + + namespace impl { + +/////////////////////////////////////////////////////////////////////////////// +// +// condition evaluation +// +/////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////// + // condition_parser_selector, decides which parser to use for a condition + // If the template argument is a parser then that parser is used. + // If the template argument is a functor then a condition parser using + // the functor is chosen + + template struct embed_t_accessor + { + typedef typename T::embed_t type; + }; + +#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 + template <> struct embed_t_accessor + { + typedef int type; + }; +#endif + + template + struct condition_parser_selector + { + typedef + typename mpl::if_< + is_parser, + ConditionT, + condition_parser + >::type + type; + + typedef typename embed_t_accessor::type embed_t; + }; + + ////////////////////////////////// + // condition_evaluator, uses a parser to check wether a condition is met + // takes a parser or a functor that can be evaluated in boolean context + // as template parameter. + + // JDG 4-15-03 refactored + template + struct condition_evaluator + { + typedef condition_parser_selector selector_t; + typedef typename selector_t::type selected_t; + typedef typename selector_t::embed_t cond_embed_t; + + typedef typename boost::call_traits::param_type + param_t; + + condition_evaluator(param_t s) : cond(s) {} + + ///////////////////////////// + // evaluate, checks wether condition is met + // returns length of a match or a negative number for no-match + template + std::ptrdiff_t + evaluate(ScannerT const &scan) const + { + typedef typename ScannerT::iterator_t iterator_t; + typedef typename parser_result::type cres_t; + iterator_t save(scan.first); + cres_t result = cond.parse(scan); + if (!result) // reset the position if evaluation + scan.first = save; // fails. + return result.length(); + } + + cond_embed_t cond; + }; + +/////////////////////////////////////////////////////////////////////////////// + } // namespace impl + +}} // namespace boost::spirit + +#endif diff --git a/boost/boost/spirit/error_handling.hpp b/boost/boost/spirit/error_handling.hpp new file mode 100644 index 0000000000..3d94ca40b2 --- /dev/null +++ b/boost/boost/spirit/error_handling.hpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_ERROR_HANDLING_MAIN_HPP) +#define BOOST_SPIRIT_ERROR_HANDLING_MAIN_HPP + +#include + +/////////////////////////////////////////////////////////////////////////////// +// +// Master header for Spirit.ErrorHandling +// +/////////////////////////////////////////////////////////////////////////////// + +#include + +#endif // !defined(BOOST_SPIRIT_ERROR_HANDLING_MAIN_HPP) diff --git a/boost/boost/spirit/error_handling/exceptions.hpp b/boost/boost/spirit/error_handling/exceptions.hpp new file mode 100644 index 0000000000..8a3e0da1a8 --- /dev/null +++ b/boost/boost/spirit/error_handling/exceptions.hpp @@ -0,0 +1,360 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_EXCEPTIONS_HPP +#define BOOST_SPIRIT_EXCEPTIONS_HPP + +#include +#include +#include +#include +#include + +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // + // parser_error_base class + // + // This is the base class of parser_error (see below). This may be + // used to catch any type of parser error. + // + // This exception shouldn't propagate outside the parser. However to + // avoid quirks of many platforms/implementations which fall outside + // the C++ standard, we derive parser_error_base from std::exception + // to allow a single catch handler to catch all exceptions. + // + /////////////////////////////////////////////////////////////////////////// + class parser_error_base : public std::exception + { + protected: + + parser_error_base() {} + virtual ~parser_error_base() throw() {} + + public: + + parser_error_base(parser_error_base const&) {} + parser_error_base& operator=(parser_error_base const&) + { + return *this; + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // parser_error class + // + // Generic parser exception class. This is the base class for all + // parser exceptions. The exception holds the iterator position + // where the error was encountered in its member variable "where". + // The parser_error also holds information regarding the error + // (error descriptor) in its member variable "descriptor". + // + // The throw_ function creates and throws a parser_error given + // an iterator and an error descriptor. + // + /////////////////////////////////////////////////////////////////////////// + template + struct parser_error : public parser_error_base + { + typedef ErrorDescrT error_descr_t; + typedef IteratorT iterator_t; + + parser_error(IteratorT where_, ErrorDescrT descriptor_) + : where(where_), descriptor(descriptor_) {} + + parser_error(parser_error const& rhs) + : where(rhs.where), descriptor(rhs.descriptor) {} + + parser_error& + operator=(parser_error const& rhs) + { + where = rhs.where; + descriptor = rhs.descriptor; + return *this; + } + + virtual + ~parser_error() throw() {} + + virtual const char* + what() const throw() + { + return "boost::spirit::parser_error"; + } + + IteratorT where; + ErrorDescrT descriptor; + }; + + ////////////////////////////////// + template + inline void + throw_(IteratorT where, ErrorDescrT descriptor) + { + boost::throw_exception( + parser_error(where, descriptor)); + } + + /////////////////////////////////////////////////////////////////////////// + // + // assertive_parser class + // + // An assertive_parser class is a parser that throws an exception + // in response to a parsing failure. The assertive_parser throws a + // parser_error exception rather than returning an unsuccessful + // match to signal that the parser failed to match the input. + // + /////////////////////////////////////////////////////////////////////////// + template + struct assertive_parser + : public unary > > + { + typedef assertive_parser self_t; + typedef unary > base_t; + typedef unary_parser_category parser_category_t; + + assertive_parser(ParserT const& parser, ErrorDescrT descriptor) + : base_t(parser), descriptor(descriptor) {} + + template + struct result + { + typedef typename parser_result::type type; + }; + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + typedef typename parser_result::type result_t; + typedef typename ScannerT::iterator_t iterator_t; + + result_t hit = this->subject().parse(scan); + if (!hit) + { + throw_(scan.first, descriptor); + } + return hit; + } + + ErrorDescrT descriptor; + }; + + /////////////////////////////////////////////////////////////////////////// + // + // assertion class + // + // assertive_parsers are never instantiated directly. The assertion + // class is used to indirectly create an assertive_parser object. + // Before declaring the grammar, we declare some assertion objects. + // Examples: + // + // enum Errors + // { + // program_expected, begin_expected, end_expected + // }; + // + // assertion expect_program(program_expected); + // assertion expect_begin(begin_expected); + // assertion expect_end(end_expected); + // + // Now, we can use these assertions as wrappers around parsers: + // + // expect_end(str_p("end")) + // + // Take note that although the example uses enums to hold the + // information regarding the error (error desccriptor), we are free + // to use other types such as integers and strings. Enums are + // convenient for error handlers to easily catch since C++ treats + // enums as unique types. + // + /////////////////////////////////////////////////////////////////////////// + template + struct assertion + { + assertion(ErrorDescrT descriptor_) + : descriptor(descriptor_) {} + + template + assertive_parser + operator()(ParserT const& parser) const + { + return assertive_parser(parser, descriptor); + } + + ErrorDescrT descriptor; + }; + + /////////////////////////////////////////////////////////////////////////// + // + // error_status + // + // Where T is an attribute type compatible with the match attribute + // of the fallback_parser's subject (defaults to nil_t). The class + // error_status reports the result of an error handler (see + // fallback_parser). result can be one of: + // + // fail: quit and fail (return a no_match) + // retry: attempt error recovery, possibly moving the scanner + // accept: force success returning a matching length, moving + // the scanner appropriately and returning an attribute + // value + // rethrow: rethrows the error. + // + /////////////////////////////////////////////////////////////////////////// + template + struct error_status + { + enum result_t { fail, retry, accept, rethrow }; + + error_status( + result_t result_ = fail, + std::ptrdiff_t length = -1, + T const& value_ = T()) + : result(result_), length(length), value(value_) {} + + result_t result; + std::ptrdiff_t length; + T value; + }; + + /////////////////////////////////////////////////////////////////////////// + // + // fallback_parser class + // + // Handles exceptions of type parser_error + // thrown somewhere inside its embedded ParserT object. The class + // sets up a try block before delegating parsing to its subject. + // When an exception is caught, the catch block then calls the + // HandlerT object. HandlerT may be a function or a functor (with + // an operator() member function) compatible with the interface: + // + // error_status + // handler(ScannerT const& scan, ErrorT error); + // + // Where scan points to the scanner state prior to parsing and error + // is the error that arose (see parser_error). The handler must + // return an error_status object (see above). + // + /////////////////////////////////////////////////////////////////////////// + namespace impl + { + template + RT fallback_parser_parse(ParserT const& p, ScannerT const& scan); + } + + template + struct fallback_parser + : public unary > > + { + typedef fallback_parser + self_t; + typedef ErrorDescrT + error_descr_t; + typedef unary > + base_t; + typedef unary_parser_category + parser_category_t; + + fallback_parser(ParserT const& parser, HandlerT const& handler_) + : base_t(parser), handler(handler_) {} + + template + struct result + { + typedef typename parser_result::type type; + }; + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + typedef typename parser_result::type result_t; + return impl::fallback_parser_parse(*this, scan); + } + + HandlerT handler; + }; + + /////////////////////////////////////////////////////////////////////////// + // + // guard class + // + // fallback_parser objects are not instantiated directly. The guard + // class is used to indirectly create a fallback_parser object. + // guards are typically predeclared just like assertions (see the + // assertion class above; the example extends the previous example + // introduced in the assertion class above): + // + // guard my_guard; + // + // Errors, in this example is the error descriptor type we want to + // detect; This is essentially the ErrorDescrT template parameter + // of the fallback_parser class. + // + // my_guard may now be used in a grammar declaration as: + // + // my_guard(p)[h] + // + // where p is a parser, h is a function or functor compatible with + // fallback_parser's HandlerT (see above). + // + /////////////////////////////////////////////////////////////////////////// + template + struct guard; + + template + struct guard_gen : public unary + { + typedef guard parser_generator_t; + typedef unary_parser_category parser_category_t; + + guard_gen(ParserT const& p) + : unary(p) {} + + template + fallback_parser + operator[](HandlerT const& handler) const + { + return fallback_parser + (this->subject(), handler); + } + }; + + template + struct guard + { + template + struct result + { + typedef guard_gen type; + }; + + template + static guard_gen + generate(ParserT const& parser) + { + return guard_gen(parser); + } + + template + guard_gen + operator()(ParserT const& parser) const + { + return guard_gen(parser); + } + }; + +}} // namespace boost::spirit + +#include +#endif + diff --git a/boost/boost/spirit/error_handling/impl/exceptions.ipp b/boost/boost/spirit/error_handling/impl/exceptions.ipp new file mode 100644 index 0000000000..e1a871b0c9 --- /dev/null +++ b/boost/boost/spirit/error_handling/impl/exceptions.ipp @@ -0,0 +1,85 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_EXCEPTIONS_IPP +#define BOOST_SPIRIT_EXCEPTIONS_IPP + +namespace boost { namespace spirit { namespace impl { + +#ifdef __BORLANDC__ + template + typename parser_result::type + fallback_parser_helper(ParserT const& subject, ScannerT const& scan); +#endif + + template + RT fallback_parser_parse(ParserT const& p, ScannerT const& scan) + { + typedef typename ScannerT::iterator_t iterator_t; + typedef typename RT::attr_t attr_t; + typedef error_status error_status_t; + typedef typename ParserT::error_descr_t error_descr_t; + + iterator_t save = scan.first; + error_status_t hr(error_status_t::retry); + + while (hr.result == error_status_t::retry) + { + try + { + #ifndef __BORLANDC__ + return p.subject().parse(scan); + #else + return impl::fallback_parser_helper(p, scan); + #endif + } + + catch (parser_error& error) + { + scan.first = save; + hr = p.handler(scan, error); + switch (hr.result) + { + case error_status_t::fail: + return scan.no_match(); + case error_status_t::accept: + return scan.create_match + (std::size_t(hr.length), hr.value, save, scan.first); + case error_status_t::rethrow: + boost::throw_exception(error); + default: + continue; + } + } + } + return scan.no_match(); + } + +/////////////////////////////////////////////////////////////////////////// +// +// Borland does not like calling the subject directly in the try block. +// Removing the #ifdef __BORLANDC__ code makes Borland complain that +// some variables and types cannot be found in the catch block. Weird! +// +/////////////////////////////////////////////////////////////////////////// +#ifdef __BORLANDC__ + + template + typename parser_result::type + fallback_parser_helper(ParserT const& p, ScannerT const& scan) + { + return p.subject().parse(scan); + } + +#endif + +}}} // namespace boost::spirit::impl + +/////////////////////////////////////////////////////////////////////////////// +#endif + diff --git a/boost/boost/spirit/iterator.hpp b/boost/boost/spirit/iterator.hpp new file mode 100644 index 0000000000..b0719c13b0 --- /dev/null +++ b/boost/boost/spirit/iterator.hpp @@ -0,0 +1,26 @@ +/*============================================================================= + Copyright (c) 2001-2003 Daniel Nuffer + Copyright (c) 2003 Giovanni Bajo + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_ITERATOR_MAIN_HPP) +#define BOOST_SPIRIT_ITERATOR_MAIN_HPP + +#include + +/////////////////////////////////////////////////////////////////////////////// +// +// Master header for Spirit.Iterators +// +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include + +#endif // !defined(BOOST_SPIRIT_ITERATOR_MAIN_HPP) diff --git a/boost/boost/spirit/iterator/file_iterator.hpp b/boost/boost/spirit/iterator/file_iterator.hpp new file mode 100644 index 0000000000..0cad0e2529 --- /dev/null +++ b/boost/boost/spirit/iterator/file_iterator.hpp @@ -0,0 +1,238 @@ +/*============================================================================= + Copyright (c) 2003 Giovanni Bajo + Copyright (c) 2003 Thomas Witt + Copyright (c) 2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +/////////////////////////////////////////////////////////////////////////////// +// +// File Iterator structure +// +// The new structure is designed on layers. The top class (used by the user) +// is file_iterator, which implements a full random access iterator through +// the file, and some specific member functions (constructor that opens +// the file, make_end() to generate the end iterator, operator bool to check +// if the file was opened correctly). +// +// file_iterator implements the random access iterator interface by the means +// of boost::iterator_adaptor, that is inhering an object created with it. +// iterator_adaptor gets a low-level file iterator implementation (with just +// a few member functions) and a policy (that basically describes to it how +// the low-level file iterator interface is). The advantage is that +// with boost::iterator_adaptor only 5 functions are needed to implement +// a fully conformant random access iterator, instead of dozens of functions +// and operators. +// +// There are two low-level file iterators implemented in this module. The +// first (std_file_iterator) uses cstdio stream functions (fopen/fread), which +// support full buffering, and is available everywhere (it's standard C++). +// The second (mmap_file_iterator) is currently available only on Windows +// platforms, and uses memory mapped files, which gives a decent speed boost. +// +/////////////////////////////////////////////////////////////////////////////// +// +// TODO LIST: +// +// - In the Win32 mmap iterator, we could check if keeping a handle to the +// opened file is really required. If it's not, we can just store the file +// length (for make_end()) and save performance. Notice that this should be +// tested under different Windows versions, the behaviour might change. +// - Add some error support (by the means of some exceptions) in case of +// low-level I/O failure. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_SPIRIT_FILE_ITERATOR_HPP +#define BOOST_SPIRIT_FILE_ITERATOR_HPP + +#include +#include +#include +#include + +#if !defined(BOOST_SPIRIT_FILEITERATOR_STD) +# if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ + && !defined(BOOST_DISABLE_WIN32) +# define BOOST_SPIRIT_FILEITERATOR_WINDOWS +# elif defined(BOOST_HAS_UNISTD_H) +extern "C" +{ +# include +} +# ifdef _POSIX_MAPPED_FILES +# define BOOST_SPIRIT_FILEITERATOR_POSIX +# endif // _POSIX_MAPPED_FILES +# endif // BOOST_HAS_UNISTD_H + +# if !defined(BOOST_SPIRIT_FILEITERATOR_WINDOWS) && \ + !defined(BOOST_SPIRIT_FILEITERATOR_POSIX) +# define BOOST_SPIRIT_FILEITERATOR_STD +# endif +#endif // BOOST_SPIRIT_FILEITERATOR_STD + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +namespace fileiter_impl { + + // Forward declarations + template + class std_file_iterator; + +#if !defined(BOOST_SPIRIT_FILEITERATOR_STD) + template + class mmap_file_iterator; +#endif + +/////////////////////////////////////////////////////////////////////////////// +} // namespace fileiter_impl + +template < + typename CharT = char, + typename BaseIterator = +#ifndef BOOST_SPIRIT_FILEITERATOR_WINDOWS + fileiter_impl::std_file_iterator +#else + fileiter_impl::mmap_file_iterator +#endif +> class file_iterator; + +/////////////////////////////////////////////////////////////////////////////// +namespace fileiter_impl { + + ///////////////////////////////////////////////////////////////////////// + // + // file_iter_generator + // + // Template meta-function to invoke boost::iterator_adaptor + // NOTE: This cannot be moved into the implementation file because of + // a bug of MSVC 7.0 and previous versions (base classes types are + // looked up at compilation time, not instantion types, and + // file_iterator would break). + // + ///////////////////////////////////////////////////////////////////////// + +#if !defined(BOOST_ITERATOR_ADAPTORS_VERSION) || \ + BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200 +#error "Please use at least Boost V1.31.0 while compiling the file_iterator class!" +#else // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200 + + template + struct file_iter_generator + { + public: + typedef BaseIteratorT adapted_t; + typedef typename adapted_t::value_type value_type; + + typedef boost::iterator_adaptor < + file_iterator, + adapted_t, + value_type const, + std::random_access_iterator_tag, + boost::use_default, + signed long + > type; + }; + +#endif // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200 + +/////////////////////////////////////////////////////////////////////////////// +} /* namespace impl */ + + +/////////////////////////////////////////////////////////////////////////////// +// +// file_iterator +// +// Iterates through an opened file. +// +// The main iterator interface is implemented by the iterator_adaptors +// library, which wraps a conforming iterator interface around the +// impl::BaseIterator class. This class merely derives the iterator_adaptors +// generated class to implement the custom constructors and make_end() +// member function. +// +/////////////////////////////////////////////////////////////////////////////// + +template +class file_iterator + : public fileiter_impl::file_iter_generator::type, + public safe_bool > +{ +private: + typedef typename + fileiter_impl::file_iter_generator::type + base_t; + typedef typename + fileiter_impl::file_iter_generator::adapted_t + adapted_t; + +public: + file_iterator() + {} + + file_iterator(std::string fileName) + : base_t(adapted_t(fileName)) + {} + + file_iterator(const base_t& iter) + : base_t(iter) + {} + + inline file_iterator& operator=(const base_t& iter); + file_iterator make_end(void); + + // operator bool. This borrows a trick from boost::shared_ptr to avoid + // to interfere with arithmetic operations. + bool operator_bool(void) const + { return this->base(); } + +private: + friend class ::boost::iterator_core_access; + + typename base_t::reference dereference() const + { + return this->base_reference().get_cur_char(); + } + + void increment() + { + this->base_reference().next_char(); + } + + void decrement() + { + this->base_reference().prev_char(); + } + + void advance(typename base_t::difference_type n) + { + this->base_reference().advance(n); + } + + template < + typename OtherDerivedT, typename OtherIteratorT, + typename V, typename C, typename R, typename D + > + typename base_t::difference_type distance_to( + iterator_adaptor + const &x) const + { + return x.base().distance(this->base_reference()); + } +}; + +/////////////////////////////////////////////////////////////////////////////// +}} /* namespace boost::spirit */ + +/////////////////////////////////////////////////////////////////////////////// +#include "impl/file_iterator.ipp" /* implementation */ + +#endif /* BOOST_SPIRIT_FILE_ITERATOR_HPP */ + diff --git a/boost/boost/spirit/iterator/fixed_size_queue.hpp b/boost/boost/spirit/iterator/fixed_size_queue.hpp new file mode 100644 index 0000000000..9f18b42288 --- /dev/null +++ b/boost/boost/spirit/iterator/fixed_size_queue.hpp @@ -0,0 +1,398 @@ +/*============================================================================= + Copyright (c) 2001, Daniel C. Nuffer + Copyright (c) 2003, Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef FIXED_SIZE_QUEUE +#define FIXED_SIZE_QUEUE + +#include +#include +#include + +#include // for BOOST_SPIRIT_ASSERT + +// FIXES for broken compilers +#include +#include + +#define BOOST_SPIRIT_ASSERT_FSQ_SIZE \ + BOOST_SPIRIT_ASSERT(((m_tail + N + 1) - m_head) % (N+1) == m_size % (N+1)) \ + /**/ + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +namespace impl { + +#if !defined(BOOST_ITERATOR_ADAPTORS_VERSION) || \ + BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200 +#error "Please use at least Boost V1.31.0 while compiling the fixed_size_queue class!" +#else // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200 + +template +class fsq_iterator +: public boost::iterator_adaptor< + fsq_iterator, + PointerT, + T, + std::random_access_iterator_tag + > +{ +public: + typedef typename QueueT::position_t position; + typedef boost::iterator_adaptor< + fsq_iterator, PointerT, T, + std::random_access_iterator_tag + > base_t; + + fsq_iterator() {} + fsq_iterator(position const &p_) : p(p_) {} + + position const &get_position() const { return p; } + +private: + friend class boost::iterator_core_access; + + typename base_t::reference dereference() const + { + return p.self->m_queue[p.pos]; + } + + void increment() + { + ++p.pos; + if (p.pos == QueueT::MAX_SIZE+1) + p.pos = 0; + } + + void decrement() + { + if (p.pos == 0) + p.pos = QueueT::MAX_SIZE; + else + --p.pos; + } + + template < + typename OtherDerivedT, typename OtherIteratorT, + typename V, typename C, typename R, typename D + > + bool equal(iterator_adaptor + const &x) const + { + position const &rhs_pos = + static_cast(x).get_position(); + return (p.self == rhs_pos.self) && (p.pos == rhs_pos.pos); + } + + template < + typename OtherDerivedT, typename OtherIteratorT, + typename V, typename C, typename R, typename D + > + typename base_t::difference_type distance_to( + iterator_adaptor + const &x) const + { + typedef typename base_t::difference_type diff_t; + + position const &p2 = + static_cast(x).get_position(); + std::size_t pos1 = p.pos; + std::size_t pos2 = p2.pos; + + // Undefined behaviour if the iterators come from different + // containers + BOOST_SPIRIT_ASSERT(p.self == p2.self); + + if (pos1 < p.self->m_head) + pos1 += QueueT::MAX_SIZE; + if (pos2 < p2.self->m_head) + pos2 += QueueT::MAX_SIZE; + + if (pos2 > pos1) + return diff_t(pos2 - pos1); + else + return -diff_t(pos1 - pos2); + } + + void advance(typename base_t::difference_type n) + { + // Notice that we don't care values of n that can + // wrap around more than one time, since it would + // be undefined behaviour anyway (going outside + // the begin/end range). Negative wrapping is a bit + // cumbersome because we don't want to case p.pos + // to signed. + if (n < 0) + { + n = -n; + if (p.pos < (std::size_t)n) + p.pos = QueueT::MAX_SIZE+1 - (n - p.pos); + else + p.pos -= n; + } + else + { + p.pos += n; + if (p.pos >= QueueT::MAX_SIZE+1) + p.pos -= QueueT::MAX_SIZE+1; + } + } + +private: + position p; +}; + +#endif // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200 + +/////////////////////////////////////////////////////////////////////////////// +} /* namespace impl */ + +template +class fixed_size_queue +{ +private: + struct position + { + fixed_size_queue* self; + std::size_t pos; + + position() : self(0), pos(0) {} + + // The const_cast here is just to avoid to have two different + // position structures for the const and non-const case. + // The const semantic is guaranteed by the iterator itself + position(const fixed_size_queue* s, std::size_t p) + : self(const_cast(s)), pos(p) + {} + }; + +public: + // Declare the iterators + typedef impl::fsq_iterator, T, T*> iterator; + typedef impl::fsq_iterator, T const, T const*> + const_iterator; + typedef position position_t; + + friend class impl::fsq_iterator, T, T*>; + friend class impl::fsq_iterator, T const, T const*>; + + fixed_size_queue(); + fixed_size_queue(const fixed_size_queue& x); + fixed_size_queue& operator=(const fixed_size_queue& x); + ~fixed_size_queue(); + + void push_back(const T& e); + void push_front(const T& e); + void serve(T& e); + void pop_front(); + + bool empty() const + { + return m_size == 0; + } + + bool full() const + { + return m_size == N; + } + + iterator begin() + { + return iterator(position(this, m_head)); + } + + const_iterator begin() const + { + return const_iterator(position(this, m_head)); + } + + iterator end() + { + return iterator(position(this, m_tail)); + } + + const_iterator end() const + { + return const_iterator(position(this, m_tail)); + } + + std::size_t size() const + { + return m_size; + } + + T& front() + { + return m_queue[m_head]; + } + + const T& front() const + { + return m_queue[m_head]; + } + +private: + // Redefine the template parameters to avoid using partial template + // specialization on the iterator policy to extract N. + BOOST_STATIC_CONSTANT(std::size_t, MAX_SIZE = N); + + std::size_t m_head; + std::size_t m_tail; + std::size_t m_size; + T m_queue[N+1]; +}; + +template +inline +fixed_size_queue::fixed_size_queue() + : m_head(0) + , m_tail(0) + , m_size(0) +{ + BOOST_SPIRIT_ASSERT(m_size <= N+1); + BOOST_SPIRIT_ASSERT_FSQ_SIZE; + BOOST_SPIRIT_ASSERT(m_head <= N+1); + BOOST_SPIRIT_ASSERT(m_tail <= N+1); +} + +template +inline +fixed_size_queue::fixed_size_queue(const fixed_size_queue& x) + : m_head(x.m_head) + , m_tail(x.m_tail) + , m_size(x.m_size) +{ + copy(x.begin(), x.end(), begin()); + BOOST_SPIRIT_ASSERT(m_size <= N+1); + BOOST_SPIRIT_ASSERT_FSQ_SIZE; + BOOST_SPIRIT_ASSERT(m_head <= N+1); + BOOST_SPIRIT_ASSERT(m_tail <= N+1); +} + +template +inline fixed_size_queue& +fixed_size_queue::operator=(const fixed_size_queue& x) +{ + if (this != &x) + { + m_head = x.m_head; + m_tail = x.m_tail; + m_size = x.m_size; + copy(x.begin(), x.end(), begin()); + } + BOOST_SPIRIT_ASSERT(m_size <= N+1); + BOOST_SPIRIT_ASSERT_FSQ_SIZE; + BOOST_SPIRIT_ASSERT(m_head <= N+1); + BOOST_SPIRIT_ASSERT(m_tail <= N+1); + + return *this; +} + +template +inline +fixed_size_queue::~fixed_size_queue() +{ + BOOST_SPIRIT_ASSERT(m_size <= N+1); + BOOST_SPIRIT_ASSERT_FSQ_SIZE; + BOOST_SPIRIT_ASSERT(m_head <= N+1); + BOOST_SPIRIT_ASSERT(m_tail <= N+1); +} + +template +inline void +fixed_size_queue::push_back(const T& e) +{ + BOOST_SPIRIT_ASSERT(m_size <= N+1); + BOOST_SPIRIT_ASSERT_FSQ_SIZE; + BOOST_SPIRIT_ASSERT(m_head <= N+1); + BOOST_SPIRIT_ASSERT(m_tail <= N+1); + + BOOST_SPIRIT_ASSERT(!full()); + + m_queue[m_tail] = e; + ++m_size; + ++m_tail; + if (m_tail == N+1) + m_tail = 0; + + + BOOST_SPIRIT_ASSERT(m_size <= N+1); + BOOST_SPIRIT_ASSERT_FSQ_SIZE; + BOOST_SPIRIT_ASSERT(m_head <= N+1); + BOOST_SPIRIT_ASSERT(m_tail <= N+1); +} + +template +inline void +fixed_size_queue::push_front(const T& e) +{ + BOOST_SPIRIT_ASSERT(m_size <= N+1); + BOOST_SPIRIT_ASSERT_FSQ_SIZE; + BOOST_SPIRIT_ASSERT(m_head <= N+1); + BOOST_SPIRIT_ASSERT(m_tail <= N+1); + + BOOST_SPIRIT_ASSERT(!full()); + + if (m_head == 0) + m_head = N; + else + --m_head; + + m_queue[m_head] = e; + ++m_size; + + BOOST_SPIRIT_ASSERT(m_size <= N+1); + BOOST_SPIRIT_ASSERT_FSQ_SIZE; + BOOST_SPIRIT_ASSERT(m_head <= N+1); + BOOST_SPIRIT_ASSERT(m_tail <= N+1); +} + + +template +inline void +fixed_size_queue::serve(T& e) +{ + BOOST_SPIRIT_ASSERT(m_size <= N+1); + BOOST_SPIRIT_ASSERT_FSQ_SIZE; + BOOST_SPIRIT_ASSERT(m_head <= N+1); + BOOST_SPIRIT_ASSERT(m_tail <= N+1); + + e = m_queue[m_head]; + pop_front(); +} + + + +template +inline void +fixed_size_queue::pop_front() +{ + BOOST_SPIRIT_ASSERT(m_size <= N+1); + BOOST_SPIRIT_ASSERT_FSQ_SIZE; + BOOST_SPIRIT_ASSERT(m_head <= N+1); + BOOST_SPIRIT_ASSERT(m_tail <= N+1); + + ++m_head; + if (m_head == N+1) + m_head = 0; + --m_size; + + BOOST_SPIRIT_ASSERT(m_size <= N+1); + BOOST_SPIRIT_ASSERT_FSQ_SIZE; + BOOST_SPIRIT_ASSERT(m_head <= N+1); + BOOST_SPIRIT_ASSERT(m_tail <= N+1); +} + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#undef BOOST_SPIRIT_ASSERT_FSQ_SIZE + +#endif diff --git a/boost/boost/spirit/iterator/impl/file_iterator.ipp b/boost/boost/spirit/iterator/impl/file_iterator.ipp new file mode 100644 index 0000000000..385067698e --- /dev/null +++ b/boost/boost/spirit/iterator/impl/file_iterator.ipp @@ -0,0 +1,459 @@ +/*============================================================================= + Copyright (c) 2003 Giovanni Bajo + Copyright (c) 2003 Martin Wille + Copyright (c) 2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#ifndef BOOST_SPIRIT_FILE_ITERATOR_IPP +#define BOOST_SPIRIT_FILE_ITERATOR_IPP + +#ifdef BOOST_SPIRIT_FILEITERATOR_WINDOWS +# define WIN32_LEAN_AND_MEAN +# include +#endif + +#include +#include + +#ifdef BOOST_SPIRIT_FILEITERATOR_WINDOWS +# include +#endif + +#ifdef BOOST_SPIRIT_FILEITERATOR_POSIX +# include // open, stat, mmap, munmap +# include // stat +# include // open +# include // stat, mmap, munmap +# include // mmap, mmunmap +#endif + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +namespace fileiter_impl { + +using namespace std; + +/////////////////////////////////////////////////////////////////////////////// +// +// std_file_iterator +// +// Base class that implements iteration through a file using standard C +// stream library (fopen and friends). This class and the following are +// the base components on which the iterator is built (through the +// iterator adaptor library). +// +// The opened file stream (FILE) is held with a shared_ptr<>, whose +// custom deleter invokes fcose(). This makes the syntax of the class +// very easy, especially everything related to copying. +// +/////////////////////////////////////////////////////////////////////////////// + +template +class std_file_iterator +{ +public: + typedef CharT value_type; + + std_file_iterator() + {} + + explicit std_file_iterator(std::string fileName) + { + FILE* f = fopen(fileName.c_str(), "rb"); + + // If the file was opened, store it into + // the smart pointer. + if (f) + { + m_file.reset(f, fclose); + m_pos = 0; + m_eof = false; + update_char(); + } + } + + std_file_iterator(const std_file_iterator& iter) + { *this = iter; } + + std_file_iterator& operator=(const std_file_iterator& iter) + { + m_file = iter.m_file; + m_curChar = iter.m_curChar; + m_eof = iter.m_eof; + m_pos = iter.m_pos; + + return *this; + } + + // Nasty bug in Comeau up to 4.3.0.1, we need explicit boolean context + // for shared_ptr to evaluate correctly + operator bool() const + { return m_file ? true : false; } + + bool operator==(const std_file_iterator& iter) const + { + return (m_file == iter.m_file) && (m_eof == iter.m_eof) && + (m_pos == iter.m_pos); + } + + const CharT& get_cur_char(void) const + { + return m_curChar; + } + + void prev_char(void) + { + m_pos -= sizeof(CharT); + update_char(); + } + + void next_char(void) + { + m_pos += sizeof(CharT); + update_char(); + } + + void seek_end(void) + { + fseek(m_file.get(), 0, SEEK_END); + m_pos = ftell(m_file.get()) / sizeof(CharT); + m_eof = true; + } + + void advance(signed long n) + { + m_pos += n * sizeof(CharT); + update_char(); + } + + long distance(const std_file_iterator& iter) const + { + return (long)(m_pos - iter.m_pos) / sizeof(CharT); + } + +private: + boost::shared_ptr m_file; + std::size_t m_pos; + CharT m_curChar; + bool m_eof; + + void update_char(void) + { + if ((std::size_t)ftell(m_file.get()) != m_pos) + fseek(m_file.get(), m_pos, SEEK_SET); + + m_eof = (fread(&m_curChar, sizeof(CharT), 1, m_file.get()) < 1); + } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// +// mmap_file_iterator +// +// File iterator for memory mapped files, for now implemented on Windows and +// POSIX platforms. This class has the same interface of std_file_iterator, +// and can be used in its place (in fact, it's the default for Windows and +// POSIX). +// +/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// mmap_file_iterator, Windows version +#ifdef BOOST_SPIRIT_FILEITERATOR_WINDOWS +template +class mmap_file_iterator +{ +public: + typedef CharT value_type; + + mmap_file_iterator() + {} + + explicit mmap_file_iterator(std::string fileName) + { + HANDLE hFile = ::CreateFileA( + fileName.c_str(), + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_FLAG_SEQUENTIAL_SCAN, + NULL + ); + + if (hFile == INVALID_HANDLE_VALUE) + return; + + // Store the size of the file, it's used to construct + // the end iterator + m_filesize = ::GetFileSize(hFile, NULL); + + HANDLE hMap = ::CreateFileMapping( + hFile, + NULL, + PAGE_READONLY, + 0, 0, + NULL + ); + + if (hMap == NULL) + { + ::CloseHandle(hFile); + return; + } + + LPVOID pMem = ::MapViewOfFile( + hMap, + FILE_MAP_READ, + 0, 0, 0 + ); + + if (pMem == NULL) + { + ::CloseHandle(hMap); + ::CloseHandle(hFile); + return; + } + + // We hold both the file handle and the memory pointer. + // We can close the hMap handle now because Windows holds internally + // a reference to it since there is a view mapped. + ::CloseHandle(hMap); + + // It seems like we can close the file handle as well (because + // a reference is hold by the filemap object). + ::CloseHandle(hFile); + + // Store the handles inside the shared_ptr (with the custom destructors) + m_mem.reset(static_cast(pMem), ::UnmapViewOfFile); + + // Start of the file + m_curChar = m_mem.get(); + } + + mmap_file_iterator(const mmap_file_iterator& iter) + { *this = iter; } + + mmap_file_iterator& operator=(const mmap_file_iterator& iter) + { + m_curChar = iter.m_curChar; + m_mem = iter.m_mem; + m_filesize = iter.m_filesize; + + return *this; + } + + // Nasty bug in Comeau up to 4.3.0.1, we need explicit boolean context + // for shared_ptr to evaluate correctly + operator bool() const + { return m_mem ? true : false; } + + bool operator==(const mmap_file_iterator& iter) const + { return m_curChar == iter.m_curChar; } + + const CharT& get_cur_char(void) const + { return *m_curChar; } + + void next_char(void) + { m_curChar++; } + + void prev_char(void) + { m_curChar--; } + + void advance(signed long n) + { m_curChar += n; } + + long distance(const mmap_file_iterator& iter) const + { return m_curChar - iter.m_curChar; } + + void seek_end(void) + { + m_curChar = m_mem.get() + + (m_filesize / sizeof(CharT)); + } + +private: +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + typedef boost::remove_pointer::type handle_t; +#else + typedef void handle_t; +#endif + + boost::shared_ptr m_mem; + std::size_t m_filesize; + CharT* m_curChar; +}; + +#endif // BOOST_SPIRIT_FILEITERATOR_WINDOWS + +/////////////////////////////////////////////////////////////////////////////// +// mmap_file_iterator, POSIX version +#ifdef BOOST_SPIRIT_FILEITERATOR_POSIX +template +class mmap_file_iterator +{ +private: + struct mapping + { + mapping(void *p, off_t len) + : data(p) + , size(len) + { } + + CharT const *begin() const + { + return static_cast(data); + } + + CharT const *end() const + { + return static_cast(data) + size/sizeof(CharT); + } + + ~mapping() + { + munmap(data, size); + } + + private: + void *data; + off_t size; + }; + +public: + typedef CharT value_type; + + mmap_file_iterator() + {} + + explicit mmap_file_iterator(std::string file_name) + { + // open the file + int fd = open(file_name.c_str(), +#ifdef O_NOCTTY + O_NOCTTY | // if stdin was closed then opening a file + // would cause the file to become the controlling + // terminal if the filename refers to a tty. Setting + // O_NOCTTY inhibits this. +#endif + O_RDONLY); + + if (fd == -1) + return; + + // call fstat to find get information about the file just + // opened (size and file type) + struct stat stat_buf; + if ((fstat(fd, &stat_buf) != 0) || !S_ISREG(stat_buf.st_mode)) + { // if fstat returns an error or if the file isn't a + // regular file we give up. + close(fd); + return; + } + + // perform the actual mapping + void *p = mmap(0, stat_buf.st_size, PROT_READ, MAP_SHARED, fd, 0); + // it is safe to close() here. POSIX requires that the OS keeps a + // second handle to the file while the file is mmapped. + close(fd); + + if (p == MAP_FAILED) + return; + + mapping *m = 0; + try + { + m = new mapping(p, stat_buf.st_size); + } + catch(...) + { + munmap(p, stat_buf.st_size); + throw; + } + + m_mem.reset(m); + + // Start of the file + m_curChar = m_mem->begin(); + } + + mmap_file_iterator(const mmap_file_iterator& iter) + { *this = iter; } + + mmap_file_iterator& operator=(const mmap_file_iterator& iter) + { + m_curChar = iter.m_curChar; + m_mem = iter.m_mem; + + return *this; + } + + // Nasty bug in Comeau up to 4.3.0.1, we need explicit boolean context + // for shared_ptr to evaluate correctly + operator bool() const + { return m_mem ? true : false; } + + bool operator==(const mmap_file_iterator& iter) const + { return m_curChar == iter.m_curChar; } + + const CharT& get_cur_char(void) const + { return *m_curChar; } + + void next_char(void) + { m_curChar++; } + + void prev_char(void) + { m_curChar--; } + + void advance(signed long n) + { m_curChar += n; } + + long distance(const mmap_file_iterator& iter) const + { return m_curChar - iter.m_curChar; } + + void seek_end(void) + { + m_curChar = m_mem->end(); + } + +private: + + boost::shared_ptr m_mem; + CharT const* m_curChar; +}; + +#endif // BOOST_SPIRIT_FILEITERATOR_POSIX + +/////////////////////////////////////////////////////////////////////////////// +} /* namespace boost::spirit::fileiter_impl */ + +template +file_iterator +file_iterator::make_end(void) +{ + file_iterator iter(*this); + iter.base_reference().seek_end(); + return iter; +} + +template +file_iterator& +file_iterator::operator=(const base_t& iter) +{ + base_t::operator=(iter); + return *this; +} + +/////////////////////////////////////////////////////////////////////////////// +}} /* namespace boost::spirit */ + + +#endif /* BOOST_SPIRIT_FILE_ITERATOR_IPP */ diff --git a/boost/boost/spirit/iterator/impl/position_iterator.ipp b/boost/boost/spirit/iterator/impl/position_iterator.ipp new file mode 100644 index 0000000000..37e1d7d986 --- /dev/null +++ b/boost/boost/spirit/iterator/impl/position_iterator.ipp @@ -0,0 +1,131 @@ +/*============================================================================= + Copyright (c) 2002 Juan Carlos Arevalo-Baeza + Copyright (c) 2002-2003 Hartmut Kaiser + Copyright (c) 2003 Giovanni Bajo + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef POSITION_ITERATOR_IPP +#define POSITION_ITERATOR_IPP + +#include +#include +#include +#include +#include +#include // for nil_t +#include // for boost::detail::iterator_traits + +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// position_policy +// +// Specialization to handle file_position_without_column. Only take care of +// newlines since no column tracking is needed. +// +/////////////////////////////////////////////////////////////////////////////// +template <> +class position_policy { + +public: + void next_line(file_position_without_column& pos) + { + ++pos.line; + } + + void set_tab_chars(unsigned int /*chars*/){} + void next_char(file_position_without_column& /*pos*/) {} + void tabulation(file_position_without_column& /*pos*/) {} +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// position_policy +// +// Specialization to handle file_position. Track characters and tabulation +// to compute the current column correctly. +// +// Default tab size is 4. You can change this with the set_tabchars member +// of position_iterator. +// +/////////////////////////////////////////////////////////////////////////////// +template <> +class position_policy { + +public: + position_policy() + : m_CharsPerTab(4) + {} + + void next_line(file_position& pos) + { + ++pos.line; + pos.column = 1; + } + + void set_tab_chars(unsigned int chars) + { + m_CharsPerTab = chars; + } + + void next_char(file_position& pos) + { + ++pos.column; + } + + void tabulation(file_position& pos) + { + pos.column += m_CharsPerTab - (pos.column - 1) % m_CharsPerTab; + } + +private: + unsigned int m_CharsPerTab; +}; + +/* namespace boost::spirit { */ namespace iterator_ { namespace impl { + +/////////////////////////////////////////////////////////////////////////////// +// +// position_iterator_base_generator +// +// Metafunction to generate the iterator type using boost::iterator_adaptors, +// hiding all the metaprogramming thunking code in it. It is used +// mainly to keep the public interface (position_iterator) cleanear. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct position_iterator_base_generator +{ +private: + typedef boost::detail::iterator_traits traits; + typedef typename traits::value_type value_type; + typedef typename traits::iterator_category iter_category_t; + + // Position iterator is always a non-mutable iterator + typedef typename boost::add_const::type const_value_type; + +public: + // Check if the MainIterT is nil. If it's nil, it means that the actual + // self type is position_iterator. Otherwise, it's a real type we + // must use + typedef typename boost::mpl::if_< + typename boost::is_same::type, + position_iterator, + MainIterT + >::type main_iter_t; + + typedef boost::iterator_adaptor< + main_iter_t, + ForwardIterT, + const_value_type + > type; +}; + +}}}} /* namespace boost::spirit::iterator_::impl */ + +#endif diff --git a/boost/boost/spirit/iterator/multi_pass.hpp b/boost/boost/spirit/iterator/multi_pass.hpp new file mode 100644 index 0000000000..68397c8091 --- /dev/null +++ b/boost/boost/spirit/iterator/multi_pass.hpp @@ -0,0 +1,1302 @@ +/*============================================================================= + Copyright (c) 2001, Daniel C. Nuffer + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_ITERATOR_MULTI_PASS_HPP +#define BOOST_SPIRIT_ITERATOR_MULTI_PASS_HPP + +#include +#include +#include +#include +#include +#include // for std::swap +#include // for std::exception +#include +#include + +#include // for BOOST_SPIRIT_ASSERT +#include +#include // for boost::detail::iterator_traits + +namespace boost { namespace spirit { + +namespace impl { + template + inline void mp_swap(T& t1, T& t2); +} + +namespace multi_pass_policies +{ + +/////////////////////////////////////////////////////////////////////////////// +// class ref_counted +// Implementation of an OwnershipPolicy used by multi_pass. +// +// Implementation modified from RefCounted class from the Loki library by +// Andrei Alexandrescu +/////////////////////////////////////////////////////////////////////////////// +class ref_counted +{ + protected: + ref_counted() + : count(new std::size_t(1)) + {} + + ref_counted(ref_counted const& x) + : count(x.count) + {} + + // clone is called when a copy of the iterator is made, so increment + // the ref-count. + void clone() + { + ++*count; + } + + // called when a copy is deleted. Decrement the ref-count. Return + // value of true indicates that the last copy has been released. + bool release() + { + if (!--*count) + { + delete count; + count = 0; + return true; + } + return false; + } + + void swap(ref_counted& x) + { + impl::mp_swap(count, x.count); + } + + public: + // returns true if there is only one iterator in existence. + // std_deque StoragePolicy will free it's buffered data if this + // returns true. + bool unique() const + { + return *count == 1; + } + + private: + std::size_t* count; +}; + +/////////////////////////////////////////////////////////////////////////////// +// class first_owner +// Implementation of an OwnershipPolicy used by multi_pass +// This ownership policy dictates that the first iterator created will +// determine the lifespan of the shared components. This works well for +// spirit, since no dynamic allocation of iterators is done, and all copies +// are make on the stack. +// +// There is a caveat about using this policy together with the std_deque +// StoragePolicy. Since first_owner always returns false from unique(), +// std_deque will only release the queued data if clear_queue() is called. +/////////////////////////////////////////////////////////////////////////////// +class first_owner +{ + protected: + first_owner() + : first(true) + {} + + first_owner(first_owner const&) + : first(false) + {} + + void clone() + { + } + + // return true to indicate deletion of resources + bool release() + { + return first; + } + + void swap(first_owner&) + { + // if we're the first, we still remain the first, even if assigned + // to, so don't swap first_. swap is only called from operator= + } + + public: + bool unique() const + { + return false; // no way to know, so always return false + } + + private: + bool first; +}; + +/////////////////////////////////////////////////////////////////////////////// +// class illegal_backtracking +// thrown by buf_id_check CheckingPolicy if an instance of an iterator is +// used after another one has invalidated the queue +/////////////////////////////////////////////////////////////////////////////// +class illegal_backtracking : public std::exception +{ +public: + + illegal_backtracking() throw() {} + ~illegal_backtracking() throw() {} + + virtual const char* + what() const throw() + { return "boost::spirit::illegal_backtracking"; } +}; + +/////////////////////////////////////////////////////////////////////////////// +// class buf_id_check +// Implementation of the CheckingPolicy used by multi_pass +// This policy is most effective when used together with the std_deque +// StoragePolicy. +// If used with the fixed_size_queue StoragePolicy, it will not detect +// iterator derefereces that are out of the range of the queue. +/////////////////////////////////////////////////////////////////////////////// +class buf_id_check +{ + protected: + buf_id_check() + : shared_buf_id(new unsigned long(0)) + , buf_id(0) + {} + + buf_id_check(buf_id_check const& x) + : shared_buf_id(x.shared_buf_id) + , buf_id(x.buf_id) + {} + + // will be called from the destructor of the last iterator. + void destroy() + { + delete shared_buf_id; + shared_buf_id = 0; + } + + void swap(buf_id_check& x) + { + impl::mp_swap(shared_buf_id, x.shared_buf_id); + impl::mp_swap(buf_id, x.buf_id); + } + + // called to verify that everything is okay. + void check() const + { + if (buf_id != *shared_buf_id) + { + boost::throw_exception(illegal_backtracking()); + } + } + + // called from multi_pass::clear_queue, so we can increment the count + void clear_queue() + { + ++*shared_buf_id; + ++buf_id; + } + + private: + unsigned long* shared_buf_id; + unsigned long buf_id; +}; + +/////////////////////////////////////////////////////////////////////////////// +// class no_check +// Implementation of the CheckingPolicy used by multi_pass +// It does not do anything :-) +/////////////////////////////////////////////////////////////////////////////// +class no_check +{ + protected: + no_check() {} + no_check(no_check const&) {} + void destroy() {} + void swap(no_check&) {} + void check() const {} + void clear_queue() {} +}; + +/////////////////////////////////////////////////////////////////////////////// +// class std_deque +// Implementation of the StoragePolicy used by multi_pass +// This stores all data in a std::deque, and keeps an offset to the current +// position. It stores all the data unless there is only one +// iterator using the queue. +// Note: a position is used instead of an iterator, because a push_back on +// a deque can invalidate any iterators. +/////////////////////////////////////////////////////////////////////////////// +class std_deque +{ + public: + +template +class inner +{ + private: + + typedef std::deque queue_type; + queue_type* queuedElements; + mutable typename queue_type::size_type queuePosition; + + protected: + inner() + : queuedElements(new queue_type) + , queuePosition(0) + {} + + inner(inner const& x) + : queuedElements(x.queuedElements) + , queuePosition(x.queuePosition) + {} + + // will be called from the destructor of the last iterator. + void destroy() + { + BOOST_SPIRIT_ASSERT(queuedElements); + delete queuedElements; + queuedElements = 0; + } + + void swap(inner& x) + { + impl::mp_swap(queuedElements, x.queuedElements); + impl::mp_swap(queuePosition, x.queuePosition); + } + + // This is called when the iterator is dereferenced. It's a template + // method so we can recover the type of the multi_pass iterator + // and call unique and access the m_input data member. + template + static typename MultiPassT::reference dereference(MultiPassT const& mp) + { + if (mp.queuePosition == mp.queuedElements->size()) + { + // check if this is the only iterator + if (mp.unique()) + { + // free up the memory used by the queue. + if (mp.queuedElements->size() > 0) + { + mp.queuedElements->clear(); + mp.queuePosition = 0; + } + } + return mp.get_input(); + } + else + { + return (*mp.queuedElements)[mp.queuePosition]; + } + } + + // This is called when the iterator is incremented. It's a template + // method so we can recover the type of the multi_pass iterator + // and call unique and access the m_input data member. + template + static void increment(MultiPassT& mp) + { + if (mp.queuePosition == mp.queuedElements->size()) + { + // check if this is the only iterator + if (mp.unique()) + { + // free up the memory used by the queue. + if (mp.queuedElements->size() > 0) + { + mp.queuedElements->clear(); + mp.queuePosition = 0; + } + } + else + { + mp.queuedElements->push_back(mp.get_input()); + ++mp.queuePosition; + } + mp.advance_input(); + } + else + { + ++mp.queuePosition; + } + + } + + // called to forcibly clear the queue + void clear_queue() + { + queuedElements->clear(); + queuePosition = 0; + } + + // called to determine whether the iterator is an eof iterator + template + static bool is_eof(MultiPassT const& mp) + { + return mp.queuePosition == mp.queuedElements->size() && + mp.input_at_eof(); + } + + // called by operator== + bool equal_to(inner const& x) const + { + return queuePosition == x.queuePosition; + } + + // called by operator< + bool less_than(inner const& x) const + { + return queuePosition < x.queuePosition; + } +}; // class inner + +}; // class std_deque + + +/////////////////////////////////////////////////////////////////////////////// +// class fixed_size_queue +// Implementation of the StoragePolicy used by multi_pass +// fixed_size_queue keeps a circular buffer (implemented by +// boost::spirit::fixed_size_queue class) that is size N+1 and stores N elements. +// It is up to the user to ensure that there is enough look ahead for their +// grammar. Currently there is no way to tell if an iterator is pointing +// to forgotten data. The leading iterator will put an item in the queue +// and remove one when it is incremented. No dynamic allocation is done, +// except on creation of the queue (fixed_size_queue constructor). +/////////////////////////////////////////////////////////////////////////////// +template < std::size_t N> +class fixed_size_queue +{ + public: + +template +class inner +{ + private: + + typedef boost::spirit::fixed_size_queue queue_type; + queue_type * queuedElements; + mutable typename queue_type::iterator queuePosition; + + protected: + inner() + : queuedElements(new queue_type) + , queuePosition(queuedElements->begin()) + {} + + inner(inner const& x) + : queuedElements(x.queuedElements) + , queuePosition(x.queuePosition) + {} + + // will be called from the destructor of the last iterator. + void destroy() + { + BOOST_SPIRIT_ASSERT(queuedElements); + delete queuedElements; + queuedElements = 0; + } + + void swap(inner& x) + { + impl::mp_swap(queuedElements, x.queuedElements); + impl::mp_swap(queuePosition, x.queuePosition); + } + + // This is called when the iterator is dereferenced. It's a template + // method so we can recover the type of the multi_pass iterator + // and access the m_input data member. + template + static typename MultiPassT::reference dereference(MultiPassT const& mp) + { + if (mp.queuePosition == mp.queuedElements->end()) + { + return mp.get_input(); + } + else + { + return *mp.queuePosition; + } + } + + // This is called when the iterator is incremented. It's a template + // method so we can recover the type of the multi_pass iterator + // and access the m_input data member. + template + static void increment(MultiPassT& mp) + { + if (mp.queuePosition == mp.queuedElements->end()) + { + // don't let the queue get larger than N + if (mp.queuedElements->size() >= N) + mp.queuedElements->pop_front(); + + mp.queuedElements->push_back(mp.get_input()); + mp.advance_input(); + } + ++mp.queuePosition; + } + + // no-op + void clear_queue() + {} + + // called to determine whether the iterator is an eof iterator + template + static bool is_eof(MultiPassT const& mp) + { + return mp.queuePosition == mp.queuedElements->end() && + mp.input_at_eof(); + } + + // called by operator== + bool equal_to(inner const& x) const + { + return queuePosition == x.queuePosition; + } + + // called by operator< + bool less_than(inner const& x) const + { + return queuePosition < x.queuePosition; + } +}; // class inner + +}; // class fixed_size_queue + + +/////////////////////////////////////////////////////////////////////////////// +// class input_iterator +// Implementation of the InputPolicy used by multi_pass +// input_iterator encapsulates an input iterator of type InputT +/////////////////////////////////////////////////////////////////////////////// +class input_iterator +{ + public: + +template +class inner +{ + typedef + typename boost::detail::iterator_traits::value_type + result_type; + + struct Data { + Data(InputT const &input_) + : input(input_), was_initialized(false) + {} + + InputT input; + result_type curtok; + bool was_initialized; + }; + + public: + typedef result_type value_type; + typedef + typename boost::detail::iterator_traits::difference_type + difference_type; + typedef + typename boost::detail::iterator_traits::pointer + pointer; + typedef + typename boost::detail::iterator_traits::reference + reference; + + protected: + inner() + : data(0) + {} + + inner(InputT x) + : data(new Data(x)) + {} + + inner(inner const& x) + : data(x.data) + {} + + void destroy() + { + delete data; + data = 0; + } + + bool same_input(inner const& x) const + { + return data == x.data; + } + + typedef + typename boost::detail::iterator_traits::value_type + value_t; + void swap(inner& x) + { + impl::mp_swap(data, x.data); + } + + void ensure_initialized() const + { + if (data && !data->was_initialized) { + data->curtok = *data->input; // get the first token + data->was_initialized = true; + } + } + + public: + reference get_input() const + { + BOOST_SPIRIT_ASSERT(0 != data); + ensure_initialized(); + return data->curtok; + } + + void advance_input() + { + BOOST_SPIRIT_ASSERT(0 != data); + data->was_initialized = false; // should get the next token + ++data->input; + } + + bool input_at_eof() const + { + return !data || data->input == InputT(); + } + + private: + Data *data; +}; + +}; + +/////////////////////////////////////////////////////////////////////////////// +// class lex_input +// Implementation of the InputPolicy used by multi_pass +// lex_input gets tokens (ints) from yylex() +/////////////////////////////////////////////////////////////////////////////// +class lex_input +{ + public: + +template +class inner +{ + public: + typedef int value_type; + typedef std::ptrdiff_t difference_type; + typedef int* pointer; + typedef int& reference; + + protected: + inner() + : curtok(new int(0)) + {} + + inner(InputT x) + : curtok(new int(x)) + {} + + inner(inner const& x) + : curtok(x.curtok) + {} + + void destroy() + { + delete curtok; + curtok = 0; + } + + bool same_input(inner const& x) const + { + return curtok == x.curtok; + } + + void swap(inner& x) + { + impl::mp_swap(curtok, x.curtok); + } + + public: + reference get_input() const + { + return *curtok; + } + + void advance_input() + { + extern int yylex(); + *curtok = yylex(); + } + + bool input_at_eof() const + { + return *curtok == 0; + } + + private: + int* curtok; + +}; + +}; + +/////////////////////////////////////////////////////////////////////////////// +// class functor_input +// Implementation of the InputPolicy used by multi_pass +// functor_input gets tokens from a functor +// Note: the functor must have a typedef for result_type +// It also must have a static variable of type result_type defined to +// represent eof that is called eof. +/////////////////////////////////////////////////////////////////////////////// +class functor_input +{ + public: + +template +class inner +{ + typedef typename FunctorT::result_type result_type; + public: + typedef result_type value_type; + typedef std::ptrdiff_t difference_type; + typedef result_type* pointer; + typedef result_type& reference; + + protected: + inner() + : ftor(0) + , curtok(0) + {} + + inner(FunctorT const& x) + : ftor(new FunctorT(x)) + , curtok(new result_type((*ftor)())) + {} + + inner(inner const& x) + : ftor(x.ftor) + , curtok(x.curtok) + {} + + void destroy() + { + delete ftor; + ftor = 0; + delete curtok; + curtok = 0; + } + + bool same_input(inner const& x) const + { + return ftor == x.ftor; + } + + void swap(inner& x) + { + impl::mp_swap(curtok, x.curtok); + impl::mp_swap(ftor, x.ftor); + } + + public: + reference get_input() const + { + return *curtok; + } + + void advance_input() + { + if (curtok) { + *curtok = (*ftor)(); + } + } + + bool input_at_eof() const + { + return !curtok || *curtok == ftor->eof; + } + + FunctorT& get_functor() const + { + return *ftor; + } + + + private: + FunctorT* ftor; + result_type* curtok; + +}; + +}; + +} // namespace multi_pass_policies + +/////////////////////////////////////////////////////////////////////////////// +// iterator_base_creator +/////////////////////////////////////////////////////////////////////////////// + +namespace iterator_ { namespace impl { + +// Meta-function to generate a std::iterator<> base class for multi_pass. This +// is used mainly to improve conformance of compilers not supporting PTS +// and thus relying on inheritance to recognize an iterator. +// We are using boost::iterator<> because it offers an automatic workaround +// for broken std::iterator<> implementations. +template +struct iterator_base_creator +{ + typedef typename InputPolicyT::BOOST_NESTED_TEMPLATE inner input_t; + + typedef boost::iterator + < + std::forward_iterator_tag, + typename input_t::value_type, + typename input_t::difference_type, + typename input_t::pointer, + typename input_t::reference + > type; +}; + +}} + + + +/////////////////////////////////////////////////////////////////////////////// +// class template multi_pass (declaration) +/////////////////////////////////////////////////////////////////////////////// +template +< + typename InputT, + typename InputPolicy = multi_pass_policies::input_iterator, + typename OwnershipPolicy = multi_pass_policies::ref_counted, + typename CheckingPolicy = multi_pass_policies::buf_id_check, + typename StoragePolicy = multi_pass_policies::std_deque +> +class multi_pass; + +// The default multi_pass instantiation uses a ref-counted std_deque scheme. + +/////////////////////////////////////////////////////////////////////////////// +// class template multi_pass (definition) +/////////////////////////////////////////////////////////////////////////////// +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +class multi_pass + : public OwnershipPolicy + , public CheckingPolicy + , public StoragePolicy::template inner< + typename InputPolicy::template inner::value_type> + , public InputPolicy::template inner + , public iterator_::impl::iterator_base_creator::type +{ + typedef OwnershipPolicy OP; + typedef CheckingPolicy CHP; + typedef typename StoragePolicy::template inner< + typename InputPolicy::template inner::value_type> SP; + typedef typename InputPolicy::template inner IP; + typedef typename + iterator_::impl::iterator_base_creator::type + IB; + + public: + typedef typename IB::value_type value_type; + typedef typename IB::difference_type difference_type; + typedef typename IB::reference reference; + typedef typename IB::pointer pointer; + typedef InputT iterator_type; + + multi_pass(); + explicit multi_pass(InputT input); + +#if BOOST_WORKAROUND(__GLIBCPP__, == 20020514) + multi_pass(int); +#endif // BOOST_WORKAROUND(__GLIBCPP__, == 20020514) + + ~multi_pass(); + + multi_pass(multi_pass const&); + multi_pass& operator=(multi_pass const&); + + void swap(multi_pass& x); + + reference operator*() const; + pointer operator->() const; + multi_pass& operator++(); + multi_pass operator++(int); + + void clear_queue(); + + bool operator==(const multi_pass& y) const; + bool operator<(const multi_pass& y) const; + + private: // helper functions + bool is_eof() const; +}; + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +multi_pass:: +multi_pass() + : OP() + , CHP() + , SP() + , IP() +{ +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +multi_pass:: +multi_pass(InputT input) + : OP() + , CHP() + , SP() + , IP(input) +{ +} + +#if BOOST_WORKAROUND(__GLIBCPP__, == 20020514) + // The standard library shipped with gcc-3.1 has a bug in + // bits/basic_string.tcc. It tries to use iter::iter(0) to + // construct an iterator. Ironically, this happens in sanity + // checking code that isn't required by the standard. + // The workaround is to provide an additional constructor that + // ignores its int argument and behaves like the default constructor. +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +multi_pass:: +multi_pass(int) + : OP() + , CHP() + , SP() + , IP() +{ +} +#endif // BOOST_WORKAROUND(__GLIBCPP__, == 20020514) + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +multi_pass:: +~multi_pass() +{ + if (OP::release()) + { + CHP::destroy(); + SP::destroy(); + IP::destroy(); + } +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +multi_pass:: +multi_pass( + multi_pass const& x) + : OP(x) + , CHP(x) + , SP(x) + , IP(x) +{ + OP::clone(); +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +multi_pass& +multi_pass:: +operator=( + multi_pass const& x) +{ + multi_pass temp(x); + temp.swap(*this); + return *this; +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline void +multi_pass:: +swap(multi_pass& x) +{ + OP::swap(x); + CHP::swap(x); + SP::swap(x); + IP::swap(x); +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +typename multi_pass:: +reference +multi_pass:: +operator*() const +{ + CHP::check(); + return SP::dereference(*this); +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +typename multi_pass:: +pointer +multi_pass:: +operator->() const +{ + return &(operator*()); +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +multi_pass& +multi_pass:: +operator++() +{ + CHP::check(); + SP::increment(*this); + return *this; +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +multi_pass +multi_pass:: +operator++(int) +{ + multi_pass + < + InputT, + InputPolicy, + OwnershipPolicy, + CheckingPolicy, + StoragePolicy + > tmp(*this); + + ++*this; + + return tmp; +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline void +multi_pass:: +clear_queue() +{ + SP::clear_queue(); + CHP::clear_queue(); +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline bool +multi_pass:: +is_eof() const +{ + return SP::is_eof(*this); +} + +///// Comparisons +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline bool +multi_pass:: +operator==(const multi_pass& y) const +{ + bool is_eof_ = SP::is_eof(*this); + bool y_is_eof_ = SP::is_eof(y); + + if (is_eof_ && y_is_eof_) + { + return true; // both are EOF + } + else if (is_eof_ ^ y_is_eof_) + { + return false; // one is EOF, one isn't + } + else if (!IP::same_input(y)) + { + return false; + } + else + { + return SP::equal_to(y); + } +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline bool +multi_pass:: +operator<(const multi_pass& y) const +{ + return SP::less_than(y); +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +bool operator!=( + const multi_pass& x, + const multi_pass& y) +{ + return !(x == y); +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +bool operator>( + const multi_pass& x, + const multi_pass& y) +{ + return y < x; +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +bool operator>=( + const multi_pass& x, + const multi_pass& y) +{ + return !(x < y); +} + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +inline +bool operator<=( + const multi_pass& x, + const multi_pass& y) +{ + return !(y < x); +} + +///// Generator function +template +inline multi_pass +make_multi_pass(InputT i) +{ + return multi_pass(i); +} + +// this could be a template typedef, since such a thing doesn't +// exist in C++, we'll use inheritance to accomplish the same thing. + +template +class look_ahead : + public multi_pass< + InputT, + multi_pass_policies::input_iterator, + multi_pass_policies::first_owner, + multi_pass_policies::no_check, + multi_pass_policies::fixed_size_queue > +{ + typedef multi_pass< + InputT, + multi_pass_policies::input_iterator, + multi_pass_policies::first_owner, + multi_pass_policies::no_check, + multi_pass_policies::fixed_size_queue > base_t; + public: + look_ahead() + : base_t() {} + + explicit look_ahead(InputT x) + : base_t(x) {} + + look_ahead(look_ahead const& x) + : base_t(x) {} + +#if BOOST_WORKAROUND(__GLIBCPP__, == 20020514) + look_ahead(int) // workaround for a bug in the library + : base_t() {} // shipped with gcc 3.1 +#endif // BOOST_WORKAROUND(__GLIBCPP__, == 20020514) + + // default generated operators destructor and assignment operator are okay. +}; + +template +< + typename InputT, + typename InputPolicy, + typename OwnershipPolicy, + typename CheckingPolicy, + typename StoragePolicy +> +void swap( + multi_pass< + InputT, InputPolicy, OwnershipPolicy, CheckingPolicy, StoragePolicy + > &x, + multi_pass< + InputT, InputPolicy, OwnershipPolicy, CheckingPolicy, StoragePolicy + > &y) +{ + x.swap(y); +} + +namespace impl { + + template + inline void mp_swap(T& t1, T& t2) + { + using std::swap; + using boost::spirit::swap; + swap(t1, t2); + } +} + +}} // namespace boost::spirit + +#endif // BOOST_SPIRIT_ITERATOR_MULTI_PASS_HPP + + diff --git a/boost/boost/spirit/iterator/position_iterator.hpp b/boost/boost/spirit/iterator/position_iterator.hpp new file mode 100644 index 0000000000..506b4b4a20 --- /dev/null +++ b/boost/boost/spirit/iterator/position_iterator.hpp @@ -0,0 +1,432 @@ +/*============================================================================= + Copyright (c) 2002 Juan Carlos Arevalo-Baeza + Copyright (c) 2002-2003 Hartmut Kaiser + Copyright (c) 2003 Giovanni Bajo + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_POSITION_ITERATOR_HPP +#define BOOST_SPIRIT_POSITION_ITERATOR_HPP + +#include +#include +#include + +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// file_position_without_column +// +// A structure to hold positional information. This includes the file, +// and the line number +// +/////////////////////////////////////////////////////////////////////////////// +struct file_position_without_column { + std::string file; + int line; + + file_position_without_column(std::string const& file_ = std::string(), + int line_ = 1): + file (file_), + line (line_) + {} + + bool operator==(const file_position_without_column& fp) const + { return line == fp.line && file == fp.file; } +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// file_position +// +// This structure holds complete file position, including file name, +// line and column number +// +/////////////////////////////////////////////////////////////////////////////// +struct file_position : public file_position_without_column { + int column; + + file_position(std::string const& file_ = std::string(), + int line_ = 1, int column_ = 1): + file_position_without_column (file_, line_), + column (column_) + {} + + bool operator==(const file_position& fp) const + { return column == fp.column && line == fp.line && file == fp.file; } +}; + + +/////////////////////////////////////////////////////////////////////////////// +// +// position_policy<> +// +// This template is the policy to handle the file position. It is specialized +// on the position type. Providing a custom file_position also requires +// providing a specialization of this class. +// +// Policy interface: +// +// Default constructor of the custom position class must be accessible. +// set_tab_chars(unsigned int chars) - Set the tabstop width +// next_char(PositionT& pos) - Notify that a new character has been +// processed +// tabulation(PositionT& pos) - Notify that a tab character has been +// processed +// next_line(PositionT& pos) - Notify that a new line delimiter has +// been reached. +// +/////////////////////////////////////////////////////////////////////////////// +template +class position_policy; + + +// Forward declaration +template +class position_iterator; + +/////////////////////////////////////////////////////////////////////////////// +}} /* namespace boost::spirit */ + + +// This must be included here for full compatibility with old MSVC +#include "impl/position_iterator.ipp" + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// position_iterator +// +// It wraps an iterator, and keeps track of the current position in the input, +// as it gets incremented. +// +// The wrapped iterator must be at least a Forward iterator. The position +// iterator itself will always be a non-mutable Forward iterator. +// +// In order to have begin/end iterators constructed, the end iterator must be +// empty constructed. Similar to what happens with stream iterators. The begin +// iterator must be constructed from both, the begin and end iterators of the +// wrapped iterator type. This is necessary to implement the lookahead of +// characters necessary to parse CRLF sequences. +// +// In order to extract the current positional data from the iterator, you may +// use the get_position member function. +// +// You can also use the set_position member function to reset the current +// position to something new. +// +// The structure that holds the current position can be customized through a +// template parameter, and the class position_policy must be specialized +// on the new type to define how to handle it. Currently, it's possible +// to choose between the file_position and file_position_without_column +// (which saves some overhead if managing current column is not required). +// +/////////////////////////////////////////////////////////////////////////////// + +#if !defined(BOOST_ITERATOR_ADAPTORS_VERSION) || \ + BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200 +#error "Please use at least Boost V1.31.0 while compiling the position_iterator class!" +#else // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200 + +/////////////////////////////////////////////////////////////////////////////// +// +// Uses the newer iterator_adaptor version (should be released with +// Boost V1.31.0) +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename ForwardIteratorT, + typename PositionT = file_position, + typename SelfT = nil_t +> +class position_iterator +: public iterator_::impl::position_iterator_base_generator< + SelfT, + ForwardIteratorT, + PositionT + >::type, + public position_policy +{ +private: + + typedef position_policy position_policy_t; + typedef typename iterator_::impl::position_iterator_base_generator< + SelfT, + ForwardIteratorT, + PositionT + >::type base_t; + typedef typename iterator_::impl::position_iterator_base_generator< + SelfT, + ForwardIteratorT, + PositionT + >::main_iter_t main_iter_t; + +public: + + typedef PositionT position_t; + + position_iterator() + : _isend(true) + {} + + position_iterator( + const ForwardIteratorT& begin, + const ForwardIteratorT& end) + : base_t(begin), _end(end), _pos(PositionT()), _isend(begin == end) + {} + + template + position_iterator( + const ForwardIteratorT& begin, + const ForwardIteratorT& end, + FileNameT fileName) + : base_t(begin), _end(end), _pos(PositionT(fileName)), + _isend(begin == end) + {} + + template + position_iterator( + const ForwardIteratorT& begin, + const ForwardIteratorT& end, + FileNameT fileName, LineT line) + : base_t(begin), _end(end), _pos(PositionT(fileName, line)), + _isend(begin == end) + {} + + template + position_iterator( + const ForwardIteratorT& begin, + const ForwardIteratorT& end, + FileNameT fileName, LineT line, ColumnT column) + : base_t(begin), _end(end), _pos(PositionT(fileName, line, column)), + _isend(begin == end) + {} + + position_iterator( + const ForwardIteratorT& begin, + const ForwardIteratorT& end, + const PositionT& pos) + : base_t(begin), _end(end), _pos(pos), _isend(begin == end) + {} + + position_iterator(const position_iterator& iter) + : base_t(iter.base()), position_policy_t(iter), + _end(iter._end), _pos(iter._pos), _isend(iter._isend) + {} + + position_iterator& operator=(const position_iterator& iter) + { + base_t::operator=(iter); + position_policy_t::operator=(iter); + _end = iter._end; + _pos = iter._pos; + _isend = iter._isend; + return *this; + } + + void set_position(PositionT const& newpos) { _pos = newpos; } + PositionT& get_position() { return _pos; } + PositionT const& get_position() const { return _pos; } + + void set_tabchars(unsigned int chars) + { + // This function (which comes from the position_policy) has a + // different name on purpose, to avoid messing with using + // declarations or qualified calls to access the base template + // function, which might break some compilers. + this->position_policy_t::set_tab_chars(chars); + } + +private: + friend class boost::iterator_core_access; + + void increment() + { + typename base_t::reference val = *(this->base()); + if (val == '\n' || val == '\r') { + ++this->base_reference(); + if (this->base_reference() != _end) { + typename base_t::reference val2 = *(this->base()); + if ((val == '\n' && val2 == '\r') + || (val == '\r' && val2 == '\n')) + { + ++this->base_reference(); + } + } + this->next_line(_pos); + static_cast(*this).newline(); + } + else if (val == '\t') { + this->tabulation(_pos); + ++this->base_reference(); + } + else { + this->next_char(_pos); + ++this->base_reference(); + } + + // The iterator is at the end only if it's the same + // of the + _isend = (this->base_reference() == _end); + } + + template < + typename OtherDerivedT, typename OtherIteratorT, + typename V, typename C, typename R, typename D + > + bool equal(iterator_adaptor + const &x) const + { + OtherDerivedT const &rhs = static_cast(x); + bool x_is_end = rhs._isend; + + return (_isend && x_is_end) || + (!_isend && !x_is_end && this->base() == rhs.base()); + } + +protected: + + void newline(void) + {} + + ForwardIteratorT _end; + PositionT _pos; + bool _isend; +}; + +#endif // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200 + +/////////////////////////////////////////////////////////////////////////////// +// +// position_iterator2 +// +// Equivalent to position_iterator, but it is able to extract the current +// line into a string. This is very handy for error reports. +// +// Notice that the footprint of this class is higher than position_iterator, +// (how much depends on how bulky the underlying iterator is), so it should +// be used only if necessary. +// +/////////////////////////////////////////////////////////////////////////////// + +template +< + typename ForwardIteratorT, + typename PositionT = file_position +> +class position_iterator2 + : public position_iterator + < + ForwardIteratorT, + PositionT, + position_iterator2 + > +{ + typedef position_iterator + < + ForwardIteratorT, + PositionT, + position_iterator2 // JDG 4-15-03 + > base_t; + +public: + typedef typename base_t::value_type value_type; + typedef PositionT position_t; + + position_iterator2() + {} + + position_iterator2( + const ForwardIteratorT& begin, + const ForwardIteratorT& end): + base_t(begin, end), + _startline(begin) + {} + + template + position_iterator2( + const ForwardIteratorT& begin, + const ForwardIteratorT& end, + FileNameT file): + base_t(begin, end, file), + _startline(begin) + {} + + template + position_iterator2( + const ForwardIteratorT& begin, + const ForwardIteratorT& end, + FileNameT file, LineT line): + base_t(begin, end, file, line), + _startline(begin) + {} + + template + position_iterator2( + const ForwardIteratorT& begin, + const ForwardIteratorT& end, + FileNameT file, LineT line, ColumnT column): + base_t(begin, end, file, line, column), + _startline(begin) + {} + + position_iterator2( + const ForwardIteratorT& begin, + const ForwardIteratorT& end, + const PositionT& pos): + base_t(begin, end, pos), + _startline(begin) + {} + + position_iterator2(const position_iterator2& iter) + : base_t(iter), _startline(iter._startline) + {} + + position_iterator2& operator=(const position_iterator2& iter) + { + base_t::operator=(iter); + _startline = iter._startline; + return *this; + } + + ForwardIteratorT get_currentline_begin(void) const + { return _startline; } + + ForwardIteratorT get_currentline_end(void) const + { return get_endline(); } + + std::basic_string get_currentline(void) const + { + return std::basic_string + (get_currentline_begin(), get_currentline_end()); + } + +protected: + ForwardIteratorT _startline; + + friend class position_iterator >; + + ForwardIteratorT get_endline() const + { + ForwardIteratorT endline = _startline; + while (endline != this->_end && *endline != '\r' && *endline != '\n') + { + ++endline; + } + return endline; + } + + void newline(void) + { _startline = this->base(); } +}; + +}} // namespace boost::spirit + +#endif diff --git a/boost/boost/spirit/meta.hpp b/boost/boost/spirit/meta.hpp new file mode 100644 index 0000000000..85876f39b5 --- /dev/null +++ b/boost/boost/spirit/meta.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 1998-2003 Joel de Guzman + Copyright (c) 2001-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_META_MAIN_HPP) +#define BOOST_SPIRIT_META_MAIN_HPP + +#include + +/////////////////////////////////////////////////////////////////////////////// +// +// Master header for Spirit.Meta +// +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include + +#endif // BOOST_SPIRIT_CORE_MAIN_HPP + diff --git a/boost/boost/spirit/meta/as_parser.hpp b/boost/boost/spirit/meta/as_parser.hpp new file mode 100644 index 0000000000..53d58775ca --- /dev/null +++ b/boost/boost/spirit/meta/as_parser.hpp @@ -0,0 +1,109 @@ +/*============================================================================= + Copyright (c) 2002-2003 Joel de Guzman + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_AS_PARSER_HPP) +#define BOOST_SPIRIT_AS_PARSER_HPP + +#include + +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // + // Helper templates to derive the parser type from an auxilliary type + // and to generate an object of the required parser type given an + // auxilliary object. Supported types to convert are parsers, + // single characters and character strings. + // + /////////////////////////////////////////////////////////////////////////// + namespace impl + { + template + struct default_as_parser + { + typedef T type; + static type const& convert(type const& p) + { + return p; + } + }; + + struct char_as_parser + { + typedef chlit type; + static type convert(char ch) + { + return type(ch); + } + }; + + struct wchar_as_parser + { + typedef chlit type; + static type convert(wchar_t ch) + { + return type(ch); + } + }; + + struct string_as_parser + { + typedef strlit type; + static type convert(char const* str) + { + return type(str); + } + }; + + struct wstring_as_parser + { + typedef strlit type; + static type convert(wchar_t const* str) + { + return type(str); + } + }; + } + + template + struct as_parser : impl::default_as_parser {}; + + template<> + struct as_parser : impl::char_as_parser {}; + + template<> + struct as_parser : impl::wchar_as_parser {}; + + template<> + struct as_parser : impl::string_as_parser {}; + + template<> + struct as_parser : impl::string_as_parser {}; + + template<> + struct as_parser : impl::wstring_as_parser {}; + + template<> + struct as_parser : impl::wstring_as_parser {}; + + template + struct as_parser : impl::string_as_parser {}; + + template + struct as_parser : impl::wstring_as_parser {}; + + template + struct as_parser : impl::string_as_parser {}; + + template + struct as_parser : impl::wstring_as_parser {}; + +}} // namespace boost::spirit + +#endif diff --git a/boost/boost/spirit/meta/fundamental.hpp b/boost/boost/spirit/meta/fundamental.hpp new file mode 100644 index 0000000000..cb0986cbc0 --- /dev/null +++ b/boost/boost/spirit/meta/fundamental.hpp @@ -0,0 +1,52 @@ +/*============================================================================= + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_FUNDAMENTAL_HPP) +#define BOOST_SPIRIT_FUNDAMENTAL_HPP + +#include + +namespace boost { namespace spirit +{ + /////////////////////////////////////////////////////////////////////////// + // + // Helper template for counting the number of nodes contained in a + // given parser type. + // All parser_category type parsers are counted as nodes. + // + /////////////////////////////////////////////////////////////////////////// + template + struct node_count { + + typedef typename ParserT::parser_category_t parser_category_t; + typedef typename impl::nodes + ::template count > count_t; + + BOOST_STATIC_CONSTANT(int, value = count_t::value); + }; + + /////////////////////////////////////////////////////////////////////////// + // + // Helper template for counting the number of leaf nodes contained in a + // given parser type. + // Only plain_parser_category type parsers are counted as leaf nodes. + // + /////////////////////////////////////////////////////////////////////////// + template + struct leaf_count { + + typedef typename ParserT::parser_category_t parser_category_t; + typedef typename impl::leafs + ::template count > count_t; + + BOOST_STATIC_CONSTANT(int, value = count_t::value); + }; + +}} // namespace boost::spirit + +#endif // !defined(BOOST_SPIRIT_FUNDAMENTAL_HPP) diff --git a/boost/boost/spirit/meta/impl/fundamental.ipp b/boost/boost/spirit/meta/impl/fundamental.ipp new file mode 100644 index 0000000000..f0b16ca45a --- /dev/null +++ b/boost/boost/spirit/meta/impl/fundamental.ipp @@ -0,0 +1,305 @@ +/*============================================================================= + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_FUNDAMENTAL_IPP) +#define BOOST_SPIRIT_FUNDAMENTAL_IPP + +#include + +namespace boost { namespace spirit { + +#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) + BOOST_SPIRIT_DEPENDENT_TEMPLATE_WRAPPER2(count_wrapper, count); +#endif // defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////// + // + // Helper template for counting the number of nodes contained in a + // given parser type. + // All parser_category type parsers are counted as nodes. + // + /////////////////////////////////////////////////////////////////////////// + template + struct nodes; + + template <> + struct nodes { + + template + struct count { + + // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT + enum { value = (LeafCountT::value + 1) }; + }; + }; + +#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) + + template <> + struct nodes { + + template + struct count { + + typedef typename ParserT::subject_t subject_t; + typedef typename subject_t::parser_category_t subject_category_t; + + typedef nodes nodes_t; + typedef typename count_wrapper + ::template result_ count_t; + + BOOST_STATIC_CONSTANT(int, value = count_t::value + 1); + }; + }; + + template <> + struct nodes { + + template + struct count { + + typedef typename ParserT::subject_t subject_t; + typedef typename subject_t::parser_category_t subject_category_t; + + typedef nodes nodes_t; + typedef typename count_wrapper + ::template result_ count_t; + + BOOST_STATIC_CONSTANT(int, value = count_t::value + 1); + }; + }; + + template <> + struct nodes { + + template + struct count { + + typedef typename ParserT::left_t left_t; + typedef typename ParserT::right_t right_t; + typedef typename left_t::parser_category_t left_category_t; + typedef typename right_t::parser_category_t right_category_t; + + typedef nodes left_nodes_t; + typedef typename count_wrapper + ::template result_ left_count_t; + + typedef nodes right_nodes_t; + typedef typename count_wrapper + ::template result_ right_count_t; + + BOOST_STATIC_CONSTANT(int, + value = (left_count_t::value + right_count_t::value + 1)); + }; + }; + +#else + + template <> + struct nodes { + + template + struct count { + + typedef typename ParserT::subject_t subject_t; + typedef typename subject_t::parser_category_t subject_category_t; + + // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT + enum { value = (nodes + ::template count::value + 1) }; + }; + }; + + template <> + struct nodes { + + template + struct count { + + typedef typename ParserT::subject_t subject_t; + typedef typename subject_t::parser_category_t subject_category_t; + + // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT + enum { value = (nodes + ::template count::value + 1) }; + }; + }; + + template <> + struct nodes { + + template + struct count { + + typedef typename ParserT::left_t left_t; + typedef typename ParserT::right_t right_t; + typedef typename left_t::parser_category_t left_category_t; + typedef typename right_t::parser_category_t right_category_t; + + typedef count self_t; + + // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT + enum { + leftcount = (nodes + ::template count::value), + rightcount = (nodes + ::template count::value), + value = ((self_t::leftcount) + (self_t::rightcount) + 1) + }; + }; + }; + +#endif + + /////////////////////////////////////////////////////////////////////////// + // + // Helper template for counting the number of leaf nodes contained in a + // given parser type. + // Only plain_parser_category type parsers are counted as leaf nodes. + // + /////////////////////////////////////////////////////////////////////////// + template + struct leafs; + + template <> + struct leafs { + + template + struct count { + + // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT + enum { value = (LeafCountT::value + 1) }; + }; + }; + +#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) + + template <> + struct leafs { + + template + struct count { + + typedef typename ParserT::subject_t subject_t; + typedef typename subject_t::parser_category_t subject_category_t; + + typedef leafs nodes_t; + typedef typename count_wrapper + ::template result_ count_t; + + BOOST_STATIC_CONSTANT(int, value = count_t::value); + }; + }; + + template <> + struct leafs { + + template + struct count { + + typedef typename ParserT::subject_t subject_t; + typedef typename subject_t::parser_category_t subject_category_t; + + typedef leafs nodes_t; + typedef typename count_wrapper + ::template result_ count_t; + + BOOST_STATIC_CONSTANT(int, value = count_t::value); + }; + }; + + template <> + struct leafs { + + template + struct count { + + typedef typename ParserT::left_t left_t; + typedef typename ParserT::right_t right_t; + typedef typename left_t::parser_category_t left_category_t; + typedef typename right_t::parser_category_t right_category_t; + + typedef leafs left_nodes_t; + typedef typename count_wrapper + ::template result_ left_count_t; + + typedef leafs right_nodes_t; + typedef typename count_wrapper + ::template result_ right_count_t; + + BOOST_STATIC_CONSTANT(int, + value = (left_count_t::value + right_count_t::value)); + }; + }; + +#else + + template <> + struct leafs { + + template + struct count { + + typedef typename ParserT::subject_t subject_t; + typedef typename subject_t::parser_category_t subject_category_t; + + // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT + enum { value = (leafs + ::template count::value) }; + }; + }; + + template <> + struct leafs { + + template + struct count { + + typedef typename ParserT::subject_t subject_t; + typedef typename subject_t::parser_category_t subject_category_t; + + // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT + enum { value = (leafs + ::template count::value) }; + }; + }; + + template <> + struct leafs { + + template + struct count { + + typedef typename ParserT::left_t left_t; + typedef typename ParserT::right_t right_t; + typedef typename left_t::parser_category_t left_category_t; + typedef typename right_t::parser_category_t right_category_t; + + typedef count self_t; + + // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT + enum { + leftcount = (leafs + ::template count::value), + rightcount = (leafs + ::template count::value), + value = (self_t::leftcount + self_t::rightcount) + }; + }; + }; + +#endif + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif // !defined(BOOST_SPIRIT_FUNDAMENTAL_IPP) diff --git a/boost/boost/spirit/meta/impl/parser_traits.ipp b/boost/boost/spirit/meta/impl/parser_traits.ipp new file mode 100644 index 0000000000..af210f177a --- /dev/null +++ b/boost/boost/spirit/meta/impl/parser_traits.ipp @@ -0,0 +1,187 @@ +/*============================================================================= + Copyright (c) 2002-2003 Joel de Guzman + Copyright (c) 2002-2003 Hartmut Kaiser + Copyright (c) 2003 Martin Wille + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_PARSER_TRAITS_IPP) +#define BOOST_SPIRIT_PARSER_TRAITS_IPP + +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +namespace impl +{ + +#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + + /////////////////////////////////////////////////////////////////////////// + // + // from spirit 1.1 (copyright (c) 2001 Bruce Florman) + // various workarounds to support compile time decisions without partial + // template specialization whether a given type is an instance of a + // concrete parser type. + // + /////////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////////// + template + struct parser_type_traits + { + // Determine at compile time (without partial specialization) + // whether a given type is an instance of the alternative + + static T t(); + + typedef struct { char dummy[1]; } size1_t; + typedef struct { char dummy[2]; } size2_t; + typedef struct { char dummy[3]; } size3_t; + typedef struct { char dummy[4]; } size4_t; + typedef struct { char dummy[5]; } size5_t; + typedef struct { char dummy[6]; } size6_t; + typedef struct { char dummy[7]; } size7_t; + typedef struct { char dummy[8]; } size8_t; + typedef struct { char dummy[9]; } size9_t; + typedef struct { char dummy[10]; } size10_t; + + // the following functions need no implementation + template + static size1_t test_(alternative const&); + template + static size2_t test_(sequence const&); + template + static size3_t test_(sequential_or const&); + template + static size4_t test_(intersection const&); + template + static size5_t test_(difference const&); + template + static size6_t test_(exclusive_or const&); + template + static size7_t test_(optional const&); + template + static size8_t test_(kleene_star const&); + template + static size9_t test_(positive const&); + + static size10_t test_(...); + + BOOST_STATIC_CONSTANT(bool, + is_alternative = (sizeof(size1_t) == sizeof(test_(t()))) ); + BOOST_STATIC_CONSTANT(bool, + is_sequence = (sizeof(size2_t) == sizeof(test_(t()))) ); + BOOST_STATIC_CONSTANT(bool, + is_sequential_or = (sizeof(size3_t) == sizeof(test_(t()))) ); + BOOST_STATIC_CONSTANT(bool, + is_intersection = (sizeof(size4_t) == sizeof(test_(t()))) ); + BOOST_STATIC_CONSTANT(bool, + is_difference = (sizeof(size5_t) == sizeof(test_(t()))) ); + BOOST_STATIC_CONSTANT(bool, + is_exclusive_or = (sizeof(size6_t) == sizeof(test_(t()))) ); + BOOST_STATIC_CONSTANT(bool, + is_optional = (sizeof(size7_t) == sizeof(test_(t()))) ); + BOOST_STATIC_CONSTANT(bool, + is_kleene_star = (sizeof(size8_t) == sizeof(test_(t()))) ); + BOOST_STATIC_CONSTANT(bool, + is_positive = (sizeof(size9_t) == sizeof(test_(t()))) ); + }; + +#else + + /////////////////////////////////////////////////////////////////////////// + struct parser_type_traits_base { + + BOOST_STATIC_CONSTANT(bool, is_alternative = false); + BOOST_STATIC_CONSTANT(bool, is_sequence = false); + BOOST_STATIC_CONSTANT(bool, is_sequential_or = false); + BOOST_STATIC_CONSTANT(bool, is_intersection = false); + BOOST_STATIC_CONSTANT(bool, is_difference = false); + BOOST_STATIC_CONSTANT(bool, is_exclusive_or = false); + BOOST_STATIC_CONSTANT(bool, is_optional = false); + BOOST_STATIC_CONSTANT(bool, is_kleene_star = false); + BOOST_STATIC_CONSTANT(bool, is_positive = false); + }; + + template + struct parser_type_traits : public parser_type_traits_base { + + // no definition here, fallback for all not explicitly mentioned parser + // types + }; + + template + struct parser_type_traits > + : public parser_type_traits_base { + + BOOST_STATIC_CONSTANT(bool, is_alternative = true); + }; + + template + struct parser_type_traits > + : public parser_type_traits_base { + + BOOST_STATIC_CONSTANT(bool, is_sequence = true); + }; + + template + struct parser_type_traits > + : public parser_type_traits_base { + + BOOST_STATIC_CONSTANT(bool, is_sequential_or = true); + }; + + template + struct parser_type_traits > + : public parser_type_traits_base { + + BOOST_STATIC_CONSTANT(bool, is_intersection = true); + }; + + template + struct parser_type_traits > + : public parser_type_traits_base { + + BOOST_STATIC_CONSTANT(bool, is_difference = true); + }; + + template + struct parser_type_traits > + : public parser_type_traits_base { + + BOOST_STATIC_CONSTANT(bool, is_exclusive_or = true); + }; + + template + struct parser_type_traits > + : public parser_type_traits_base { + + BOOST_STATIC_CONSTANT(bool, is_optional = true); + }; + + template + struct parser_type_traits > + : public parser_type_traits_base { + + BOOST_STATIC_CONSTANT(bool, is_kleene_star = true); + }; + + template + struct parser_type_traits > + : public parser_type_traits_base { + + BOOST_STATIC_CONSTANT(bool, is_positive = true); + }; + +#endif // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif // !defined(BOOST_SPIRIT_PARSER_TRAITS_IPP) diff --git a/boost/boost/spirit/meta/impl/refactoring.ipp b/boost/boost/spirit/meta/impl/refactoring.ipp new file mode 100644 index 0000000000..c63a8c07c3 --- /dev/null +++ b/boost/boost/spirit/meta/impl/refactoring.ipp @@ -0,0 +1,447 @@ +/*============================================================================= + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_REFACTORING_IPP +#define BOOST_SPIRIT_REFACTORING_IPP + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// The struct 'self_nested_refactoring' is used to indicate, that the +// refactoring algorithm should be 'self-nested'. +// +// The struct 'non_nested_refactoring' is used to indicate, that no nesting +// of refactoring algorithms is reqired. +// +/////////////////////////////////////////////////////////////////////////////// + +struct non_nested_refactoring { typedef non_nested_refactoring embed_t; }; +struct self_nested_refactoring { typedef self_nested_refactoring embed_t; }; + +/////////////////////////////////////////////////////////////////////////////// +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// +// +// Helper templates for refactoring parsers +// +/////////////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////////// + // + // refactor the left unary operand of a binary parser + // + // The refactoring should be done only if the left operand is an + // unary_parser_category parser. + // + /////////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////////// + template + struct refactor_unary_nested { + + template < + typename ParserT, typename NestedT, + typename ScannerT, typename BinaryT + > + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, BinaryT const& binary, + NestedT const& /*nested_d*/) + { + return binary.parse(scan); + } + }; + + template <> + struct refactor_unary_nested { + + template < + typename ParserT, typename ScannerT, typename BinaryT, + typename NestedT + > + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, BinaryT const& binary, + NestedT const& nested_d) + { + typedef typename BinaryT::parser_generator_t op_t; + typedef + typename BinaryT::left_t::parser_generator_t + unary_t; + + return + unary_t::generate( + nested_d[ + op_t::generate(binary.left().subject(), binary.right()) + ] + ).parse(scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + template + struct refactor_unary_non_nested { + + template + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, BinaryT const& binary) + { + return binary.parse(scan); + } + }; + + template <> + struct refactor_unary_non_nested { + + template + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, BinaryT const& binary) + { + typedef typename BinaryT::parser_generator_t op_t; + typedef + typename BinaryT::left_t::parser_generator_t + unary_t; + + return unary_t::generate( + op_t::generate(binary.left().subject(), binary.right()) + ).parse(scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + template + struct refactor_unary_type { + + template + static typename parser_result::type + parse(ParserT const &p, ScannerT const& scan, BinaryT const& binary, + NestedT const& nested_d) + { + typedef + typename BinaryT::left_t::parser_category_t + parser_category_t; + + return refactor_unary_nested:: + parse(p, scan, binary, nested_d); + } + }; + + template <> + struct refactor_unary_type { + + template + static typename parser_result::type + parse(ParserT const &p, ScannerT const& scan, BinaryT const& binary, + non_nested_refactoring const&) + { + typedef + typename BinaryT::left_t::parser_category_t + parser_category_t; + + return refactor_unary_non_nested:: + parse(p, scan, binary); + } + + }; + + template <> + struct refactor_unary_type { + + template + static typename parser_result::type + parse(ParserT const &p, ScannerT const& scan, BinaryT const& binary, + self_nested_refactoring const &nested_tag) + { + typedef + typename BinaryT::left_t::parser_category_t + parser_category_t; + typedef typename ParserT::parser_generator_t parser_generator_t; + + parser_generator_t nested_d(nested_tag); + return refactor_unary_nested:: + parse(p, scan, binary, nested_d); + } + + }; + + /////////////////////////////////////////////////////////////////////////// + // + // refactor the action on the left operand of a binary parser + // + // The refactoring should be done only if the left operand is an + // action_parser_category parser. + // + /////////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////////// + template + struct refactor_action_nested { + + template < + typename ParserT, typename ScannerT, typename BinaryT, + typename NestedT + > + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, BinaryT const& binary, + NestedT const& nested_d) + { + return nested_d[binary].parse(scan); + } + }; + + template <> + struct refactor_action_nested { + + template < + typename ParserT, typename ScannerT, typename BinaryT, + typename NestedT + > + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, BinaryT const& binary, + NestedT const& nested_d) + { + typedef typename BinaryT::parser_generator_t binary_gen_t; + + return ( + nested_d[ + binary_gen_t::generate( + binary.left().subject(), + binary.right() + ) + ][binary.left().predicate()] + ).parse(scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + template + struct refactor_action_non_nested { + + template + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, BinaryT const& binary) + { + return binary.parse(scan); + } + }; + + template <> + struct refactor_action_non_nested { + + template + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, BinaryT const& binary) + { + typedef typename BinaryT::parser_generator_t binary_gen_t; + + return ( + binary_gen_t::generate( + binary.left().subject(), + binary.right() + )[binary.left().predicate()] + ).parse(scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + template + struct refactor_action_type { + + template + static typename parser_result::type + parse(ParserT const &p, ScannerT const& scan, BinaryT const& binary, + NestedT const& nested_d) + { + typedef + typename BinaryT::left_t::parser_category_t + parser_category_t; + + return refactor_action_nested:: + parse(p, scan, binary, nested_d); + } + }; + + template <> + struct refactor_action_type { + + template + static typename parser_result::type + parse(ParserT const &p, ScannerT const& scan, BinaryT const& binary, + non_nested_refactoring const&) + { + typedef + typename BinaryT::left_t::parser_category_t + parser_category_t; + + return refactor_action_non_nested:: + parse(p, scan, binary); + } + }; + + template <> + struct refactor_action_type { + + template + static typename parser_result::type + parse(ParserT const &p, ScannerT const& scan, BinaryT const& binary, + self_nested_refactoring const &nested_tag) + { + typedef typename ParserT::parser_generator_t parser_generator_t; + typedef + typename BinaryT::left_t::parser_category_t + parser_category_t; + + parser_generator_t nested_d(nested_tag); + return refactor_action_nested:: + parse(p, scan, binary, nested_d); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // refactor the action attached to a binary parser + // + // The refactoring should be done only if the given parser is an + // binary_parser_category parser. + // + /////////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////////// + template + struct attach_action_nested { + + template < + typename ParserT, typename ScannerT, typename ActionT, + typename NestedT + > + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, ActionT const &action, + NestedT const& nested_d) + { + return action.parse(scan); + } + }; + + template <> + struct attach_action_nested { + + template < + typename ParserT, typename ScannerT, typename ActionT, + typename NestedT + > + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, ActionT const &action, + NestedT const& nested_d) + { + typedef + typename ActionT::subject_t::parser_generator_t + binary_gen_t; + + return ( + binary_gen_t::generate( + nested_d[action.subject().left()[action.predicate()]], + nested_d[action.subject().right()[action.predicate()]] + ) + ).parse(scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + template + struct attach_action_non_nested { + + template + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, ActionT const &action) + { + return action.parse(scan); + } + }; + + template <> + struct attach_action_non_nested { + + template + static typename parser_result::type + parse(ParserT const &, ScannerT const& scan, ActionT const &action) + { + typedef + typename ActionT::subject_t::parser_generator_t + binary_gen_t; + + return ( + binary_gen_t::generate( + action.subject().left()[action.predicate()], + action.subject().right()[action.predicate()] + ) + ).parse(scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + template + struct attach_action_type { + + template + static typename parser_result::type + parse(ParserT const &p, ScannerT const& scan, ActionT const& action, + NestedT const& nested_d) + { + typedef + typename ActionT::subject_t::parser_category_t + parser_category_t; + + return attach_action_nested:: + parse(p, scan, action, nested_d); + } + }; + + template <> + struct attach_action_type { + + template + static typename parser_result::type + parse(ParserT const &p, ScannerT const& scan, ActionT const &action, + non_nested_refactoring const&) + { + typedef + typename ActionT::subject_t::parser_category_t + parser_category_t; + + return attach_action_non_nested:: + parse(p, scan, action); + } + }; + + template <> + struct attach_action_type { + + template + static typename parser_result::type + parse(ParserT const &p, ScannerT const& scan, ActionT const &action, + self_nested_refactoring const& nested_tag) + { + typedef typename ParserT::parser_generator_t parser_generator_t; + typedef + typename ActionT::subject_t::parser_category_t + parser_category_t; + + parser_generator_t nested_d(nested_tag); + return attach_action_nested:: + parse(p, scan, action, nested_d); + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif + diff --git a/boost/boost/spirit/meta/impl/traverse.ipp b/boost/boost/spirit/meta/impl/traverse.ipp new file mode 100644 index 0000000000..71c9a9fa80 --- /dev/null +++ b/boost/boost/spirit/meta/impl/traverse.ipp @@ -0,0 +1,389 @@ +/*============================================================================= + Copyright (c) 2002-2003 Joel de Guzman + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_TRAVERSE_IPP) +#define BOOST_SPIRIT_TRAVERSE_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +namespace impl +{ + + template + struct traverse_post_order_return_category; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// +// Environment class for post_order_traversal +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct traverse_post_order_env { + + BOOST_STATIC_CONSTANT(int, level = Level); + BOOST_STATIC_CONSTANT(int, node = Node); + BOOST_STATIC_CONSTANT(int, index = Index); + BOOST_STATIC_CONSTANT(int, lastleft = LastLeft); +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// traverse_post_order_return template +// +// This template is a helper for dispatching the calculation of a parser +// type result for a traversal level to the corresponding parser_category +// based specialization. +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct traverse_post_order_return { + + typedef typename ParserT::parser_category_t parser_category_t; + typedef typename impl::traverse_post_order_return_category + ::template result::type type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// parser_traversal_..._result templates +// +// These are metafunctions, which calculate the resulting parser type +// for all subparsers and feed these types to the user supplied +// metafunctions to get back the resulting parser type of this traversal +// level. +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct parser_traversal_plain_result { + + typedef typename MetaT::template plain_result::type type; +}; + +/////////////////////////////////////////////////////////////////////////////// +template +struct parser_traversal_unary_result { + + typedef typename MetaT + ::template unary_result::type type; +}; + +/////////////////////////////////////////////////////////////////////////////// +template +struct parser_traversal_action_result { + + typedef typename MetaT + ::template action_result::type type; +}; + +/////////////////////////////////////////////////////////////////////////////// +template < + typename MetaT, typename BinaryT, typename LeftT, + typename RightT, typename EnvT +> +struct parser_traversal_binary_result { + + BOOST_STATIC_CONSTANT(int, + thisnum = (node_count::value + EnvT::lastleft-1)); + BOOST_STATIC_CONSTANT(int, + leftnum = (node_count::value + EnvT::lastleft-1)); + BOOST_STATIC_CONSTANT(int, + leafnum = (leaf_count::value + EnvT::index)); + + typedef parser_traversal_binary_result self_t; + + // left traversal environment and resulting parser type + typedef traverse_post_order_env< + (EnvT::level+1), (self_t::leftnum), (EnvT::index), (EnvT::lastleft) + > left_sub_env_t; + typedef typename traverse_post_order_return< + MetaT, LeftT, left_sub_env_t + >::type + left_t; + + // right traversal environment and resulting parser type + typedef traverse_post_order_env< + (EnvT::level+1), (self_t::thisnum-1), (self_t::leafnum), (self_t::leftnum+1) + > right_sub_env_t; + typedef typename traverse_post_order_return< + MetaT, RightT, right_sub_env_t + >::type + right_t; + + typedef typename MetaT::template binary_result< + BinaryT, left_t, right_t, EnvT + >::type + type; +}; + +/////////////////////////////////////////////////////////////////////////////// +namespace impl +{ + /////////////////////////////////////////////////////////////////////////// + // + // Meta functions, which dispatch the calculation of the return type of + // of the post_order traverse function to the result template of the + // corresponding parser_category based metafunction template. + // + /////////////////////////////////////////////////////////////////////////// + + template + struct traverse_post_order_return_category; + + template <> + struct traverse_post_order_return_category { + + template + struct result { + + typedef typename parser_traversal_plain_result< + MetaT, ParserT, EnvT + >::type + type; + }; + }; + + template <> + struct traverse_post_order_return_category { + + template + struct result { + + typedef typename parser_traversal_unary_result< + MetaT, ParserT, typename ParserT::subject_t, EnvT + >::type + type; + }; + }; + + template <> + struct traverse_post_order_return_category { + + template + struct result { + + typedef typename parser_traversal_action_result< + MetaT, ParserT, typename ParserT::subject_t, EnvT + >::type + type; + }; + }; + + template <> + struct traverse_post_order_return_category { + + template + struct result { + + typedef typename parser_traversal_binary_result< + MetaT, ParserT, typename ParserT::left_t, + typename ParserT::right_t, EnvT + >::type + type; + }; + }; + + /////////////////////////////////////////////////////////////////////////// + // + // Post-order parser traversal + // + // The following templates contain the parser_category based code for + // + // - calculating the type of the resulting parser, which is to be + // returned from a level of traversal + // - traversing down the composite parser structure, this traversal + // returnes a new parser object + // + // Both tasks are delegated to the MetaT metafunction supplied by the + // user. + // + /////////////////////////////////////////////////////////////////////////// + + template + struct traverse_post_order; + + template <> + struct traverse_post_order { + + template + struct result { + + typedef + typename parser_traversal_plain_result::type + type; + }; + + template + static + typename parser_traversal_plain_result::type + generate(MetaT const &meta_, ParserT const &parser_, EnvT const &env) + { + return meta_.generate_plain(parser_, env); + } + }; + + template <> + struct traverse_post_order { + + template < + typename MetaT, typename ParserT, typename SubjectT, typename EnvT + > + struct result { + + typedef typename parser_traversal_unary_result< + MetaT, ParserT, SubjectT, EnvT + >::type + type; + }; + + template + static + typename parser_traversal_unary_result< + MetaT, ParserT, + typename traverse_post_order_return< + MetaT, typename ParserT::subject_t, EnvT + >::type, + EnvT + >::type + generate(MetaT const &meta_, ParserT const &unary_, EnvT const &env) + { + typedef typename ParserT::subject_t subject_t; + typedef typename subject_t::parser_category_t subject_category_t; + + return meta_.generate_unary( + unary_, + traverse_post_order::generate(meta_, + unary_.subject(), + traverse_post_order_env< + EnvT::level+1, EnvT::node-1, EnvT::index, EnvT::lastleft + >() + ), + env + ); + } + }; + + template <> + struct traverse_post_order { + + template < + typename MetaT, typename ParserT, typename SubjectT, typename EnvT + > + struct result { + + typedef typename parser_traversal_action_result< + MetaT, ParserT, SubjectT, EnvT + >::type + type; + }; + + template + static + typename parser_traversal_action_result< + MetaT, ParserT, + typename traverse_post_order_return< + MetaT, typename ParserT::subject_t, EnvT + >::type, + EnvT + >::type + generate(MetaT const &meta_, ParserT const &action_, EnvT const &env) + { + typedef typename ParserT::subject_t subject_t; + typedef typename subject_t::parser_category_t subject_category_t; + + return meta_.generate_action( + action_, + traverse_post_order::generate(meta_, + action_.subject(), + traverse_post_order_env< + EnvT::level+1, EnvT::node-1, EnvT::index, EnvT::lastleft + >() + ), + env + ); + } + }; + + template <> + struct traverse_post_order { + + template < + typename MetaT, typename ParserT, typename LeftT, + typename RightT, typename EnvT + > + struct result { + + typedef typename parser_traversal_binary_result< + MetaT, ParserT, LeftT, RightT, EnvT + >::type + type; + }; + + template + static + typename parser_traversal_binary_result< + MetaT, ParserT, + typename traverse_post_order_return< + MetaT, typename ParserT::left_t, EnvT + >::type, + typename traverse_post_order_return< + MetaT, typename ParserT::right_t, EnvT + >::type, + EnvT + >::type + generate(MetaT const &meta_, ParserT const &binary_, EnvT const& /*env*/) + { + typedef typename ParserT::left_t left_t; + typedef typename ParserT::right_t right_t; + typedef typename left_t::parser_category_t left_category_t; + typedef typename right_t::parser_category_t right_category_t; + + enum { + leftnum = (node_count::value + EnvT::lastleft-1), + thisnum = (node_count::value + EnvT::lastleft-1), + rightnum = (thisnum-1), + leafnum = (leaf_count::value + EnvT::index) + }; + + return meta_.generate_binary( + binary_, + traverse_post_order::generate( + meta_, binary_.left(), + traverse_post_order_env< + EnvT::level+1, leftnum, EnvT::index, EnvT::lastleft + >() + ), + traverse_post_order::generate( + meta_, binary_.right(), + traverse_post_order_env< + EnvT::level+1, rightnum, leafnum, leftnum+1 + >() + ), + traverse_post_order_env< + EnvT::level, thisnum, EnvT::index, EnvT::lastleft + >() + ); + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif // !defined(BOOST_SPIRIT_TRAVERSE_IPP) diff --git a/boost/boost/spirit/meta/parser_traits.hpp b/boost/boost/spirit/meta/parser_traits.hpp new file mode 100644 index 0000000000..3a967415e9 --- /dev/null +++ b/boost/boost/spirit/meta/parser_traits.hpp @@ -0,0 +1,316 @@ +/*============================================================================= + Copyright (c) 2002-2003 Joel de Guzman + Copyright (c) 2002-2003 Hartmut Kaiser + Copyright (c) 2003 Martin Wille + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_PARSER_TRAITS_HPP) +#define BOOST_SPIRIT_PARSER_TRAITS_HPP + +#include +#include + +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// Parser traits templates +// +// Used to determine the type and several other characteristics of a given +// parser type. +// +/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// +// The is_parser traits template can be used to tell wether a given +// class is a parser. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct is_parser +{ + BOOST_STATIC_CONSTANT(bool, value = + (::boost::is_base_and_derived, T>::value)); + +// [JDG 2/3/03] simplified implementation by +// using boost::is_base_and_derived +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// The is_unary_composite traits template can be used to tell if a given +// parser is a unary parser as for instance kleene_star or optional. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct is_unary_composite { + + BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible< + typename UnaryT::parser_category_t, unary_parser_category>::value)); +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// The is_acction_parser traits template can be used to tell if a given +// parser is a action parser, i.e. it is a composite consisting of a +// auxilliary parser and an attached semantic action. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct is_action_parser { + + BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible< + typename ActionT::parser_category_t, action_parser_category>::value)); +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// The is_binary_composite traits template can be used to tell if a given +// parser is a binary parser as for instance sequence or difference. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct is_binary_composite { + + BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible< + typename BinaryT::parser_category_t, binary_parser_category>::value)); +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// The is_composite_parser traits template can be used to tell if a given +// parser is a unary or a binary parser composite type. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct is_composite_parser { + + BOOST_STATIC_CONSTANT(bool, value = ( + ::boost::spirit::is_unary_composite::value || + ::boost::spirit::is_binary_composite::value)); +}; + +/////////////////////////////////////////////////////////////////////////////// +template +struct is_alternative { + + BOOST_STATIC_CONSTANT(bool, value = ( + ::boost::spirit::impl::parser_type_traits::is_alternative)); +}; + +template +struct is_sequence { + + BOOST_STATIC_CONSTANT(bool, value = ( + ::boost::spirit::impl::parser_type_traits::is_sequence)); +}; + +template +struct is_sequential_or { + + BOOST_STATIC_CONSTANT(bool, value = ( + ::boost::spirit::impl::parser_type_traits::is_sequential_or)); +}; + +template +struct is_intersection { + + BOOST_STATIC_CONSTANT(bool, value = ( + ::boost::spirit::impl::parser_type_traits::is_intersection)); +}; + +template +struct is_difference { + + BOOST_STATIC_CONSTANT(bool, value = ( + ::boost::spirit::impl::parser_type_traits::is_difference)); +}; + +template +struct is_exclusive_or { + + BOOST_STATIC_CONSTANT(bool, value = ( + ::boost::spirit::impl::parser_type_traits::is_exclusive_or)); +}; + +template +struct is_optional { + + BOOST_STATIC_CONSTANT(bool, value = ( + ::boost::spirit::impl::parser_type_traits::is_optional)); +}; + +template +struct is_kleene_star { + + BOOST_STATIC_CONSTANT(bool, value = ( + ::boost::spirit::impl::parser_type_traits::is_kleene_star)); +}; + +template +struct is_positive { + + BOOST_STATIC_CONSTANT(bool, value = ( + ::boost::spirit::impl::parser_type_traits::is_positive)); +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Parser extraction templates +// +/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// +// The unary_subject template can be used to return the type of the +// parser used as the subject of an unary parser. +// If the parser under inspection is not an unary type parser the compilation +// will fail. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct unary_subject { + + BOOST_STATIC_ASSERT(::boost::spirit::is_unary_composite::value); + typedef typename UnaryT::subject_t type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// The get_unary_subject template function returns the parser object, which +// is used as the subject of an unary parser. +// If the parser under inspection is not an unary type parser the compilation +// will fail. +// +/////////////////////////////////////////////////////////////////////////////// +template +inline typename unary_subject::type const & +get_unary_subject(UnaryT const &unary_) +{ + BOOST_STATIC_ASSERT(::boost::spirit::is_unary_composite::value); + return unary_.subject(); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// The binary_left_subject and binary_right_subject templates can be used to +// return the types of the parsers used as the left and right subject of an +// binary parser. +// If the parser under inspection is not a binary type parser the compilation +// will fail. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct binary_left_subject { + + BOOST_STATIC_ASSERT(::boost::spirit::is_binary_composite::value); + typedef typename BinaryT::left_t type; +}; + +template +struct binary_right_subject { + + BOOST_STATIC_ASSERT(::boost::spirit::is_binary_composite::value); + typedef typename BinaryT::right_t type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// The get_binary_left_subject and get_binary_right_subject template functions +// return the parser object, which is used as the left or right subject of a +// binary parser. +// If the parser under inspection is not a binary type parser the compilation +// will fail. +// +/////////////////////////////////////////////////////////////////////////////// +template +inline typename binary_left_subject::type const & +get_binary_left_subject(BinaryT const &binary_) +{ + BOOST_STATIC_ASSERT(::boost::spirit::is_binary_composite::value); + return binary_.left(); +} + +template +inline typename binary_right_subject::type const & +get_binary_right_subject(BinaryT const &binary_) +{ + BOOST_STATIC_ASSERT(::boost::spirit::is_binary_composite::value); + return binary_.right(); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// The action_subject template can be used to return the type of the +// parser used as the subject of an action parser. +// If the parser under inspection is not an action type parser the compilation +// will fail. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct action_subject { + + BOOST_STATIC_ASSERT(::boost::spirit::is_action_parser::value); + typedef typename ActionT::subject_t type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// The get_action_subject template function returns the parser object, which +// is used as the subject of an action parser. +// If the parser under inspection is not an action type parser the compilation +// will fail. +// +/////////////////////////////////////////////////////////////////////////////// +template +inline typename action_subject::type const & +get_action_subject(ActionT const &action_) +{ + BOOST_STATIC_ASSERT(::boost::spirit::is_action_parser::value); + return action_.subject(); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// The semantic_action template can be used to return the type of the +// attached semantic action of an action parser. +// If the parser under inspection is not an action type parser the compilation +// will fail. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct semantic_action { + + BOOST_STATIC_ASSERT(::boost::spirit::is_action_parser::value); + typedef typename ActionT::predicate_t type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// The get_semantic_action template function returns the attached semantic +// action of an action parser. +// If the parser under inspection is not an action type parser the compilation +// will fail. +// +/////////////////////////////////////////////////////////////////////////////// +template +inline typename semantic_action::type const & +get_semantic_action(ActionT const &action_) +{ + BOOST_STATIC_ASSERT(::boost::spirit::is_action_parser::value); + return action_.predicate(); +} + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif // !defined(BOOST_SPIRIT_PARSER_TRAITS_HPP) diff --git a/boost/boost/spirit/meta/refactoring.hpp b/boost/boost/spirit/meta/refactoring.hpp new file mode 100644 index 0000000000..6e92683b70 --- /dev/null +++ b/boost/boost/spirit/meta/refactoring.hpp @@ -0,0 +1,274 @@ +/*============================================================================= + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_REFACTORING_HPP +#define BOOST_SPIRIT_REFACTORING_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// refactor_unary_parser class +// +// This helper template allows to attach an unary operation to a newly +// constructed parser, which combines the subject of the left operand of +// the original given parser (BinaryT) with the right operand of the +// original binary parser through the original binary operation and +// rewraps the resulting parser with the original unary operator. +// +// For instance given the parser: +// *some_parser - another_parser +// +// will be refactored to: +// *(some_parser - another_parser) +// +// If the parser to refactor is not a unary parser, no refactoring is done +// at all. +// +// The original parser should be a binary_parser_category parser, +// else the compilation will fail +// +/////////////////////////////////////////////////////////////////////////////// + +template +class refactor_unary_gen; + +template +class refactor_unary_parser : + public parser > { + +public: + // the parser to refactor has to be at least a binary_parser_category + // parser + BOOST_STATIC_ASSERT(( + boost::is_convertible::value + )); + + refactor_unary_parser(BinaryT const& binary_, NestedT const& nested_) + : binary(binary_), nested(nested_) {} + + typedef refactor_unary_parser self_t; + typedef refactor_unary_gen parser_generator_t; + typedef typename BinaryT::left_t::parser_category_t parser_category_t; + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + return impl::refactor_unary_type:: + parse(*this, scan, binary, nested); + } + +private: + typename as_parser::type::embed_t binary; + typename NestedT::embed_t nested; +}; + +////////////////////////////////// +template +class refactor_unary_gen { + +public: + typedef refactor_unary_gen embed_t; + + refactor_unary_gen(NestedT const& nested_ = non_nested_refactoring()) + : nested(nested_) {} + + template + refactor_unary_parser + operator[](parser const& subject) const + { + return refactor_unary_parser + (subject.derived(), nested); + } + +private: + typename NestedT::embed_t nested; +}; + +const refactor_unary_gen<> refactor_unary_d = refactor_unary_gen<>(); + +/////////////////////////////////////////////////////////////////////////////// +// +// refactor_action_parser class +// +// This helper template allows to attach an action taken from the left +// operand of the given binary parser to a newly constructed parser, +// which combines the subject of the left operand of the original binary +// parser with the right operand of the original binary parser by means of +// the original binary operator parser. +// +// For instance the parser: +// some_parser[some_attached_functor] - another_parser +// +// will be refactored to: +// (some_parser - another_parser)[some_attached_functor] +// +// If the left operand to refactor is not an action parser, no refactoring +// is done at all. +// +// The original parser should be a binary_parser_category parser, +// else the compilation will fail +// +/////////////////////////////////////////////////////////////////////////////// + +template +class refactor_action_gen; + +template +class refactor_action_parser : + public parser > { + +public: + // the parser to refactor has to be at least a binary_parser_category + // parser + BOOST_STATIC_ASSERT(( + boost::is_convertible::value + )); + + refactor_action_parser(BinaryT const& binary_, NestedT const& nested_) + : binary(binary_), nested(nested_) {} + + typedef refactor_action_parser self_t; + typedef refactor_action_gen parser_generator_t; + typedef typename BinaryT::left_t::parser_category_t parser_category_t; + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + return impl::refactor_action_type:: + parse(*this, scan, binary, nested); + } + +private: + typename as_parser::type::embed_t binary; + typename NestedT::embed_t nested; +}; + +////////////////////////////////// +template +class refactor_action_gen { + +public: + typedef refactor_action_gen embed_t; + + refactor_action_gen(NestedT const& nested_ = non_nested_refactoring()) + : nested(nested_) {} + + template + refactor_action_parser + operator[](parser const& subject) const + { + return refactor_action_parser + (subject.derived(), nested); + } + +private: + typename NestedT::embed_t nested; +}; + +const refactor_action_gen<> refactor_action_d = refactor_action_gen<>(); + +/////////////////////////////////////////////////////////////////////////////// +// +// attach_action_parser class +// +// This helper template allows to attach an action given separately +// to to all parsers, out of which the given parser is constructed and +// reconstructs a new parser having the same structure. +// +// For instance the parser: +// (some_parser >> another_parser)[some_attached_functor] +// +// will be refactored to: +// some_parser[some_attached_functor] +// >> another_parser[some_attached_functor] +// +// The original parser should be a action_parser_category parser, +// else the compilation will fail +// +// If the parser, to which the action is attached is not an binary parser, +// no refactoring is done at all. +// +/////////////////////////////////////////////////////////////////////////////// + +template +class attach_action_gen; + +template +class attach_action_parser : + public parser > { + +public: + // the parser to refactor has to be at least a action_parser_category + // parser + BOOST_STATIC_ASSERT(( + boost::is_convertible::value + )); + + attach_action_parser(ActionT const& actor_, NestedT const& nested_) + : actor(actor_), nested(nested_) {} + + typedef attach_action_parser self_t; + typedef attach_action_gen parser_generator_t; + typedef typename ActionT::parser_category_t parser_category_t; + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + return impl::attach_action_type:: + parse(*this, scan, actor, nested); + } + +private: + typename as_parser::type::embed_t actor; + typename NestedT::embed_t nested; +}; + +////////////////////////////////// +template +class attach_action_gen { + +public: + typedef attach_action_gen embed_t; + + attach_action_gen(NestedT const& nested_ = non_nested_refactoring()) + : nested(nested_) {} + + template + attach_action_parser, NestedT> + operator[](action const& actor) const + { + return attach_action_parser, NestedT> + (actor, nested); + } + +private: + typename NestedT::embed_t nested; +}; + +const attach_action_gen<> attach_action_d = attach_action_gen<>(); + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif // BOOST_SPIRIT_REFACTORING_HPP + diff --git a/boost/boost/spirit/meta/traverse.hpp b/boost/boost/spirit/meta/traverse.hpp new file mode 100644 index 0000000000..0151412c1c --- /dev/null +++ b/boost/boost/spirit/meta/traverse.hpp @@ -0,0 +1,218 @@ +/*============================================================================= + Copyright (c) 2002-2003 Joel de Guzman + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_TRAVERSE_HPP) +#define BOOST_SPIRIT_TRAVERSE_HPP + +#include + +namespace boost { namespace spirit +{ + /////////////////////////////////////////////////////////////////////////// + // + // Post-order traversal of auxilliary parsers. + // + /////////////////////////////////////////////////////////////////////////// + struct post_order + { + // Return the parser type, which is generated as the result of the + // traverse function below. + + template + struct result + { + typedef typename + traverse_post_order_return< + MetaT + , ParserT + , traverse_post_order_env<0, 0, 0, 0> + >::type + type; + }; + + // Traverse a given parser and refactor it with the help of the given + // MetaT metafunction template. + + template + static typename result::type + traverse(MetaT const &meta_, ParserT const &parser_) + { + typedef typename ParserT::parser_category_t parser_category_t; + return impl::traverse_post_order::generate( + meta_, parser_, traverse_post_order_env<0, 0, 0, 0>()); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // Transform policies + // + // The following policy classes could be used to assemble some new + // transformation metafunction which uses identity transformations + // for some parser_category type parsers. + // + /////////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////////// + // transform plain parsers + template + struct plain_identity_policy + { + template + struct plain_result + { + // plain parsers should be embedded and returned correctly + typedef typename ParserT::embed_t type; + }; + + template + typename parser_traversal_plain_result::type + generate_plain(ParserT const &parser_, EnvT const& /*env*/) const + { + return parser_; + } + }; + + ////////////////////////////////// + // transform unary parsers + template + struct unary_identity_policy_return + { + typedef typename UnaryT::parser_generator_t parser_generator_t; + typedef typename parser_generator_t + ::template result::type type; + }; + + template + struct unary_identity_policy + { + template + struct unary_result + { + typedef + typename unary_identity_policy_return::type + type; + }; + + template + typename parser_traversal_unary_result< + TransformT, UnaryT, SubjectT, EnvT>::type + generate_unary( + UnaryT const &, SubjectT const &subject_, EnvT const& /*env*/) const + { + typedef typename UnaryT::parser_generator_t parser_generator_t; + return parser_generator_t::template generate(subject_); + } + }; + + ////////////////////////////////// + // transform action parsers + template + struct action_identity_policy + { + template + struct action_result + { + typedef action type; + }; + + template + typename parser_traversal_action_result< + TransformT, ActionT, SubjectT, EnvT + >::type + generate_action(ActionT const &action_, SubjectT const &subject_, + EnvT const& /*env*/) const + { + return subject_[action_.predicate()]; + } + }; + + ////////////////////////////////// + // transform binary parsers + template + struct binary_identity_policy_return + { + typedef typename BinaryT::parser_generator_t parser_generator_t; + typedef typename parser_generator_t + ::template result::type type; + }; + + template + struct binary_identity_policy + { + template + struct binary_result { + + typedef typename + binary_identity_policy_return::type + type; + }; + + template + typename parser_traversal_binary_result< + TransformT, BinaryT, LeftT, RightT, EnvT + >::type + generate_binary( + BinaryT const &, LeftT const& left_ + , RightT const& right_, EnvT const& /*env*/) const + { + typedef typename BinaryT::parser_generator_t parser_generator_t; + return parser_generator_t:: + template generate(left_, right_); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // transform_policies template + // + // The transform_policies template metafunction could serve as a + // base class for new metafunctions to be passed to the traverse meta + // template (see above), where only minimal parts have to be + // overwritten. + // + /////////////////////////////////////////////////////////////////////////// + + template < + typename TransformT, + typename PlainPolicyT = plain_identity_policy, + typename UnaryPolicyT = unary_identity_policy, + typename ActionPolicyT = action_identity_policy, + typename BinaryPolicyT = binary_identity_policy + > + struct transform_policies : + public PlainPolicyT, + public UnaryPolicyT, + public ActionPolicyT, + public BinaryPolicyT + { + }; + + /////////////////////////////////////////////////////////////////////////// + // + // Identity transformation + // + // The identity_transform metafunction supplied to the traverse + // template will generate a new parser, which will be exactly + // identical to the parser given as the parameter to the traverse + // metafunction. I.e. the following conceptual 'equation' will be + // always true: + // + // some_parser == + // post_order::traverse(identity_transform(), some_parser) + // + /////////////////////////////////////////////////////////////////////////// + + struct identity_transform : transform_policies {}; + +}} // namespace boost::spirit + +#endif // !defined(BOOST_SPIRIT_TRAVERSE_HPP) diff --git a/boost/boost/spirit/phoenix.hpp b/boost/boost/spirit/phoenix.hpp new file mode 100644 index 0000000000..f3655b2cb9 --- /dev/null +++ b/boost/boost/spirit/phoenix.hpp @@ -0,0 +1,26 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2001-2002 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#if !defined(BOOST_SPIRIT_PHOENIX_HPP) +#define BOOST_SPIRIT_PHOENIX_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // !defined(BOOST_SPIRIT_PHOENIX_HPP) diff --git a/boost/boost/spirit/phoenix/actor.hpp b/boost/boost/spirit/phoenix/actor.hpp new file mode 100644 index 0000000000..7c7d3c4c24 --- /dev/null +++ b/boost/boost/spirit/phoenix/actor.hpp @@ -0,0 +1,613 @@ +/*============================================================================= + Phoenix v1.2 + Copyright (c) 2001-2002 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef PHOENIX_ACTOR_HPP +#define PHOENIX_ACTOR_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix { + +// These are forward declared here because we cannot include impl.hpp +// or operators.hpp yet but the actor's assignment operator and index +// operator are required to be members. + +////////////////////////////////// +struct assign_op; +struct index_op; + +////////////////////////////////// +namespace impl { + + template + struct make_binary1; +} + +namespace impl { + + /////////////////////////////////////////////////////////////////////////// + // + // if_t selects type A or B depending on the condition C If C is of + // type char[2], B is selected, otherwise A + // + // TODO: This should be part of a common meta-library + // + /////////////////////////////////////////////////////////////////////////// + template + struct if_t { typedef A type; }; + + template + struct if_t { typedef B type; }; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// unpack_tuple class +// +// This class is used to unpack a supplied tuple such, that the members of +// this tuple will be handled as if they would be supplied separately. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct unpack_tuple : public TupleT { + + typedef TupleT tuple_t; + + unpack_tuple() {} + unpack_tuple(tuple_t const &tuple_) : TupleT(tuple_) {} +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// actor class +// +// This class is a protocol class for all actors. This class is +// essentially an interface contract. The actor class does not +// really know how how to act on anything but instead relies on the +// template parameter BaseT (from which the actor will derive from) +// to do the actual action. +// +// An actor is a functor that is capable of accepting arguments up +// to a predefined maximum. It is up to the base class to do the +// actual processing or possibly to limit the arity (no. of +// arguments) passed in. Upon invocation of the functor through a +// supplied operator(), the actor funnels the arguments passed in +// by the client into a tuple and calls the base eval member +// function. +// +// Schematically: +// +// arg0 ---------| +// arg1 ---------| +// arg3 ---------|---> tupled_args ---> base.eval +// ... | +// argN ---------| +// +// actor::operator()(arg0, arg1... argN) +// ---> BaseT::eval(tupled_args); +// +// Actor base classes from which this class inherits from are +// expected to have a corresponding member function eval compatible +// with the conceptual Interface: +// +// template +// actor_return_type +// eval(TupleT const& args) const; +// +// where args are the actual arguments passed in by the client +// funneled into a tuple (see tuple.hpp for details). +// +// The actor_return_type can be anything. Base classes are free to +// return any type, even argument dependent types (types that are +// deduced from the types of the arguments). After evaluating the +// parameters and doing some computations or actions, the eval +// member function concludes by returning something back to the +// client. To do this, the forwarding function (the actor's +// operator()) needs to know the return type of the eval member +// function that it is calling. For this purpose, actor base +// classes are required to provide a nested template class: +// +// template +// struct result; +// +// This auxiliary class provides the result type information +// returned by the eval member function of a base actor class. The +// nested template class result should have a typedef 'type' that +// reflects the return type of its member function eval. It is +// basically a type computer that answers the question "given +// arguments packed into a TupleT type, what will be the result +// type of the eval member function of ActorT?". The template class +// actor_result queries this to extract the return type of an +// actor. Example: +// +// typedef typename actor_result::type +// actor_return_type; +// +// where actor_return_type is the actual type returned by ActorT's +// eval member function given some arguments in a TupleT. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct actor_result { + + typedef typename ActorT::template result::type type; + typedef typename remove_reference::type plain_type; +}; + +////////////////////////////////// +template +struct actor : public BaseT { + + actor(); + actor(BaseT const& base); + + typename actor_result >::type + operator()() const; + + template + typename actor_result >::type + operator()(A& a) const; + + template + typename actor_result >::type + operator()(A& a, B& b) const; + + template + typename actor_result >::type + operator()(A& a, B& b, C& c) const; + +#if PHOENIX_LIMIT > 3 + template + typename actor_result >::type + operator()(A& a, B& b, C& c, D& d) const; + + template + typename actor_result >::type + operator()(A& a, B& b, C& c, D& d, E& e) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F> + typename actor_result >::type + operator()(A& a, B& b, C& c, D& d, E& e, F& f) const; + +#if PHOENIX_LIMIT > 6 + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G> + typename actor_result >::type + operator()(A& a, B& b, C& c, D& d, E& e, F& f, G& g) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H> + typename actor_result + >::type + operator()(A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I> + typename actor_result + >::type + operator()(A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i) const; + +#if PHOENIX_LIMIT > 9 + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J> + typename actor_result + >::type + operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K> + typename actor_result + >::type + operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j, + K& k) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L> + typename actor_result + >::type + operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j, + K& k, L& l) const; + +#if PHOENIX_LIMIT > 12 + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M> + typename actor_result + >::type + operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j, + K& k, L& l, M& m) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N> + typename actor_result + >::type + operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j, + K& k, L& l, M& m, N& n) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N, typename O> + typename actor_result + >::type + operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j, + K& k, L& l, M& m, N& n, O& o) const; + +#endif +#endif +#endif +#endif + + template + typename actor_result >::type + operator()(unpack_tuple const &t) const; + + template + typename impl::make_binary1::type + operator=(B const& b) const; + + template + typename impl::make_binary1::type + operator[](B const& b) const; +}; + +/////////////////////////////////////////////////////////////////////////// +// +// as_actor +// +// as_actor is a meta-program that converts an arbitrary type into +// an actor. All participants in the framework must be first-class +// actors. This meta-program is used all throughout the framework +// whenever an unknown type needs to be converted to an actor. +// as_actor specializations are expected to have a typedef 'type'. +// This is the destination actor type. A static member function +// 'convert' converts an object to this target type. +// +// The meta-program does no conversion if the object to be +// converted is already an actor. +// +/////////////////////////////////////////////////////////////////////////// +template +struct as_actor; + +////////////////////////////////// +template +struct as_actor > { + + typedef actor type; + static type convert(actor const& x) { return x; } +}; + +////////////////////////////////// +template <> +struct as_actor { + + typedef nil_t type; + static nil_t convert(nil_t /*x*/) + { return nil_t(); } +}; + +////////////////////////////////// +template <> +struct as_actor { + + typedef void type; + // ERROR!!! +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// actor class implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +actor::actor() +: BaseT() {} + +////////////////////////////////// +template +actor::actor(BaseT const& base) +: BaseT(base) {} + +////////////////////////////////// +template +inline typename actor_result >::type +actor::operator()() const +{ + return BaseT::eval(tuple<>()); +} + +////////////////////////////////// +template +template +inline typename actor_result >::type +actor::operator()(A& a) const +{ + return BaseT::eval(tuple(a)); +} + +////////////////////////////////// +template +template +inline typename actor_result >::type +actor::operator()(A& a, B& b) const +{ + return BaseT::eval(tuple(a, b)); +} + +////////////////////////////////// +template +template +inline typename actor_result >::type +actor::operator()(A& a, B& b, C& c) const +{ + return BaseT::eval(tuple(a, b, c)); +} + +#if PHOENIX_LIMIT > 3 +////////////////////////////////// +template +template +inline typename actor_result >::type +actor::operator()(A& a, B& b, C& c, D& d) const +{ + return BaseT::eval(tuple(a, b, c, d)); +} + +////////////////////////////////// +template +template +inline typename actor_result >::type +actor::operator()(A& a, B& b, C& c, D& d, E& e) const +{ + return BaseT::eval(tuple(a, b, c, d, e)); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F> +inline typename actor_result +>::type +actor::operator()( + A& a, B& b, C& c, D& d, E& e, F& f +) const +{ + return BaseT::eval( + tuple + (a, b, c, d, e, f) + ); +} + +#if PHOENIX_LIMIT > 6 +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G> +inline typename actor_result +>::type +actor::operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g +) const +{ + return BaseT::eval( + tuple + (a, b, c, d, e, f, g) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H> +inline typename actor_result +>::type +actor::operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h +) const +{ + return BaseT::eval( + tuple + (a, b, c, d, e, f, g, h) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I> +inline typename actor_result +>::type +actor::operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i +) const +{ + return BaseT::eval( + tuple + (a, b, c, d, e, f, g, h, i) + ); +} + +#if PHOENIX_LIMIT > 9 +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J> +inline typename actor_result +>::type +actor::operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j +) const +{ + return BaseT::eval( + tuple + (a, b, c, d, e, f, g, h, i, j) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K> +inline typename actor_result +>::type +actor::operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j, + K& k +) const +{ + return BaseT::eval( + tuple + (a, b, c, d, e, f, g, h, i, j, k) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L> +inline typename actor_result +>::type +actor::operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j, + K& k, L& l +) const +{ + return BaseT::eval( + tuple + (a, b, c, d, e, f, g, h, i, j, k, l) + ); +} + +#if PHOENIX_LIMIT > 12 +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M> +inline typename actor_result +>::type +actor::operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j, + K& k, L& l, M& m +) const +{ + return BaseT::eval( + tuple + (a, b, c, d, e, f, g, h, i, j, k, l, m) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N> +inline typename actor_result +>::type +actor::operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j, + K& k, L& l, M& m, N& n +) const +{ + return BaseT::eval( + tuple + (a, b, c, d, e, f, g, h, i, j, k, l, m, n) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N, typename O> +inline typename actor_result +>::type +actor::operator()( + A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h, I& i, J& j, + K& k, L& l, M& m, N& n, O& o +) const +{ + return BaseT::eval( + tuple + (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) + ); +} + +#endif +#endif +#endif +#endif + +////////////////////////////////// +template +template +typename actor_result >::type +actor::operator()(unpack_tuple const &t) const +{ + return BaseT::eval(t); +} + +/////////////////////////////////////////////////////////////////////////////// +} // namespace phoenix + +#endif diff --git a/boost/boost/spirit/phoenix/binders.hpp b/boost/boost/spirit/phoenix/binders.hpp new file mode 100644 index 0000000000..a894ff8cb6 --- /dev/null +++ b/boost/boost/spirit/phoenix/binders.hpp @@ -0,0 +1,4067 @@ +/*============================================================================= + Phoenix v1.2 + Copyright (c) 2001-2002 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef PHOENIX_BINDERS_HPP +#define PHOENIX_BINDERS_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix { + +/////////////////////////////////////////////////////////////////////////////// +// +// Binders +// +// There are times when it is desireable to bind a simple functor, +// function, member function or member variable for deferred +// evaluation. This can be done through the binding facilities +// provided below. There are template classes: +// +// 1) function_ptr ( function pointer binder ) +// 2) functor ( functor pointer binder ) +// 3) member_function_ptr ( member function pointer binder ) +// 4) member_var_ptr ( member variable pointer binder ) +// +// These template classes are specialized lazy function classes for +// functors, function pointers, member function pointers and member +// variable pointers, respectively. These are subclasses of the +// lazy-function class (see functions.hpp). Each of these has a +// corresponding overloaded bind(x) function. Each bind(x) function +// generates a suitable binder object. +// +// Example, given a function foo: +// +// void foo_(int n) { std::cout << n << std::endl; } +// +// Here's how the function foo is bound: +// +// bind(&foo_) +// +// This bind expression results to a lazy-function (see +// functions.hpp) that is lazily evaluated. This bind expression is +// also equivalent to: +// +// function_ptr foo = &foo_; +// +// The template parameter of the function_ptr is the return and +// argument types of actual signature of the function to be bound +// read from left to right: +// +// void foo_(int); ---> function_ptr +// +// Either bind(&foo_) and its equivalent foo can now be used in the +// same way a lazy function (see functions.hpp) is used: +// +// bind(&foo_)(arg1) +// +// or +// +// foo(arg1) +// +// The latter, of course, being much easier to understand. This is +// now a full-fledged lazy function that can finally be evaluated +// by another function call invocation. A second function call will +// invoke the actual foo function: +// +// int i = 4; +// foo(arg1)(i); +// +// will print out "4". +// +// Binding functors and member functions can be done similarly. +// Here's how to bind a functor (e.g. std::plus): +// +// bind(std::plus()) +// +// or +// +// functor > plus; +// +// Again, these are full-fledged lazy functions. In this case, +// unlike the first example, expect 2 arguments (std::plus +// needs two arguments lhs and rhs). Either or both of which can be +// lazily bound: +// +// plus(arg1, arg2) // arg1 + arg2 +// plus(100, arg1) // 100 + arg1 +// plus(100, 200) // 300 +// +// A bound member function takes in a pointer or reference to an +// object as the first argument. For instance, given: +// +// struct xyz { void foo(int) const; }; +// +// xyz's foo member function can be bound as: +// +// bind(&xyz::foo) +// +// or +// +// member_function_ptr xyz_foo = &xyz::foo; +// +// The template parameter of the member_function_ptr is the return, +// class and argument types of actual signature of the function to +// be bound read from left to right: +// +// void xyz::foo_(int); ---> member_function_ptr +// +// Take note that a member_function_ptr lazy-function expects the +// first argument to be a pointer or reference to an object. Both +// the object (reference or pointer) and the arguments can be +// lazily bound. Examples: +// +// xyz obj; +// xyz_foo(arg1, arg2) // arg1.foo(arg2) +// xyz_foo(obj, arg1) // obj.foo(arg1) +// xyz_foo(obj, 100) // obj.foo(100) +// +// Be reminded that var(obj) must be used to call non-const member +// functions. For example, if xyz was declared as: +// +// struct xyz { void foo(int); }; +// +// the pointer or reference to the object must also be non-const. +// Lazily bound arguments are stored as const value by default (see +// variable class in primitives.hpp). +// +// xyz_foo(var(obj), 100) // obj.foo(100) +// +// Finally, member variables can be bound much like member +// functions. For instance, given: +// +// struct xyz { int v; }; +// +// xyz::v can be bound as: +// +// bind(&xyz::v) +// or +// +// member_var_ptr xyz_v = &xyz::v; +// +// The template parameter of the member_var_ptr is the type of the +// variable followed by the class: +// +// int xyz::v; ---> member_var_ptr +// +// Just like the member_function_ptr, member_var_ptr also expects +// the first argument to be a pointer or reference to an object. +// Both the object (reference or pointer) and the arguments can be +// lazily bound. Examples: +// +// xyz obj; +// xyz_v(arg1) // arg1.v +// xyz_v(obj) // obj.v +// +/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// +// Functor binder +// +/////////////////////////////////////////////////////////////////////////////// +template +struct functor_action : public FuncT { + +#if !defined(__BORLANDC__) && (!defined(__MWERKS__) || (__MWERKS__ > 0x3002)) + + template < + typename A = nil_t + , typename B = nil_t + , typename C = nil_t + +#if PHOENIX_LIMIT > 3 + , typename D = nil_t + , typename E = nil_t + , typename F = nil_t + +#if PHOENIX_LIMIT > 6 + , typename G = nil_t + , typename H = nil_t + , typename I = nil_t + +#if PHOENIX_LIMIT > 9 + , typename J = nil_t + , typename K = nil_t + , typename L = nil_t + +#if PHOENIX_LIMIT > 12 + , typename M = nil_t + , typename N = nil_t + , typename O = nil_t + +#endif +#endif +#endif +#endif + > + struct result { typedef typename FuncT::result_type type; }; +#endif + + functor_action(FuncT fptr_ = FuncT()) + : FuncT(fptr_) {} +}; + +#if defined(__BORLANDC__) || (defined(__MWERKS__) && (__MWERKS__ <= 0x3002)) + +/////////////////////////////////////////////////////////////////////////////// +// +// The following specializations are needed because Borland and CodeWarrior +// does not accept default template arguments in nested template classes in +// classes (i.e functor_action::result) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite0_result, TupleT> { + + typedef typename FuncT::result_type type; +}; + +////////////////////////////////// +template +struct composite1_result, TupleT, A> { + + typedef typename FuncT::result_type type; +}; + +////////////////////////////////// +template +struct composite2_result, TupleT, A, B> { + + typedef typename FuncT::result_type type; +}; + +////////////////////////////////// +template +struct composite3_result, TupleT, A, B, C> { + + typedef typename FuncT::result_type type; +}; + +#if PHOENIX_LIMIT > 3 +////////////////////////////////// +template +struct composite4_result, TupleT, + A, B, C, D> { + + typedef typename FuncT::result_type type; +}; + +////////////////////////////////// +template +struct composite5_result, TupleT, + A, B, C, D, E> { + + typedef typename FuncT::result_type type; +}; + +////////////////////////////////// +template +struct composite6_result, TupleT, + A, B, C, D, E, F> { + + typedef typename FuncT::result_type type; +}; + +#if PHOENIX_LIMIT > 6 +////////////////////////////////// +template +struct composite7_result, TupleT, + A, B, C, D, E, F, G> { + + typedef typename FuncT::result_type type; +}; + +////////////////////////////////// +template +struct composite8_result, TupleT, + A, B, C, D, E, F, G, H> { + + typedef typename FuncT::result_type type; +}; + +////////////////////////////////// +template +struct composite9_result, TupleT, + A, B, C, D, E, F, G, H, I> { + + typedef typename FuncT::result_type type; +}; + +#if PHOENIX_LIMIT > 9 +////////////////////////////////// +template +struct composite10_result, TupleT, + A, B, C, D, E, F, G, H, I, J> { + + typedef typename FuncT::result_type type; +}; + +////////////////////////////////// +template +struct composite11_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K> { + + typedef typename FuncT::result_type type; +}; + +////////////////////////////////// +template +struct composite12_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L> { + + typedef typename FuncT::result_type type; +}; + +#if PHOENIX_LIMIT > 12 +////////////////////////////////// +template +struct composite13_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L, M> { + + typedef typename FuncT::result_type type; +}; + +////////////////////////////////// +template +struct composite14_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L, M, N> { + + typedef typename FuncT::result_type type; +}; + +////////////////////////////////// +template +struct composite15_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> { + + typedef typename FuncT::result_type type; +}; + +#endif +#endif +#endif +#endif +#endif + +////////////////////////////////// +template +struct functor : public function > { + + functor(FuncT func) + : function >(functor_action(func)) {}; +}; + +////////////////////////////////// +template +inline functor +bind(FuncT func) +{ + return functor(func); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member variable pointer binder +// +/////////////////////////////////////////////////////////////////////////////// +namespace impl { + + ////////////////////////////////// + template + struct as_ptr { + + typedef T* pointer_type; + + static T* get(T& ref) + { return &ref; } + }; + + ////////////////////////////////// + template + struct as_ptr { + + typedef T* pointer_type; + + static T* get(T* ptr) + { return ptr; } + }; +} + +////////////////////////////////// +template +struct member_var_ptr_action_result { + + typedef typename ActionT::template result::type type; +}; + +////////////////////////////////// +template +struct member_var_ptr_action { + + typedef member_var_ptr_action self_t; + + template + struct result { + + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type type; + }; + + typedef T ClassT::*mem_var_ptr_t; + + member_var_ptr_action(mem_var_ptr_t ptr_) + : ptr(ptr_) {} + + template + typename member_var_ptr_action_result::type + operator()(CT& obj) const + { return impl::as_ptr::get(obj)->*ptr; } + + mem_var_ptr_t ptr; +}; + +////////////////////////////////// +template +struct member_var_ptr +: public function > { + + member_var_ptr(T ClassT::*mp) + : function > + (member_var_ptr_action(mp)) {} +}; + +////////////////////////////////// +template +inline member_var_ptr +bind(T ClassT::*mp) +{ + return member_var_ptr(mp); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (main class) +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename RT + , typename A = nil_t + , typename B = nil_t + , typename C = nil_t + +#if PHOENIX_LIMIT > 3 + , typename D = nil_t + , typename E = nil_t + , typename F = nil_t + +#if PHOENIX_LIMIT > 6 + , typename G = nil_t + , typename H = nil_t + , typename I = nil_t + +#if PHOENIX_LIMIT > 9 + , typename J = nil_t + , typename K = nil_t + , typename L = nil_t + +#if PHOENIX_LIMIT > 12 + , typename M = nil_t + , typename N = nil_t + , typename O = nil_t + +#endif +#endif +#endif +#endif + + , typename NU = nil_t // Not used +> +struct function_ptr_action; + +////////////////////////////////// +template < + typename RT + , typename A = nil_t + , typename B = nil_t + , typename C = nil_t + +#if PHOENIX_LIMIT > 3 + , typename D = nil_t + , typename E = nil_t + , typename F = nil_t + +#if PHOENIX_LIMIT > 6 + , typename G = nil_t + , typename H = nil_t + , typename I = nil_t + +#if PHOENIX_LIMIT > 9 + , typename J = nil_t + , typename K = nil_t + , typename L = nil_t + +#if PHOENIX_LIMIT > 12 + , typename M = nil_t + , typename N = nil_t + , typename O = nil_t + +#endif +#endif +#endif +#endif +> +struct function_ptr +: public function 3 + , D, E, F +#if PHOENIX_LIMIT > 6 + , G, H, I +#if PHOENIX_LIMIT > 9 + , J, K, L +#if PHOENIX_LIMIT > 12 + , M, N, O +#endif +#endif +#endif +#endif + > > { + + typedef function_ptr_action 3 + , D, E, F +#if PHOENIX_LIMIT > 6 + , G, H, I +#if PHOENIX_LIMIT > 9 + , J, K, L +#if PHOENIX_LIMIT > 12 + , M, N, O +#endif +#endif +#endif +#endif + > action_t; + + template + function_ptr(FPT fp) + : function(action_t(fp)) {} +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 0 arg) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(); + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()() const + { return fptr(); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)()) +{ + return function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 1 arg) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A); + + template + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()(A a) const + { return fptr(a); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A)) +{ + return function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 2 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B); + + template + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()(A a, B b) const + { return fptr(a, b); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B)) +{ + return function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 3 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C); + + template + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()(A a, B b, C c) const + { return fptr(a, b, c); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C)) +{ + return function_ptr(fptr); +} + +#if PHOENIX_LIMIT > 3 +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 4 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D); + + template + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()(A a, B b, C c, D d) const + { return fptr(a, b, c, d); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D)) +{ + return function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 5 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D, E); + + template < + typename A_, typename B_, typename C_, typename D_, typename E_ + > + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e + ) const + { return fptr(a, b, c, d, e); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D, E)) +{ + return function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 6 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D, E, F); + + template < + typename A_, typename B_, typename C_, typename D_, typename E_, + typename F_ + > + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, + F f + ) const + { return fptr(a, b, c, d, e, f); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D, E, F)) +{ + return function_ptr(fptr); +} + +#if PHOENIX_LIMIT > 6 +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 7 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D, E, F, G); + + template < + typename A_, typename B_, typename C_, typename D_, typename E_, + typename F_, typename G_ + > + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, + F f, G g + ) const + { return fptr(a, b, c, d, e, f, g); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D, E, F, G)) +{ + return function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 8 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D, E, F, G, H); + + template < + typename A_, typename B_, typename C_, typename D_, typename E_, + typename F_, typename G_, typename H_ + > + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, + F f, G g, H h + ) const + { return fptr(a, b, c, d, e, f, g, h); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D, E, F, G, H)) +{ + return function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 9 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D, E, F, G, H, I); + + template < + typename A_, typename B_, typename C_, typename D_, typename E_, + typename F_, typename G_, typename H_, typename I_ + > + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, + F f, G g, H h, I i + ) const + { return fptr(a, b, c, d, e, f, g, h, i); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D, E, F, G, H, I)) +{ + return function_ptr(fptr); +} + +#if PHOENIX_LIMIT > 9 +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 10 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D, E, F, G, H, I, J); + + template < + typename A_, typename B_, typename C_, typename D_, typename E_, + typename F_, typename G_, typename H_, typename I_, typename J_ + > + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, + F f, G g, H h, I i, J j + ) const + { return fptr(a, b, c, d, e, f, g, h, i, j); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D, E, F, G, H, I, J)) +{ + return function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 11 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D, E, F, G, H, I, J, K); + + template < + typename A_, typename B_, typename C_, typename D_, typename E_, + typename F_, typename G_, typename H_, typename I_, typename J_, + typename K_ + > + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, + F f, G g, H h, I i, J j, + K k + ) const + { return fptr(a, b, c, d, e, f, g, h, i, j, k); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D, E, F, G, H, I, J, K)) +{ + return function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 12 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D, E, F, G, H, I, J, K, L); + + template < + typename A_, typename B_, typename C_, typename D_, typename E_, + typename F_, typename G_, typename H_, typename I_, typename J_, + typename K_, typename L_ + > + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, + F f, G g, H h, I i, J j, + K k, L l + ) const + { return fptr(a, b, c, d, e, f, g, h, i, j, k, l); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D, E, F, G, H, I, J, K, L)) +{ + return function_ptr(fptr); +} + +#if PHOENIX_LIMIT > 12 +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 13 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D, E, F, G, H, I, J, K, L, M); + + template < + typename A_, typename B_, typename C_, typename D_, typename E_, + typename F_, typename G_, typename H_, typename I_, typename J_, + typename K_, typename L_, typename M_ + > + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, + F f, G g, H h, I i, J j, + K k, L l, M m + ) const + { return fptr(a, b, c, d, e, f, g, h, i, j, k, l, m); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M)) +{ + return function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 14 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D, E, F, G, H, I, J, K, L, M, N); + + template < + typename A_, typename B_, typename C_, typename D_, typename E_, + typename F_, typename G_, typename H_, typename I_, typename J_, + typename K_, typename L_, typename M_, typename N_ + > + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, + F f, G g, H h, I i, J j, + K k, L l, M m, N n + ) const + { return fptr(a, b, c, d, e, f, g, h, i, j, k, l, m, n); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N)) +{ + return function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Function pointer binder (specialization for 15 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function_ptr_action { + + typedef RT result_type; + typedef RT(*func_ptr_t)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O); + + template < + typename A_, typename B_, typename C_, typename D_, typename E_, + typename F_, typename G_, typename H_, typename I_, typename J_, + typename K_, typename L_, typename M_, typename N_, typename O_ + > + struct result { typedef result_type type; }; + + function_ptr_action(func_ptr_t fptr_) + : fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, + F f, G g, H h, I i, J j, + K k, L l, M m, N n, O o + ) const + { return fptr(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o); } + + func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline function_ptr +bind(RT(*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)) +{ + return function_ptr(fptr); +} + +#endif +#endif +#endif +#endif +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (main class) +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename RT, + typename ClassT + , typename A = nil_t + , typename B = nil_t + , typename C = nil_t + +#if PHOENIX_LIMIT > 3 + , typename D = nil_t + , typename E = nil_t + , typename F = nil_t + +#if PHOENIX_LIMIT > 6 + , typename G = nil_t + , typename H = nil_t + , typename I = nil_t + +#if PHOENIX_LIMIT > 9 + , typename J = nil_t + , typename K = nil_t + , typename L = nil_t + +#if PHOENIX_LIMIT > 12 + , typename M = nil_t + , typename N = nil_t + , typename O = nil_t + +#endif +#endif +#endif +#endif + + , typename NU = nil_t // Not used +> +struct member_function_ptr_action; + +////////////////////////////////// +template < + typename RT, + typename ClassT + , typename A = nil_t + , typename B = nil_t + , typename C = nil_t + +#if PHOENIX_LIMIT > 3 + , typename D = nil_t + , typename E = nil_t + , typename F = nil_t + +#if PHOENIX_LIMIT > 6 + , typename G = nil_t + , typename H = nil_t + , typename I = nil_t + +#if PHOENIX_LIMIT > 9 + , typename J = nil_t + , typename K = nil_t + , typename L = nil_t + +#if PHOENIX_LIMIT > 12 + , typename M = nil_t + , typename N = nil_t + , typename O = nil_t + +#endif +#endif +#endif +#endif +> +struct member_function_ptr +: public function 3 + , D, E, F +#if PHOENIX_LIMIT > 6 + , G, H, I +#if PHOENIX_LIMIT > 9 + , J, K, L +#if PHOENIX_LIMIT > 12 + , M, N, O +#endif +#endif +#endif +#endif + > > { + + typedef member_function_ptr_action 3 + , D, E, F +#if PHOENIX_LIMIT > 6 + , G, H, I +#if PHOENIX_LIMIT > 9 + , J, K, L +#if PHOENIX_LIMIT > 12 + , M, N, O +#endif +#endif +#endif +#endif + > action_t; + + template + member_function_ptr(FPT fp) + : function(action_t(fp)) {} +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 0 arg) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(); + typedef RT(ClassT::*cmf)() const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj) const + { return (impl::as_ptr::get(obj)->*fptr)(); } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)()) +{ + return member_function_ptr(fptr); +} + +template +inline member_function_ptr +bind(RT(ClassT::*fptr)() const) +{ + return member_function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 1 arg) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A); + typedef RT(ClassT::*cmf)(A) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, A a) const + { return (impl::as_ptr::get(obj)->*fptr)(a); } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A)) +{ + return member_function_ptr(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A) const) +{ + return member_function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 2 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B); + typedef RT(ClassT::*cmf)(A, B) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, A a, B b) const + { return (impl::as_ptr::get(obj)->*fptr)(a, b); } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B)) +{ + return member_function_ptr(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B) const) +{ + return member_function_ptr(fptr); +} + +#if PHOENIX_LIMIT > 3 +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 3 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C); + typedef RT(ClassT::*cmf)(A, B, C) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, A a, B b, C c) const + { return (impl::as_ptr::get(obj)->*fptr)(a, b, c); } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C)) +{ + return member_function_ptr(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C) const) +{ + return member_function_ptr(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 4 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D); + typedef RT(ClassT::*cmf)(A, B, C, D) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d + ) const + { return (impl::as_ptr::get(obj)->*fptr)(a, b, c, d); } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D>(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 5 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E); + typedef RT(ClassT::*cmf)(A, B, C, D, E) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d, E e + ) const + { return (impl::as_ptr::get(obj)->*fptr)(a, b, c, d, e); } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D, E>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D, E>(fptr); +} + +#if PHOENIX_LIMIT > 6 +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 6 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d, E e, F f + ) const + { return (impl::as_ptr::get(obj)->*fptr)(a, b, c, d, e, f); } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D, E, F>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D, E, F>(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 7 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d, E e, F f, G g + ) const + { return (impl::as_ptr::get(obj)->*fptr)(a, b, c, d, e, f, g); } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D, E, F, G>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D, E, F, G>(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 8 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d, E e, F f, G g, H h + ) const + { return (impl::as_ptr::get(obj)->*fptr)(a, b, c, d, e, f, g, h); } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D, E, F, G, H>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D, E, F, G, H>(fptr); +} + +#if PHOENIX_LIMIT > 9 +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 9 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d, E e, F f, G g, H h, I i + ) const + { return (impl::as_ptr::get(obj)->*fptr)(a, b, c, d, e, f, g, h, i); } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D, E, F, G, H, I>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D, E, F, G, H, I>(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 10 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j + ) const + { + return (impl::as_ptr::get(obj)->*fptr) + (a, b, c, d, e, f, g, h, i, j); + } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D, E, F, G, H, I, J>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J>(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 11 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J, K); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J, K) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k + ) const + { + return (impl::as_ptr::get(obj)->*fptr) + (a, b, c, d, e, f, g, h, i, j, k); + } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K>(fptr); +} + +#if PHOENIX_LIMIT > 12 +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 12 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J, K, L); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J, K, L) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l + ) const + { + return (impl::as_ptr::get(obj)->*fptr) + (a, b, c, d, e, f, g, h, i, j, k, l); + } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L>(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 13 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J, K, L, M); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J, K, L, M) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m + ) const + { + return (impl::as_ptr::get(obj)->*fptr) + (a, b, c, d, e, f, g, h, i, j, k, l, m); + } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L, M>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L, M>(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 14 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J, K, L, M, N); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J, K, L, M, N) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n + ) const + { + return (impl::as_ptr::get(obj)->*fptr) + (a, b, c, d, e, f, g, h, i, j, k, l, m, n); + } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L, M, N>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L, M, N>(fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Member function pointer binder (specialization for 15 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct member_function_ptr_action { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + member_function_ptr_action(mem_func_ptr_t fptr_) + : fptr(fptr_) {} + + template + result_type operator()(CT& obj, + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o + ) const + { + return (impl::as_ptr::get(obj)->*fptr) + (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o); + } + + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)) +{ + return member_function_ptr< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(fptr); +} + +////////////////////////////////// +template +inline member_function_ptr +bind(RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) const) +{ + return member_function_ptr< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(fptr); +} + +#endif +#endif +#endif +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (main class) +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename RT, + typename ClassT + , typename A = nil_t + , typename B = nil_t + , typename C = nil_t + +#if PHOENIX_LIMIT > 3 + , typename D = nil_t + , typename E = nil_t + , typename F = nil_t + +#if PHOENIX_LIMIT > 6 + , typename G = nil_t + , typename H = nil_t + , typename I = nil_t + +#if PHOENIX_LIMIT > 9 + , typename J = nil_t + , typename K = nil_t + , typename L = nil_t + +#if PHOENIX_LIMIT > 12 + , typename M = nil_t + , typename N = nil_t + , typename O = nil_t + +#endif +#endif +#endif +#endif + + , typename NU = nil_t // Not used +> +struct bound_member_action; + +////////////////////////////////// +template < + typename RT, + typename ClassT + , typename A = nil_t + , typename B = nil_t + , typename C = nil_t + +#if PHOENIX_LIMIT > 3 + , typename D = nil_t + , typename E = nil_t + , typename F = nil_t + +#if PHOENIX_LIMIT > 6 + , typename G = nil_t + , typename H = nil_t + , typename I = nil_t + +#if PHOENIX_LIMIT > 9 + , typename J = nil_t + , typename K = nil_t + , typename L = nil_t + +#if PHOENIX_LIMIT > 12 + , typename M = nil_t + , typename N = nil_t + , typename O = nil_t + +#endif +#endif +#endif +#endif +> +struct bound_member +: public function 3 + , D, E, F +#if PHOENIX_LIMIT > 6 + , G, H, I +#if PHOENIX_LIMIT > 9 + , J, K, L +#if PHOENIX_LIMIT > 12 + , M, N, O +#endif +#endif +#endif +#endif + > > { + + typedef bound_member_action 3 + , D, E, F +#if PHOENIX_LIMIT > 6 + , G, H, I +#if PHOENIX_LIMIT > 9 + , J, K, L +#if PHOENIX_LIMIT > 12 + , M, N, O +#endif +#endif +#endif +#endif + > action_t; + + template + bound_member(CT & c, FPT fp) + : function(action_t(c,fp)) {} + +#if !defined(__BORLANDC__) + template + bound_member(CT * c, FPT fp) + : function(action_t(c,fp)) {} +#endif +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 0 arg) +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct bound_member_action 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(); + typedef RT(ClassT::*cmf)() const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()() const + { return (obj->*fptr)(); } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// + +template +inline bound_member +bind(ClassT & obj, RT(ClassT::*fptr)()) +{ + return bound_member(obj, fptr); +} + +template +inline bound_member +bind(ClassT * obj, RT(ClassT::*fptr)()) +{ +#if defined(__MWERKS__) && (__MWERKS__ < 0x3003) + return bound_member(*obj, fptr); +#else + return bound_member(obj, fptr); +#endif +} + +template +inline bound_member +bind(ClassT const& obj, RT(ClassT::*fptr)()) +{ + return bound_member(obj, fptr); +} + +template +inline bound_member +bind(ClassT const* obj, RT(ClassT::*fptr)() const) +{ +#if defined(__MWERKS__) && (__MWERKS__ < 0x3003) + return bound_member(*obj, fptr); +#else + return bound_member(obj, fptr); +#endif +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 1 arg) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A); + typedef RT(ClassT::*cmf)(A) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()(A a) const + { return (obj->*fptr)(a); } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj, RT(ClassT::*fptr)(A)) +{ + return bound_member(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj, RT(ClassT::*fptr)(A)) +{ + return bound_member(obj,fptr); +} + +////////////////////////////////// +template +inline bound_member +bind(ClassT const& obj, RT(ClassT::*fptr)(A) const) +{ + return bound_member(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj, RT(ClassT::*fptr)(A) const) +{ + return bound_member(obj,fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 2 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B); + typedef RT(ClassT::*cmf)(A, B) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()(A a, B b) const + { return (obj->*fptr)(a, b); } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B)) +{ + return bound_member(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B)) +{ + return bound_member(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B) const) +{ + return bound_member(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B) const) +{ + return bound_member(obj,fptr); +} + +#if PHOENIX_LIMIT > 3 +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 3 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C); + typedef RT(ClassT::*cmf)(A, B, C) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()(A a, B b, C c) const + { return (obj->*fptr)(a, b, c); } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C)) +{ + return bound_member(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C)) +{ + return bound_member(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C) const) +{ + return bound_member(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C) const) +{ + return bound_member(obj,fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 4 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D); + typedef RT(ClassT::*cmf)(A, B, C, D) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()(A a, B b, C c, D d) const + { return (obj->*fptr)(a, b, c, d); } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D)) +{ + return bound_member< + RT, ClassT, A, B, C, D>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D)) +{ + return bound_member< + RT, ClassT, A, B, C, D>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D>(obj,fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 5 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E); + typedef RT(ClassT::*cmf)(A, B, C, D, E) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e + ) const + { return (obj->*fptr)(a, b, c, d, e); } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D, E)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D, E)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D, E) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D, E) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E>(obj,fptr); +} + +#if PHOENIX_LIMIT > 6 +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 6 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template < + typename A_, typename B_, typename C_, typename D_, + typename E_, typename F_ + > + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, F f + ) const + { return (obj->*fptr)(a, b, c, d, e, f); } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D, E, F)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D, E, F)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D, E, F) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D, E, F) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F>(obj,fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 7 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template < + typename A_, typename B_, typename C_, typename D_, + typename E_, typename F_, typename G_ + > + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, F f, G g + ) const + { return (obj->*fptr)(a, b, c, d, e, f, g); } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G>(obj,fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 8 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template < + typename A_, typename B_, typename C_, typename D_, + typename E_, typename F_, typename G_, typename H_ + > + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, F f, G g, H h + ) const + { return (obj->*fptr)(a, b, c, d, e, f, g, h); } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H>(obj,fptr); +} + +#if PHOENIX_LIMIT > 9 +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 9 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template < + typename A_, typename B_, typename C_, typename D_, + typename E_, typename F_, typename G_, typename H_, typename I_ + > + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, F f, G g, H h, I i + ) const + { return (obj->*fptr)(a, b, c, d, e, f, g, h, i); } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I>(obj,fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 10 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template < + typename A_, typename B_, typename C_, typename D_, + typename E_, typename F_, typename G_, typename H_, typename I_, + typename J_ + > + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j + ) const + { + return (obj->*fptr)(a, b, c, d, e, f, g, h, i, j); + } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J>(obj,fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 11 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J, K); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J, K) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template < + typename A_, typename B_, typename C_, typename D_, + typename E_, typename F_, typename G_, typename H_, typename I_, + typename J_, typename K_ + > + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k + ) const + { + return (obj->*fptr)(a, b, c, d, e, f, g, h, i, j, k); + } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K>(obj,fptr); +} + +#if PHOENIX_LIMIT > 12 +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 12 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J, K, L); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J, K, L) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template < + typename A_, typename B_, typename C_, typename D_, + typename E_, typename F_, typename G_, typename H_, typename I_, + typename J_, typename K_, typename L_ + > + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l + ) const + { + return (obj->*fptr)(a, b, c, d, e, f, g, h, i, j, k, l); + } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L>(obj,fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 13 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J, K, L, M); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J, K, L, M) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template < + typename A_, typename B_, typename C_, typename D_, + typename E_, typename F_, typename G_, typename H_, typename I_, + typename J_, typename K_, typename L_, typename M_ + > + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m + ) const + { + return (obj->*fptr)(a, b, c, d, e, f, g, h, i, j, k, l, m); + } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L, M>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L, M>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L, M>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L, M>(obj,fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 14 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J, K, L, M, N); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J, K, L, M, N) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template < + typename A_, typename B_, typename C_, typename D_, + typename E_, typename F_, typename G_, typename H_, typename I_, + typename J_, typename K_, typename L_, typename M_, typename N_ + > + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n + ) const + { + return (obj->*fptr)(a, b, c, d, e, f, g, h, i, j, k, l, m, n); + } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L, M, N>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L, M, N>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L, M, N>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L, M, N>(obj,fptr); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Bound member function binder (specialization for 15 args) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct bound_member_action { + + typedef RT result_type; + typedef RT(ClassT::*mf)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O); + typedef RT(ClassT::*cmf)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) const; + typedef char is_const[boost::is_const::value ? 1 : 2]; + typedef typename impl::if_t::type mem_func_ptr_t; + + template < + typename A_, typename B_, typename C_, typename D_, + typename E_, typename F_, typename G_, typename H_, typename I_, + typename J_, typename K_, typename L_, typename M_, typename N_, + typename O_ + > + struct result { typedef result_type type; }; + + template + bound_member_action(CT & obj_, mem_func_ptr_t fptr_) + : obj(impl::as_ptr::get(obj_)), fptr(fptr_) {} + + result_type operator()( + A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o + ) const + { + return (obj->*fptr)(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o); + } + + typename impl::as_ptr::pointer_type obj; + mem_func_ptr_t fptr; +}; + +////////////////////////////////// +template +inline bound_member +bind(ClassT & obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(obj,fptr); +} + +template +inline bound_member +bind(ClassT * obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)) +{ + return bound_member< + RT, ClassT, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const& obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(obj,fptr); +} + +template +inline bound_member +bind(ClassT const* obj,RT(ClassT::*fptr)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) const) +{ + return bound_member< + RT, ClassT const, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(obj,fptr); +} + +#endif +#endif +#endif +#endif + +} // namespace phoenix + +#endif diff --git a/boost/boost/spirit/phoenix/casts.hpp b/boost/boost/spirit/phoenix/casts.hpp new file mode 100644 index 0000000000..3782e9f8b4 --- /dev/null +++ b/boost/boost/spirit/phoenix/casts.hpp @@ -0,0 +1,1471 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2001-2003 Hartmut Kaiser + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef PHOENIX_CASTS_HPP +#define PHOENIX_CASTS_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix { + +/////////////////////////////////////////////////////////////////////////////// +// +// Phoenix predefined maximum construct_ limit. This limit defines the maximum +// number of parameters supported for calles to the set of construct_ template +// functions (lazy object construction, see below). This number defaults to 3. +// The actual maximum is rounded up in multiples of 3. Thus, if this value +// is 4, the actual limit is 6. The ultimate maximum limit in this +// implementation is 15. +// PHOENIX_CONSTRUCT_LIMIT should NOT be greater than PHOENIX_LIMIT! + +#if !defined(PHOENIX_CONSTRUCT_LIMIT) +#define PHOENIX_CONSTRUCT_LIMIT PHOENIX_LIMIT +#endif + +// ensure PHOENIX_CONSTRUCT_LIMIT <= PHOENIX_LIMIT +BOOST_STATIC_ASSERT(PHOENIX_CONSTRUCT_LIMIT <= PHOENIX_LIMIT); + +// ensure PHOENIX_CONSTRUCT_LIMIT <= 15 +BOOST_STATIC_ASSERT(PHOENIX_CONSTRUCT_LIMIT <= 15); + +/////////////////////////////////////////////////////////////////////////////// +// +// Lazy C++ casts +// +// The set of lazy C++ cast template classes and functions provide a way +// of lazily casting certain type to another during parsing. +// The lazy C++ templates are (syntactically) used very much like +// the well known C++ casts: +// +// A *a = static_cast_(...actor returning a convertible type...); +// +// where the given parameter should be an actor, which eval() function +// returns a convertible type. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct static_cast_l { + + template + struct result { typedef T type; }; + + static_cast_l(A const& a_) + : a(a_) {} + + template + T + eval(TupleT const& args) const + { + return static_cast(a.eval(args)); + } + + A a; +}; + +////////////////////////////////// +template +inline actor > +static_cast_(actor const& a) +{ + typedef static_cast_l cast_t; + return actor(cast_t(a)); +} + +////////////////////////////////// +template +struct dynamic_cast_l { + + template + struct result { typedef T type; }; + + dynamic_cast_l(A const& a_) + : a(a_) {} + + template + T + eval(TupleT const& args) const + { + return dynamic_cast(a.eval(args)); + } + + A a; +}; + +////////////////////////////////// +template +inline actor > +dynamic_cast_(actor const& a) +{ + typedef dynamic_cast_l cast_t; + return actor(cast_t(a)); +} + +////////////////////////////////// +template +struct reinterpret_cast_l { + + template + struct result { typedef T type; }; + + reinterpret_cast_l(A const& a_) + : a(a_) {} + + template + T + eval(TupleT const& args) const + { + return reinterpret_cast(a.eval(args)); + } + + A a; +}; + +////////////////////////////////// +template +inline actor > +reinterpret_cast_(actor const& a) +{ + typedef reinterpret_cast_l cast_t; + return actor(cast_t(a)); +} + +////////////////////////////////// +template +struct const_cast_l { + + template + struct result { typedef T type; }; + + const_cast_l(A const& a_) + : a(a_) {} + + template + T + eval(TupleT const& args) const + { + return const_cast(a.eval(args)); + } + + A a; +}; + +////////////////////////////////// +template +inline actor > +const_cast_(actor const& a) +{ + typedef const_cast_l cast_t; + return actor(cast_t(a)); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// construct_ +// +// Lazy object construction +// +// The set of construct_<> template classes and functions provide a way +// of lazily constructing certain object from a arbitrary set of +// actors during parsing. +// The construct_ templates are (syntactically) used very much like +// the well known C++ casts: +// +// A a = construct_(...arbitrary list of actors...); +// +// where the given parameters are submitted as parameters to the +// contructor of the object of type A. (This certainly implies, that +// type A has a constructor with a fitting set of parameter types +// defined.) +// +// The maximum number of needed parameters is controlled through the +// preprocessor constant PHOENIX_CONSTRUCT_LIMIT. Note though, that this +// limit should not be greater than PHOENIX_LIMIT. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct construct_l_0 { + typedef T result_type; + + T operator()() const { + return T(); + } +}; + + +template +struct construct_l { + + template < + typename A + , typename B + , typename C + +#if PHOENIX_CONSTRUCT_LIMIT > 3 + , typename D + , typename E + , typename F + +#if PHOENIX_CONSTRUCT_LIMIT > 6 + , typename G + , typename H + , typename I + +#if PHOENIX_CONSTRUCT_LIMIT > 9 + , typename J + , typename K + , typename L + +#if PHOENIX_CONSTRUCT_LIMIT > 12 + , typename M + , typename N + , typename O +#endif +#endif +#endif +#endif + > + struct result { typedef T type; }; + + T operator()() const + { + return T(); + } + + template + T operator()(A const& a) const + { + T t(a); + return t; + } + + template + T operator()(A const& a, B const& b) const + { + T t(a, b); + return t; + } + + template + T operator()(A const& a, B const& b, C const& c) const + { + T t(a, b, c); + return t; + } + +#if PHOENIX_CONSTRUCT_LIMIT > 3 + template < + typename A, typename B, typename C, typename D + > + T operator()( + A const& a, B const& b, C const& c, D const& d) const + { + T t(a, b, c, d); + return t; + } + + template < + typename A, typename B, typename C, typename D, typename E + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e) const + { + T t(a, b, c, d, e); + return t; + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f) const + { + T t(a, b, c, d, e, f); + return t; + } + +#if PHOENIX_CONSTRUCT_LIMIT > 6 + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g) const + { + T t(a, b, c, d, e, f, g); + return t; + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h) const + { + T t(a, b, c, d, e, f, g, h); + return t; + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i) const + { + T t(a, b, c, d, e, f, g, h, i); + return t; + } + +#if PHOENIX_CONSTRUCT_LIMIT > 9 + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j) const + { + T t(a, b, c, d, e, f, g, h, i, j); + return t; + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k) const + { + T t(a, b, c, d, e, f, g, h, i, j, k); + return t; + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l) const + { + T t(a, b, c, d, e, f, g, h, i, j, k, l); + return t; + } + +#if PHOENIX_CONSTRUCT_LIMIT > 12 + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m) const + { + T t(a, b, c, d, e, f, g, h, i, j, k, l, m); + return t; + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n) const + { + T t(a, b, c, d, e, f, g, h, i, j, k, l, m, n); + return t; + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N, typename O + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n, O const& o) const + { + T t(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o); + return t; + } + +#endif +#endif +#endif +#endif +}; + + +template +struct construct_1 { + + template < + typename A + > + struct result { typedef T type; }; + + template + T operator()(A const& a) const + { + T t(a); + return t; + } + +}; + +template +struct construct_2 { + + template < + typename A + , typename B + > + struct result { typedef T type; }; + + template + T operator()(A const& a, B const& b) const + { + T t(a, b); + return t; + } + +}; + +template +struct construct_3 { + + template < + typename A + , typename B + , typename C + > + struct result { typedef T type; }; + + template + T operator()(A const& a, B const& b, C const& c) const + { + T t(a, b, c); + return t; + } +}; + +#if PHOENIX_CONSTRUCT_LIMIT > 3 +template +struct construct_4 { + + template < + typename A + , typename B + , typename C + , typename D + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D + > + T operator()( + A const& a, B const& b, C const& c, D const& d) const + { + T t(a, b, c, d); + return t; + } +}; + + +template +struct construct_5 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D, typename E + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e) const + { + T t(a, b, c, d, e); + return t; + } +}; + + +template +struct construct_6 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f) const + { + T t(a, b, c, d, e, f); + return t; + } +}; +#endif + + +#if PHOENIX_CONSTRUCT_LIMIT > 6 +template +struct construct_7 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g) const + { + T t(a, b, c, d, e, f, g); + return t; + } +}; + +template +struct construct_8 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h) const + { + T t(a, b, c, d, e, f, g, h); + return t; + } +}; + +template +struct construct_9 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i) const + { + T t(a, b, c, d, e, f, g, h, i); + return t; + } +}; +#endif + + +#if PHOENIX_CONSTRUCT_LIMIT > 9 +template +struct construct_10 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j) const + { + T t(a, b, c, d, e, f, g, h, i, j); + return t; + } +}; + +template +struct construct_11 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + , typename K + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k) const + { + T t(a, b, c, d, e, f, g, h, i, j, k); + return t; + } +}; + +template +struct construct_12 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + , typename K + , typename L + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l) const + { + T t(a, b, c, d, f, e, g, h, i, j, k, l); + return t; + } +}; +#endif + +#if PHOENIX_CONSTRUCT_LIMIT > 12 +template +struct construct_13 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + , typename K + , typename L + , typename M + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m) const + { + T t(a, b, c, d, e, f, g, h, i, j, k, l, m); + return t; + } +}; + +template +struct construct_14 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + , typename K + , typename L + , typename M + , typename N + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n) const + { + T t(a, b, c, d, e, f, g, h, i, j, k, l, m, n); + return t; + } +}; + +template +struct construct_15 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + , typename K + , typename L + , typename M + , typename N + , typename O + > + struct result { typedef T type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N, typename O + > + T operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n, O const& o) const + { + T t(a, b, c, d, f, e, g, h, i, j, k, l, m, n, o); + return t; + } +}; +#endif + + +#if defined(__BORLANDC__) || (defined(__MWERKS__) && (__MWERKS__ <= 0x3002)) + +/////////////////////////////////////////////////////////////////////////////// +// +// The following specializations are needed because Borland and CodeWarrior +// does not accept default template arguments in nested template classes in +// classes (i.e construct_l::result) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite0_result, TupleT> { + + typedef T type; +}; + +////////////////////////////////// +template +struct composite1_result, TupleT, A> { + + typedef T type; +}; + +////////////////////////////////// +template +struct composite2_result, TupleT, A, B> { + + typedef T type; +}; + +////////////////////////////////// +template +struct composite3_result, TupleT, A, B, C> { + + typedef T type; +}; + +#if PHOENIX_LIMIT > 3 +////////////////////////////////// +template +struct composite4_result, TupleT, + A, B, C, D> { + + typedef T type; +}; + +////////////////////////////////// +template +struct composite5_result, TupleT, + A, B, C, D, E> { + + typedef T type; +}; + +////////////////////////////////// +template +struct composite6_result, TupleT, + A, B, C, D, E, F> { + + typedef T type; +}; + +#if PHOENIX_LIMIT > 6 +////////////////////////////////// +template +struct composite7_result, TupleT, + A, B, C, D, E, F, G> { + + typedef T type; +}; + +////////////////////////////////// +template +struct composite8_result, TupleT, + A, B, C, D, E, F, G, H> { + + typedef T type; +}; + +////////////////////////////////// +template +struct composite9_result, TupleT, + A, B, C, D, E, F, G, H, I> { + + typedef T type; +}; + +#if PHOENIX_LIMIT > 9 +////////////////////////////////// +template +struct composite10_result, TupleT, + A, B, C, D, E, F, G, H, I, J> { + + typedef T type; +}; + +////////////////////////////////// +template +struct composite11_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K> { + + typedef T type; +}; + +////////////////////////////////// +template +struct composite12_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L> { + + typedef T type; +}; + +#if PHOENIX_LIMIT > 12 +////////////////////////////////// +template +struct composite13_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L, M> { + + typedef T type; +}; + +////////////////////////////////// +template +struct composite14_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L, M, N> { + + typedef T type; +}; + +////////////////////////////////// +template +struct composite15_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> { + + typedef T type; +}; + +#endif +#endif +#endif +#endif +#endif + +////////////////////////////////// +template +inline typename impl::make_composite >::type +construct_() +{ + typedef impl::make_composite > make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_l_0())); +} + +////////////////////////////////// +template +inline typename impl::make_composite, A>::type +construct_(A const& a) +{ + typedef impl::make_composite, A> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_1(), + as_actor::convert(a) + )); +} + +////////////////////////////////// +template +inline typename impl::make_composite, A, B>::type +construct_(A const& a, B const& b) +{ + typedef impl::make_composite, A, B> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_2(), + as_actor::convert(a), + as_actor::convert(b) + )); +} + +////////////////////////////////// +template +inline typename impl::make_composite, A, B, C>::type +construct_(A const& a, B const& b, C const& c) +{ + typedef impl::make_composite, A, B, C> make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_3(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c) + )); +} + +#if PHOENIX_CONSTRUCT_LIMIT > 3 +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D +> +inline typename impl::make_composite, A, B, C, D>::type +construct_( + A const& a, B const& b, C const& c, D const& d) +{ + typedef + impl::make_composite, A, B, C, D> + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_4(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E +> +inline typename impl::make_composite, A, B, C, D, E>::type +construct_( + A const& a, B const& b, C const& c, D const& d, E const& e) +{ + typedef + impl::make_composite, A, B, C, D, E> + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_5(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F +> +inline typename impl::make_composite, A, B, C, D, E, F>::type +construct_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f) +{ + typedef + impl::make_composite, A, B, C, D, E, F> + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_6(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f) + )); +} + +#if PHOENIX_CONSTRUCT_LIMIT > 6 +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G +> +inline typename impl::make_composite, A, B, C, D, E, F, G>::type +construct_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g) +{ + typedef + impl::make_composite, A, B, C, D, E, F, G> + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_7(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H +> +inline typename impl::make_composite, A, B, C, D, E, F, G, H>::type +construct_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h) +{ + typedef + impl::make_composite, A, B, C, D, E, F, G, H> + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_8(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I +> +inline typename impl::make_composite, A, B, C, D, E, F, G, H, I>::type +construct_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i) +{ + typedef + impl::make_composite, A, B, C, D, E, F, G, H, I> + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_9(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i) + )); +} + +#if PHOENIX_CONSTRUCT_LIMIT > 9 +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J +> +inline typename impl::make_composite< + construct_10, A, B, C, D, E, F, G, H, I, J>::type +construct_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j) +{ + typedef + impl::make_composite< + construct_10, A, B, C, D, E, F, G, H, I, J + > + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_10(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, typename K +> +inline typename impl::make_composite< + construct_11, A, B, C, D, E, F, G, H, I, J, K>::type +construct_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k) +{ + typedef + impl::make_composite< + construct_11, A, B, C, D, E, F, G, H, I, J, K + > + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_11(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, typename K, + typename L +> +inline typename impl::make_composite< + construct_12, A, B, C, D, E, F, G, H, I, J, K, L>::type +construct_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l) +{ + typedef + impl::make_composite< + construct_12, A, B, C, D, E, F, G, H, I, J, K, L + > + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_12(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l) + )); +} + +#if PHOENIX_CONSTRUCT_LIMIT > 12 +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, typename K, + typename L, typename M +> +inline typename impl::make_composite< + construct_13, A, B, C, D, E, F, G, H, I, J, K, L, M>::type +construct_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m) +{ + typedef + impl::make_composite< + construct_13, A, B, C, D, E, F, G, H, I, J, K, L, M + > + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_13(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l), + as_actor::convert(m) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, typename K, + typename L, typename M, typename N +> +inline typename impl::make_composite< + construct_14, A, B, C, D, E, F, G, H, I, J, K, L, M>::type +construct_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n) +{ + typedef + impl::make_composite< + construct_14, A, B, C, D, E, F, G, H, I, J, K, L, M, N + > + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_14(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l), + as_actor::convert(m), + as_actor::convert(n) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, typename K, + typename L, typename M, typename N, typename O +> +inline typename impl::make_composite< + construct_15, A, B, C, D, E, F, G, H, I, J, K, L, M, O>::type +construct_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n, O const& o) +{ + typedef + impl::make_composite< + construct_15, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O + > + make_composite_t; + typedef typename make_composite_t::type type_t; + typedef typename make_composite_t::composite_type composite_type_t; + + return type_t(composite_type_t(construct_15(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l), + as_actor::convert(m), + as_actor::convert(n), + as_actor::convert(o) + )); +} + +#endif +#endif +#endif +#endif + +/////////////////////////////////////////////////////////////////////////////// +} // namespace phoenix + +#endif // PHOENIX_CASTS_HPP diff --git a/boost/boost/spirit/phoenix/closures.hpp b/boost/boost/spirit/phoenix/closures.hpp new file mode 100644 index 0000000000..3f7c1f6ce3 --- /dev/null +++ b/boost/boost/spirit/phoenix/closures.hpp @@ -0,0 +1,422 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2001-2002 Joel de Guzman + MT code Copyright (c) 2002-2003 Martin Wille + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef PHOENIX_CLOSURES_HPP +#define PHOENIX_CLOSURES_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +#ifdef PHOENIX_THREADSAFE +#include +#endif + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix { + +/////////////////////////////////////////////////////////////////////////////// +// +// Adaptable closures +// +// The framework will not be complete without some form of closures +// support. Closures encapsulate a stack frame where local +// variables are created upon entering a function and destructed +// upon exiting. Closures provide an environment for local +// variables to reside. Closures can hold heterogeneous types. +// +// Phoenix closures are true hardware stack based closures. At the +// very least, closures enable true reentrancy in lambda functions. +// A closure provides access to a function stack frame where local +// variables reside. Modeled after Pascal nested stack frames, +// closures can be nested just like nested functions where code in +// inner closures may access local variables from in-scope outer +// closures (accessing inner scopes from outer scopes is an error +// and will cause a run-time assertion failure). +// +// There are three (3) interacting classes: +// +// 1) closure: +// +// At the point of declaration, a closure does not yet create a +// stack frame nor instantiate any variables. A closure declaration +// declares the types and names[note] of the local variables. The +// closure class is meant to be subclassed. It is the +// responsibility of a closure subclass to supply the names for +// each of the local variable in the closure. Example: +// +// struct my_closure : closure { +// +// member1 num; // names the 1st (int) local variable +// member2 message; // names the 2nd (string) local variable +// member3 real; // names the 3rd (double) local variable +// }; +// +// my_closure clos; +// +// Now that we have a closure 'clos', its local variables can be +// accessed lazily using the dot notation. Each qualified local +// variable can be used just like any primitive actor (see +// primitives.hpp). Examples: +// +// clos.num = 30 +// clos.message = arg1 +// clos.real = clos.num * 1e6 +// +// The examples above are lazily evaluated. As usual, these +// expressions return composite actors that will be evaluated +// through a second function call invocation (see operators.hpp). +// Each of the members (clos.xxx) is an actor. As such, applying +// the operator() will reveal its identity: +// +// clos.num() // will return the current value of clos.num +// +// *** [note] Acknowledgement: Juan Carlos Arevalo-Baeza (JCAB) +// introduced and initilally implemented the closure member names +// that uses the dot notation. +// +// 2) closure_member +// +// The named local variables of closure 'clos' above are actually +// closure members. The closure_member class is an actor and +// conforms to its conceptual interface. member1..memberN are +// predefined typedefs that correspond to each of the listed types +// in the closure template parameters. +// +// 3) closure_frame +// +// When a closure member is finally evaluated, it should refer to +// an actual instance of the variable in the hardware stack. +// Without doing so, the process is not complete and the evaluated +// member will result to an assertion failure. Remember that the +// closure is just a declaration. The local variables that a +// closure refers to must still be instantiated. +// +// The closure_frame class does the actual instantiation of the +// local variables and links these variables with the closure and +// all its members. There can be multiple instances of +// closure_frames typically situated in the stack inside a +// function. Each closure_frame instance initiates a stack frame +// with a new set of closure local variables. Example: +// +// void foo() +// { +// closure_frame frame(clos); +// /* do something */ +// } +// +// where 'clos' is an instance of our closure 'my_closure' above. +// Take note that the usage above precludes locally declared +// classes. If my_closure is a locally declared type, we can still +// use its self_type as a paramater to closure_frame: +// +// closure_frame frame(clos); +// +// Upon instantiation, the closure_frame links the local variables +// to the closure. The previous link to another closure_frame +// instance created before is saved. Upon destruction, the +// closure_frame unlinks itself from the closure and relinks the +// preceding closure_frame prior to this instance. +// +// The local variables in the closure 'clos' above is default +// constructed in the stack inside function 'foo'. Once 'foo' is +// exited, all of these local variables are destructed. In some +// cases, default construction is not desirable and we need to +// initialize the local closure variables with some values. This +// can be done by passing in the initializers in a compatible +// tuple. A compatible tuple is one with the same number of +// elements as the destination and where each element from the +// destination can be constructed from each corresponding element +// in the source. Example: +// +// tuple init(123, "Hello", 1000); +// closure_frame frame(clos, init); +// +// Here now, our closure_frame's variables are initialized with +// int: 123, char const*: "Hello" and int: 1000. +// +/////////////////////////////////////////////////////////////////////////////// + +namespace impl +{ + /////////////////////////////////////////////////////////////////////// + // closure_frame_holder is a simple class that encapsulates the + // storage for a frame pointer. It uses thread specific data in + // case when multithreading is enabled, an ordinary pointer otherwise + // + // it has get() and set() member functions. set() has to be used + // _after_ get(). get() contains intialisation code in the multi + // threading case + // + // closure_frame_holder is used by the closure<> class to store + // the pointer to the current frame. + // +#ifndef PHOENIX_THREADSAFE + template + struct closure_frame_holder + { + typedef FrameT frame_t; + typedef frame_t *frame_ptr; + + closure_frame_holder() : frame(0) {} + + frame_ptr &get() { return frame; } + void set(frame_t *f) { frame = f; } + + private: + frame_ptr frame; + + // no copies, no assignments + closure_frame_holder(closure_frame_holder const &); + closure_frame_holder &operator=(closure_frame_holder const &); + }; +#else + template + struct closure_frame_holder + { + typedef FrameT frame_t; + typedef frame_t *frame_ptr; + + closure_frame_holder() : tsp_frame() {} + + frame_ptr &get() + { + if (!tsp_frame.get()) + tsp_frame.reset(new frame_ptr(0)); + return *tsp_frame; + } + void set(frame_ptr f) + { + *tsp_frame = f; + } + + private: + boost::thread_specific_ptr tsp_frame; + + // no copies, no assignments + closure_frame_holder(closure_frame_holder const &); + closure_frame_holder &operator=(closure_frame_holder const &); + }; +#endif +} // namespace phoenix::impl + +/////////////////////////////////////////////////////////////////////////////// +// +// closure_frame class +// +/////////////////////////////////////////////////////////////////////////////// +template +class closure_frame : public ClosureT::tuple_t { + +public: + + closure_frame(ClosureT const& clos) + : ClosureT::tuple_t(), save(clos.frame.get()), frame(clos.frame) + { clos.frame.set(this); } + + template + closure_frame(ClosureT const& clos, TupleT const& init) + : ClosureT::tuple_t(init), save(clos.frame.get()), frame(clos.frame) + { clos.frame.set(this); } + + ~closure_frame() + { frame.set(save); } + +private: + + closure_frame(closure_frame const&); // no copy + closure_frame& operator=(closure_frame const&); // no assign + + closure_frame* save; + impl::closure_frame_holder& frame; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// closure_member class +// +/////////////////////////////////////////////////////////////////////////////// +template +class closure_member { + +public: + + typedef typename ClosureT::tuple_t tuple_t; + + closure_member() + : frame(ClosureT::closure_frame_holder_ref()) {} + + template + struct result { + + typedef typename tuple_element< + N, typename ClosureT::tuple_t + >::rtype type; + }; + + template + typename tuple_element::rtype + eval(TupleT const& /*args*/) const + { + using namespace std; + assert(frame.get() != 0); + return (*frame.get())[tuple_index()]; + } + +private: + impl::closure_frame_holder &frame; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// closure class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename T0 = nil_t + , typename T1 = nil_t + , typename T2 = nil_t + +#if PHOENIX_LIMIT > 3 + , typename T3 = nil_t + , typename T4 = nil_t + , typename T5 = nil_t + +#if PHOENIX_LIMIT > 6 + , typename T6 = nil_t + , typename T7 = nil_t + , typename T8 = nil_t + +#if PHOENIX_LIMIT > 9 + , typename T9 = nil_t + , typename T10 = nil_t + , typename T11 = nil_t + +#if PHOENIX_LIMIT > 12 + , typename T12 = nil_t + , typename T13 = nil_t + , typename T14 = nil_t + +#endif +#endif +#endif +#endif +> +class closure { + +public: + + typedef tuple< + T0, T1, T2 +#if PHOENIX_LIMIT > 3 + , T3, T4, T5 +#if PHOENIX_LIMIT > 6 + , T6, T7, T8 +#if PHOENIX_LIMIT > 9 + , T9, T10, T11 +#if PHOENIX_LIMIT > 12 + , T12, T13, T14 +#endif +#endif +#endif +#endif + > tuple_t; + + typedef closure< + T0, T1, T2 +#if PHOENIX_LIMIT > 3 + , T3, T4, T5 +#if PHOENIX_LIMIT > 6 + , T6, T7, T8 +#if PHOENIX_LIMIT > 9 + , T9, T10, T11 +#if PHOENIX_LIMIT > 12 + , T12, T13, T14 +#endif +#endif +#endif +#endif + > self_t; + + typedef closure_frame closure_frame_t; + + closure() + : frame() { closure_frame_holder_ref(&frame); } + closure_frame_t& context() { assert(frame!=0); return frame.get(); } + closure_frame_t const& context() const { assert(frame!=0); return frame.get(); } + + typedef actor > member1; + typedef actor > member2; + typedef actor > member3; + +#if PHOENIX_LIMIT > 3 + typedef actor > member4; + typedef actor > member5; + typedef actor > member6; + +#if PHOENIX_LIMIT > 6 + typedef actor > member7; + typedef actor > member8; + typedef actor > member9; + +#if PHOENIX_LIMIT > 9 + typedef actor > member10; + typedef actor > member11; + typedef actor > member12; + +#if PHOENIX_LIMIT > 12 + typedef actor > member13; + typedef actor > member14; + typedef actor > member15; + +#endif +#endif +#endif +#endif + +#if !defined(__MWERKS__) || (__MWERKS__ > 0x3002) +private: +#endif + + closure(closure const&); // no copy + closure& operator=(closure const&); // no assign + +#if !defined(__MWERKS__) || (__MWERKS__ > 0x3002) + template + friend class closure_member; + + template + friend class closure_frame; +#endif + + typedef impl::closure_frame_holder holder_t; + + static holder_t & + closure_frame_holder_ref(holder_t* holder_ = 0) + { +#ifdef PHOENIX_THREADSAFE + static boost::thread_specific_ptr tsp_frame; + if (!tsp_frame.get()) + tsp_frame.reset(new holder_t *(0)); + holder_t *& holder = *tsp_frame; +#else + static holder_t* holder = 0; +#endif + if (holder_ != 0) + holder = holder_; + return *holder; + } + + mutable holder_t frame; +}; + +} + // namespace phoenix + +#endif diff --git a/boost/boost/spirit/phoenix/composite.hpp b/boost/boost/spirit/phoenix/composite.hpp new file mode 100644 index 0000000000..903d31935e --- /dev/null +++ b/boost/boost/spirit/phoenix/composite.hpp @@ -0,0 +1,1423 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2001-2002 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef PHOENIX_COMPOSITE_HPP +#define PHOENIX_COMPOSITE_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix { + +/////////////////////////////////////////////////////////////////////////////// +// +// composite class +// +// A composite is an actor base class composed of zero or more +// actors (see actor.hpp) and an operation. A composite is itself +// an actor superclass and conforms to its conceptual interface. +// Its eval member function un-funnels the tupled actual arguments +// from the tuple by invoking each of the actors' eval member +// function. The results of each are then passed on as arguments to +// the operation. Specializations are provided to handle different +// numbers of actors. +// +// Schematically: +// +// actor0.eval(tupled_args) --> arg0 --> | +// actor1.eval(tupled_args) --> arg1 --> | +// actor2.eval(tupled_args) --> arg3 --> | --> operation(arg0...argN) +// ... | +// actorN.eval(tupled_args) --> argN --> | +// +// The operation can be any suitable functor that can accept the +// arguments passed in by the composite. The operation is expected +// to have a member operator() that carries out the actual +// operation. There should be a one to one correspondence between +// actors of the composite and the arguments of the operation's +// member operator(). +// +// The operation is also expected to have a nested template class +// result. The nested template class result should have a +// typedef 'type' that reflects the return type of its member +// operator(). This is essentially a type computer that answers the +// metaprogramming question "Given arguments of type T0...TN, what +// will be its operator()'s return type?". +// +// There is a special case for operations that accept no arguments. +// Such nullary operations are only required to define a typedef +// result_type that reflects the return type of its operator(). +// +// Here's an example of a simple operation that squares a number: +// +// struct square { +// +// template +// struct result { typedef ArgT type; }; +// +// template +// ArgT operator()(ArgT n) const { return n * n; } +// }; +// +// As can be seen, operations can be polymorphic. Its arguments and +// return type are not fixed to a particular type. The example +// above for example, can handle any ArgT type as long as it has a +// multiplication operator. +// +// Composites are not created directly. Instead, there are meta- +// programs provided that indirectly create composites. See +// operators.hpp, binders.hpp and functions.hpp for examples. +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename OperationT + , typename A = nil_t + , typename B = nil_t + , typename C = nil_t + +#if PHOENIX_LIMIT > 3 + , typename D = nil_t + , typename E = nil_t + , typename F = nil_t + +#if PHOENIX_LIMIT > 6 + , typename G = nil_t + , typename H = nil_t + , typename I = nil_t + +#if PHOENIX_LIMIT > 9 + , typename J = nil_t + , typename K = nil_t + , typename L = nil_t + +#if PHOENIX_LIMIT > 12 + , typename M = nil_t + , typename N = nil_t + , typename O = nil_t + +#endif +#endif +#endif +#endif + + , typename NU = nil_t // Not used +> +struct composite; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <0 actor> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite0_result { + + typedef typename OperationT::result_type type; +}; + +////////////////////////////////// +template +struct composite 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite0_result< + OperationT, TupleT + >::type type; + }; + + composite(OperationT const& op_) + : op(op_) {} + + template + typename OperationT::result_type + eval(TupleT const& /*args*/) const + { + return op(); + } + + mutable OperationT op; // operation +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <1 actor> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite1_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite1_result< + OperationT, TupleT, A + >::type type; + }; + + composite(OperationT const& op_, + A const& a_) + : op(op_), a(a_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + return op(ra); + } + + mutable OperationT op; // operation + A a; // actors +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <2 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite2_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite2_result< + OperationT, TupleT, A, B + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_) + : op(op_), a(a_), b(b_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + return op(ra, rb); + } + + mutable OperationT op; // operation + A a; B b; // actors +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <3 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite3_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite3_result< + OperationT, TupleT, A, B, C + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_) + : op(op_), a(a_), b(b_), c(c_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + return op(ra, rb, rc); + } + + mutable OperationT op; // operation + A a; B b; C c; // actors +}; + +#if PHOENIX_LIMIT > 3 +/////////////////////////////////////////////////////////////////////////////// +// +// composite <4 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite4_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite4_result< + OperationT, TupleT, A, B, C, D + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_) + : op(op_), a(a_), b(b_), c(c_), d(d_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + return op(ra, rb, rc, rd); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; // actors +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <5 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite5_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite5_result< + OperationT, TupleT, A, B, C, D, E + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_, E const& e_) + : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + typename actor_result::type re = e.eval(args); + return op(ra, rb, rc, rd, re); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; E e; // actors +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <6 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite6_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite6_result< + OperationT, TupleT, A, B, C, D, E, F + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, + F const& f_) + : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + typename actor_result::type re = e.eval(args); + typename actor_result::type rf = f.eval(args); + return op(ra, rb, rc, rd, re, rf); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; E e; F f; // actors +}; + +#if PHOENIX_LIMIT > 6 +/////////////////////////////////////////////////////////////////////////////// +// +// composite <7 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite7_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite7_result< + OperationT, TupleT, A, B, C, D, E, F, G + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, + F const& f_, G const& g_) + : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + typename actor_result::type re = e.eval(args); + typename actor_result::type rf = f.eval(args); + typename actor_result::type rg = g.eval(args); + return op(ra, rb, rc, rd, re, rf, rg); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; E e; F f; G g; // actors +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <8 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite8_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite8_result< + OperationT, TupleT, A, B, C, D, E, F, G, H + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, + F const& f_, G const& g_, H const& h_) + : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + typename actor_result::type re = e.eval(args); + typename actor_result::type rf = f.eval(args); + typename actor_result::type rg = g.eval(args); + typename actor_result::type rh = h.eval(args); + return op(ra, rb, rc, rd, re, rf, rg, rh); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; E e; F f; G g; H h; // actors +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <9 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite9_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite9_result< + OperationT, TupleT, A, B, C, D, E, F, G, H, I + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, + F const& f_, G const& g_, H const& h_, I const& i_) + : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + typename actor_result::type re = e.eval(args); + typename actor_result::type rf = f.eval(args); + typename actor_result::type rg = g.eval(args); + typename actor_result::type rh = h.eval(args); + typename actor_result::type ri = i.eval(args); + return op(ra, rb, rc, rd, re, rf, rg, rh, ri); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; E e; F f; G g; H h; I i; // actors +}; + +#if PHOENIX_LIMIT > 9 +/////////////////////////////////////////////////////////////////////////////// +// +// composite <10 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite10_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite10_result< + OperationT, TupleT, A, B, C, D, E, F, G, H, I, J + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, + F const& f_, G const& g_, H const& h_, I const& i_, J const& j_) + : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + typename actor_result::type re = e.eval(args); + typename actor_result::type rf = f.eval(args); + typename actor_result::type rg = g.eval(args); + typename actor_result::type rh = h.eval(args); + typename actor_result::type ri = i.eval(args); + typename actor_result::type rj = j.eval(args); + return op(ra, rb, rc, rd, re, rf, rg, rh, ri, rj); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; E e; F f; G g; H h; I i; J j; // actors +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <11 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite11_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite11_result< + OperationT, TupleT, A, B, C, D, E, F, G, H, I, J, K + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, + F const& f_, G const& g_, H const& h_, I const& i_, J const& j_, + K const& k_) + : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_), + k(k_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + typename actor_result::type re = e.eval(args); + typename actor_result::type rf = f.eval(args); + typename actor_result::type rg = g.eval(args); + typename actor_result::type rh = h.eval(args); + typename actor_result::type ri = i.eval(args); + typename actor_result::type rj = j.eval(args); + typename actor_result::type rk = k.eval(args); + return op(ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; E e; F f; G g; H h; I i; J j; + K k;// actors +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <12 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite12_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> { + + typedef composite self_t; + + template + struct result { + + typedef typename composite12_result< + OperationT, TupleT, A, B, C, D, E, F, G, H, I, J, K, L + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, + F const& f_, G const& g_, H const& h_, I const& i_, J const& j_, + K const& k_, L const& l_) + : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_), + k(k_), l(l_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + typename actor_result::type re = e.eval(args); + typename actor_result::type rf = f.eval(args); + typename actor_result::type rg = g.eval(args); + typename actor_result::type rh = h.eval(args); + typename actor_result::type ri = i.eval(args); + typename actor_result::type rj = j.eval(args); + typename actor_result::type rk = k.eval(args); + typename actor_result::type rl = l.eval(args); + return op(ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; E e; F f; G g; H h; I i; J j; + K k; L l;// actors +}; + +#if PHOENIX_LIMIT > 12 +/////////////////////////////////////////////////////////////////////////////// +// +// composite <13 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite13_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite { + + typedef composite self_t; + + template + struct result { + + typedef typename composite13_result< + OperationT, TupleT, A, B, C, D, E, F, G, H, I, J, K, L, M + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, + F const& f_, G const& g_, H const& h_, I const& i_, J const& j_, + K const& k_, L const& l_, M const& m_) + : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_), + k(k_), l(l_), m(m_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + typename actor_result::type re = e.eval(args); + typename actor_result::type rf = f.eval(args); + typename actor_result::type rg = g.eval(args); + typename actor_result::type rh = h.eval(args); + typename actor_result::type ri = i.eval(args); + typename actor_result::type rj = j.eval(args); + typename actor_result::type rk = k.eval(args); + typename actor_result::type rl = l.eval(args); + typename actor_result::type rm = m.eval(args); + return op(ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; E e; F f; G g; H h; I i; J j; + K k; L l; M m; // actors +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <14 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite14_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite { + + typedef composite self_t; + + template + struct result { + + typedef typename composite14_result< + OperationT, TupleT, A, B, C, D, E, F, G, H, I, J, K, L, M, N + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, + F const& f_, G const& g_, H const& h_, I const& i_, J const& j_, + K const& k_, L const& l_, M const& m_, N const& n_) + : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_), + k(k_), l(l_), m(m_), n(n_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + typename actor_result::type re = e.eval(args); + typename actor_result::type rf = f.eval(args); + typename actor_result::type rg = g.eval(args); + typename actor_result::type rh = h.eval(args); + typename actor_result::type ri = i.eval(args); + typename actor_result::type rj = j.eval(args); + typename actor_result::type rk = k.eval(args); + typename actor_result::type rl = l.eval(args); + typename actor_result::type rm = m.eval(args); + typename actor_result::type rn = n.eval(args); + return op(ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm, rn); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; E e; F f; G g; H h; I i; J j; + K k; L l; M m; N n; // actors +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// composite <15 actors> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite15_result { + + typedef typename OperationT::template result< + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type, + typename actor_result::plain_type + >::type type; +}; + +////////////////////////////////// +template +struct composite { + + typedef composite self_t; + + template + struct result { + + typedef typename composite15_result< + OperationT, TupleT, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O + >::type type; + }; + + composite(OperationT const& op_, + A const& a_, B const& b_, C const& c_, D const& d_, E const& e_, + F const& f_, G const& g_, H const& h_, I const& i_, J const& j_, + K const& k_, L const& l_, M const& m_, N const& n_, O const& o_) + : op(op_), a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_), + k(k_), l(l_), m(m_), n(n_), o(o_) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + typename actor_result::type ra = a.eval(args); + typename actor_result::type rb = b.eval(args); + typename actor_result::type rc = c.eval(args); + typename actor_result::type rd = d.eval(args); + typename actor_result::type re = e.eval(args); + typename actor_result::type rf = f.eval(args); + typename actor_result::type rg = g.eval(args); + typename actor_result::type rh = h.eval(args); + typename actor_result::type ri = i.eval(args); + typename actor_result::type rj = j.eval(args); + typename actor_result::type rk = k.eval(args); + typename actor_result::type rl = l.eval(args); + typename actor_result::type rm = m.eval(args); + typename actor_result::type rn = n.eval(args); + typename actor_result::type ro = o.eval(args); + return op(ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm, rn, ro); + } + + mutable OperationT op; // operation + A a; B b; C c; D d; E e; F f; G g; H h; I i; J j; + K k; L l; M m; N n; O o; // actors +}; + +#endif +#endif +#endif +#endif + +namespace impl { + + /////////////////////////////////////////////////////////////////////////// + // + // make_composite is basically a type computer that answers the + // question "Given types T0..TN, what composite type should I + // create and if I were to generate an actual + // composite, what type should I return?" + // + /////////////////////////////////////////////////////////////////////////// + template < + typename OperationT + , typename A = nil_t + , typename B = nil_t + , typename C = nil_t + +#if PHOENIX_LIMIT > 3 + , typename D = nil_t + , typename E = nil_t + , typename F = nil_t + +#if PHOENIX_LIMIT > 6 + , typename G = nil_t + , typename H = nil_t + , typename I = nil_t + +#if PHOENIX_LIMIT > 9 + , typename J = nil_t + , typename K = nil_t + , typename L = nil_t + +#if PHOENIX_LIMIT > 12 + , typename M = nil_t + , typename N = nil_t + , typename O = nil_t + +#endif +#endif +#endif +#endif + > + struct make_composite { + + typedef composite::type + , typename as_actor::type + , typename as_actor::type + +#if PHOENIX_LIMIT > 3 + , typename as_actor::type + , typename as_actor::type + , typename as_actor::type + +#if PHOENIX_LIMIT > 6 + , typename as_actor::type + , typename as_actor::type + , typename as_actor::type + +#if PHOENIX_LIMIT > 9 + , typename as_actor::type + , typename as_actor::type + , typename as_actor::type + +#if PHOENIX_LIMIT > 12 + , typename as_actor::type + , typename as_actor::type + , typename as_actor::type + +#endif +#endif +#endif +#endif + > composite_type; + + typedef actor type; + }; + + /////////////////////////////////////////////////////////////////////////// + // + // make_unary, make_binary, make_binary1, make_binary2 and + // make_binary3 utilities are provided here for easy creation of + // unary and binary composites. + // + /////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////// input is an actor + template + struct make_unary { + + typedef typename make_composite + >::type type; + + static type + construct(actor const& _0) + { + typedef typename make_composite + >::composite_type + ret_t; + + return ret_t(OperationT(), _0); + } + }; + + ////////////////////////////////// LHS is an actor, RHS is unknown + template + struct make_binary1 { + + typedef typename make_composite + , B>::type type; + + static type + construct(actor const& _0, B const& _1) + { + typedef typename make_composite + , B>::composite_type + ret_t; + + return ret_t(OperationT(), _0, as_actor::convert(_1)); + } + }; + + ////////////////////////////////// LHS is unknown, RHS is an actor + template + struct make_binary2 { + + typedef typename make_composite + >::type type; + + static type + construct(A const& _0, actor const& _1) + { + typedef typename make_composite + >::composite_type + ret_t; + + return ret_t(OperationT(), as_actor::convert(_0), _1); + } + }; + + ////////////////////////////////// Both LHS and RHS are actors + template + struct make_binary3 { + + typedef typename make_composite + , actor >::type type; + + static type + construct(actor const& _0, actor const& _1) + { + typedef typename make_composite + , actor >::composite_type + ret_t; + + return ret_t(OperationT(), _0, _1); + } + }; + +} // namespace impl + +} // namespace phoenix + +#endif diff --git a/boost/boost/spirit/phoenix/functions.hpp b/boost/boost/spirit/phoenix/functions.hpp new file mode 100644 index 0000000000..dc13485857 --- /dev/null +++ b/boost/boost/spirit/phoenix/functions.hpp @@ -0,0 +1,761 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2001-2002 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef PHOENIX_FUNCTIONS_HPP +#define PHOENIX_FUNCTIONS_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix { + +/////////////////////////////////////////////////////////////////////////////// +// +// function class +// +// Lazy functions +// +// This class provides a mechanism for lazily evaluating functions. +// Syntactically, a lazy function looks like an ordinary C/C++ +// function. The function call looks the same. However, unlike +// ordinary functions, the actual function execution is deferred. +// (see actor.hpp, primitives.hpp and composite.hpp for an +// overview). For example here are sample factorial function calls: +// +// factorial(4) +// factorial(arg1) +// factorial(arg1 * 6) +// +// These functions are automatically lazily bound unlike ordinary +// function pointers or functor objects that need to be explicitly +// bound through the bind function (see binders.hpp). +// +// A lazy function works in conjunction with a user defined functor +// (as usual with a member operator()). Only special forms of +// functor objects are allowed. This is required to enable true +// polymorphism (STL style monomorphic functors and function +// pointers can still be used through the bind facility in +// binders.hpp). +// +// This special functor is expected to have a nested template class +// result (where N is the number of arguments of its +// member operator()). The nested template class result should have +// a typedef 'type' that reflects the return type of its member +// operator(). This is essentially a type computer that answers the +// metaprogramming question "Given arguments of type A...TN, what +// will be the operator()'s return type?". +// +// There is a special case for functors that accept no arguments. +// Such nullary functors are only required to define a typedef +// result_type that reflects the return type of its operator(). +// +// Here's an example of a simple functor that computes the +// factorial of a number: +// +// struct factorial_impl { +// +// template +// struct result { typedef Arg type; }; +// +// template +// Arg operator()(Arg n) const +// { return (n <= 0) ? 1 : n * this->operator()(n-1); } +// }; +// +// As can be seen, the functor can be polymorphic. Its arguments +// and return type are not fixed to a particular type. The example +// above for example, can handle any type as long as it can carry +// out the required operations (i.e. <=, * and -). +// +// We can now declare and instantiate a lazy 'factorial' function: +// +// function factorial; +// +// Invoking a lazy function 'factorial' does not immediately +// execute the functor factorial_impl. Instead, a composite (see +// composite.hpp) object is created and returned to the caller. +// Example: +// +// factorial(arg1) +// +// does nothing more than return a composite. A second function +// call will invoke the actual factorial function. Example: +// +// int i = 4; +// cout << factorial(arg1)(i); +// +// will print out "24". +// +// Take note that in certain cases (e.g. for functors with state), +// an instance may be passed on to the constructor. Example: +// +// function factorial(ftor); +// +// where ftor is an instance of factorial_impl (this is not +// necessary in this case since factorial is a simple stateless +// functor). Take care though when using functors with state +// because the functors are taken in by value. It is best to keep +// the data manipulated by a functor outside the functor itself and +// keep a reference to this data inside the functor. Also, it is +// best to keep functors as small as possible. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct function { + + function() : op() {} + function(OperationT const& op_) : op(op_) {} + + actor > + operator()() const; + + template + typename impl::make_composite::type + operator()(A const& a) const; + + template + typename impl::make_composite::type + operator()(A const& a, B const& b) const; + + template + typename impl::make_composite::type + operator()(A const& a, B const& b, C const& c) const; + +#if PHOENIX_LIMIT > 3 + + template + typename impl::make_composite::type + operator()(A const& a, B const& b, C const& c, D const& d) const; + + template + typename impl::make_composite< + OperationT, A, B, C, D, E + >::type + operator()( + A const& a, B const& b, C const& c, D const& d, E const& e + ) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F + > + typename impl::make_composite< + OperationT, A, B, C, D, E, F + >::type + operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f + ) const; + +#if PHOENIX_LIMIT > 6 + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G + > + typename impl::make_composite< + OperationT, A, B, C, D, E, F, G + >::type + operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g + ) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H + > + typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H + >::type + operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h + ) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I + > + typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I + >::type + operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i + ) const; + +#if PHOENIX_LIMIT > 9 + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J + > + typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J + >::type + operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j + ) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K + > + typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K + >::type + operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k + ) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L + > + typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L + >::type + operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l + ) const; + +#if PHOENIX_LIMIT > 12 + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M + > + typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L, M + >::type + operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m + ) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N + > + typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L, M, N + >::type + operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n + ) const; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N, typename O + > + typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O + >::type + operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n, O const& o + ) const; + +#endif +#endif +#endif +#endif + + OperationT op; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// function class implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +inline actor > +function::operator()() const +{ + return actor >(op); +} + +////////////////////////////////// +template +template +inline typename impl::make_composite::type +function::operator()(A const& a) const +{ + typedef typename impl::make_composite::composite_type ret_t; + return ret_t + ( + op, + as_actor::convert(a) + ); +} + +////////////////////////////////// +template +template +inline typename impl::make_composite::type +function::operator()(A const& a, B const& b) const +{ + typedef + typename impl::make_composite::composite_type + ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b) + ); +} + +////////////////////////////////// +template +template +inline typename impl::make_composite::type +function::operator()(A const& a, B const& b, C const& c) const +{ + typedef + typename impl::make_composite::composite_type + ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c) + ); +} + +#if PHOENIX_LIMIT > 3 +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D +> +inline typename impl::make_composite< + OperationT, A, B, C, D +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E +> +inline typename impl::make_composite< + OperationT, A, B, C, D, E +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d, E const& e +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D, E + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F +> +inline typename impl::make_composite< + OperationT, A, B, C, D, E, F +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D, E, F + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f) + ); +} + +#if PHOENIX_LIMIT > 6 + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G +> +inline typename impl::make_composite< + OperationT, A, B, C, D, E, F, G +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D, E, F, G + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H +> +inline typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I +> +inline typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i) + ); +} + +#if PHOENIX_LIMIT > 9 + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J +> +inline typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K +> +inline typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L +> +inline typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l) + ); +} + +#if PHOENIX_LIMIT > 12 + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M +> +inline typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L, M +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L, M + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l), + as_actor::convert(m) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N +> +inline typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L, M, N +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L, M, N + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l), + as_actor::convert(m), + as_actor::convert(n) + ); +} + +////////////////////////////////// +template +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N, typename O +> +inline typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O +>::type +function::operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n, O const& o +) const +{ + typedef typename impl::make_composite< + OperationT, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O + >::composite_type ret_t; + + return ret_t( + op, + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l), + as_actor::convert(m), + as_actor::convert(n), + as_actor::convert(o) + ); +} + +#endif +#endif +#endif +#endif + +/////////////////////////////////////////////////////////////////////////////// +} // namespace phoenix + +#endif diff --git a/boost/boost/spirit/phoenix/new.hpp b/boost/boost/spirit/phoenix/new.hpp new file mode 100644 index 0000000000..61d5dc79dd --- /dev/null +++ b/boost/boost/spirit/phoenix/new.hpp @@ -0,0 +1,1285 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2001-2003 Hartmut Kaiser + Copyright (c) 2003 Vaclav Vesely + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#ifndef PHOENIX_NEW_HPP +#define PHOENIX_NEW_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix { + +/////////////////////////////////////////////////////////////////////////////// +// +// Phoenix predefined maximum new_ limit. This limit defines the maximum +// number of parameters supported for calles to the set of new_ template +// functions (lazy object construction, see below). This number defaults to 3. +// The actual maximum is rounded up in multiples of 3. Thus, if this value +// is 4, the actual limit is 6. The ultimate maximum limit in this +// implementation is 15. +// PHOENIX_CONSTRUCT_LIMIT should NOT be greater than PHOENIX_LIMIT! + +#if !defined(PHOENIX_CONSTRUCT_LIMIT) +#define PHOENIX_CONSTRUCT_LIMIT PHOENIX_LIMIT +#endif + +// ensure PHOENIX_CONSTRUCT_LIMIT <= PHOENIX_LIMIT +BOOST_STATIC_ASSERT(PHOENIX_CONSTRUCT_LIMIT <= PHOENIX_LIMIT); + +// ensure PHOENIX_CONSTRUCT_LIMIT <= 15 +BOOST_STATIC_ASSERT(PHOENIX_CONSTRUCT_LIMIT <= 15); + +/////////////////////////////////////////////////////////////////////////////// +// +// new_ +// +// Lazy object construction +// +// The set of new_<> template classes and functions provide a way +// of lazily constructing certain object from a arbitrary set of +// actors during parsing. +// The new_ templates are (syntactically) used very much like +// the well known C++ casts: +// +// A *a = new_(...arbitrary list of actors...); +// +// where the given parameters are submitted as parameters to the +// contructor of the object of type A. (This certainly implies, that +// type A has a constructor with a fitting set of parameter types +// defined.) +// +// The maximum number of needed parameters is controlled through the +// preprocessor constant PHOENIX_CONSTRUCT_LIMIT. Note though, that this +// limit should not be greater than PHOENIX_LIMIT. +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct new_l_0 +{ + typedef T* result_type; + + T* operator()() const + { + return new T(); + } +}; + +template +struct new_l { + + template < + typename A + , typename B + , typename C + +#if PHOENIX_CONSTRUCT_LIMIT > 3 + , typename D + , typename E + , typename F + +#if PHOENIX_CONSTRUCT_LIMIT > 6 + , typename G + , typename H + , typename I + +#if PHOENIX_CONSTRUCT_LIMIT > 9 + , typename J + , typename K + , typename L + +#if PHOENIX_CONSTRUCT_LIMIT > 12 + , typename M + , typename N + , typename O +#endif +#endif +#endif +#endif + > + struct result { typedef T* type; }; + + T* operator()() const { + return new T(); + } + + template + T* operator()(A const& a) const { + return new T(a); + } + + template + T* operator()(A const& a, B const& b) const { + return new T(a, b); + } + + template + T* operator()(A const& a, B const& b, C const& c) const { + return new T(a, b, c); + } + +#if PHOENIX_CONSTRUCT_LIMIT > 3 + template < + typename A, typename B, typename C, typename D + > + T* operator()( + A const& a, B const& b, C const& c, D const& d) const + { + return new T(a, b, c, d); + } + + template < + typename A, typename B, typename C, typename D, typename E + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e) const + { + return new T(a, b, c, d, e); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f) const + { + return new T(a, b, c, d, e, f); + } + +#if PHOENIX_CONSTRUCT_LIMIT > 6 + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g) const + { + return new T(a, b, c, d, e, f, g); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h) const + { + return new T(a, b, c, d, e, f, g, h); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i) const + { + return new T(a, b, c, d, e, f, g, h, i); + } + +#if PHOENIX_CONSTRUCT_LIMIT > 9 + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j) const + { + return new T(a, b, c, d, e, f, g, h, i, j); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k) const + { + return new T(a, b, c, d, e, f, g, h, i, j, k); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l) const + { + return new T(a, b, c, d, e, f, g, h, i, j, k, l); + } + +#if PHOENIX_CONSTRUCT_LIMIT > 12 + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m) const + { + return new T(a, b, c, d, e, f, g, h, i, j, k, l, m); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n) const + { + return new T(a, b, c, d, e, f, g, h, i, j, k, l, m, n); + } + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N, typename O + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n, O const& o) const + { + return new T(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o); + } + +#endif +#endif +#endif +#endif +}; + +template +struct new_1 { + + template < + typename A + > + struct result { typedef T* type; }; + + template + T* operator()(A const& a) const { + return new T(a); + } + +}; + +template +struct new_2 { + + template < + typename A + , typename B + > + struct result { typedef T* type; }; + + template + T* operator()(A const& a, B const& b) const { + return new T(a, b); + } + +}; + +template +struct new_3 { + + template < + typename A + , typename B + , typename C + > + struct result { typedef T* type; }; + + template + T* operator()(A const& a, B const& b, C const& c) const { + return new T(a, b, c); + } +}; + +#if PHOENIX_CONSTRUCT_LIMIT > 3 +template +struct new_4 { + + template < + typename A + , typename B + , typename C + , typename D + > + struct result { typedef T* type; }; + + + template < + typename A, typename B, typename C, typename D + > + T* operator()( + A const& a, B const& b, C const& c, D const& d) const + { + return new T(a, b, c, d); + } +}; + + +template +struct new_5 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + > + struct result { typedef T* type; }; + + template < + typename A, typename B, typename C, typename D, typename E + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e) const + { + return new T(a, b, c, d, e); + } +}; + + +template +struct new_6 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + > + struct result { typedef T* type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f) const + { + return new T(a, b, c, d, e, f); + } +}; +#endif + + +#if PHOENIX_CONSTRUCT_LIMIT > 6 +template +struct new_7 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + > + struct result { typedef T* type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g) const + { + return new T(a, b, c, d, e, f, g); + } +}; + +template +struct new_8 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + > + struct result { typedef T* type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h) const + { + return new T(a, b, c, d, e, f, g, h); + } +}; + +template +struct new_9 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + > + struct result { typedef T* type; }; + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i) const + { + return new T(a, b, c, d, e, f, g, h, i); + } +}; +#endif + + +#if PHOENIX_CONSTRUCT_LIMIT > 9 +template +struct new_10 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + > + struct result { typedef T* type; }; + + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j) const + { + return new T(a, b, c, d, e, f, g, h, i, j); + } +}; + +template +struct new_11 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + , typename K + > + struct result { typedef T* type; }; + + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k) const + { + return new T(a, b, c, d, e, f, g, h, i, j, k); + } + +}; + +template +struct new_12 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + , typename K + , typename L + > + struct result { typedef T* type; }; + + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l) const + { + return new T(a, b, c, d, f, e, g, h, i, j, k, l); + } +}; +#endif + +#if PHOENIX_CONSTRUCT_LIMIT > 12 +template +struct new_13 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + , typename K + , typename L + , typename M + > + struct result { typedef T* type; }; + + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m) const + { + return new T(a, b, c, d, e, f, g, h, i, j, k, l, m); + } +}; + +template +struct new_14 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + , typename K + , typename L + , typename M + , typename N + > + struct result { typedef T* type; }; + + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n) const + { + return new T(a, b, c, d, e, f, g, h, i, j, k, l, m, n); + } + +}; + +template +struct new_15 { + + template < + typename A + , typename B + , typename C + , typename D + , typename E + , typename F + , typename G + , typename H + , typename I + , typename J + , typename K + , typename L + , typename M + , typename N + , typename O + > + struct result { typedef T* type; }; + + + template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N, typename O + > + T* operator()( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n, O const& o) const + { + return new T(a, b, c, d, f, e, g, h, i, j, k, l, m, n, o); + } + +}; +#endif + + +#if defined(__BORLANDC__) || (defined(__MWERKS__) && (__MWERKS__ <= 0x3002)) + +/////////////////////////////////////////////////////////////////////////////// +// +// The following specializations are needed because Borland and CodeWarrior +// does not accept default template arguments in nested template classes in +// classes (i.e new_l::result) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct composite0_result, TupleT> { + + typedef T* type; +}; + +////////////////////////////////// +template +struct composite1_result, TupleT, A> { + + typedef T* type; +}; + +////////////////////////////////// +template +struct composite2_result, TupleT, A, B> { + + typedef T* type; +}; + +////////////////////////////////// +template +struct composite3_result, TupleT, A, B, C> { + + typedef T* type; +}; + +#if PHOENIX_LIMIT > 3 +////////////////////////////////// +template +struct composite4_result, TupleT, + A, B, C, D> { + + typedef T* type; +}; + +////////////////////////////////// +template +struct composite5_result, TupleT, + A, B, C, D, E> { + + typedef T* type; +}; + +////////////////////////////////// +template +struct composite6_result, TupleT, + A, B, C, D, E, F> { + + typedef T* type; +}; + +#if PHOENIX_LIMIT > 6 +////////////////////////////////// +template +struct composite7_result, TupleT, + A, B, C, D, E, F, G> { + + typedef T* type; +}; + +////////////////////////////////// +template +struct composite8_result, TupleT, + A, B, C, D, E, F, G, H> { + + typedef T* type; +}; + +////////////////////////////////// +template +struct composite9_result, TupleT, + A, B, C, D, E, F, G, H, I> { + + typedef T* type; +}; + +#if PHOENIX_LIMIT > 9 +////////////////////////////////// +template +struct composite10_result, TupleT, + A, B, C, D, E, F, G, H, I, J> { + + typedef T* type; +}; + +////////////////////////////////// +template +struct composite11_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K> { + + typedef T* type; +}; + +////////////////////////////////// +template +struct composite12_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L> { + + typedef T* type; +}; + +#if PHOENIX_LIMIT > 12 +////////////////////////////////// +template +struct composite13_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L, M> { + + typedef T* type; +}; + +////////////////////////////////// +template +struct composite14_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L, M, N> { + + typedef T* type; +}; + +////////////////////////////////// +template +struct composite15_result, TupleT, + A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> { + + typedef T* type; +}; + +#endif +#endif +#endif +#endif +#endif + +////////////////////////////////// +template +inline typename impl::make_composite >::type +new_() +{ + typedef impl::make_composite > make_composite_t; + + return make_composite_t::type( + make_composite_t::composite_type(new_l_0())); +} + +////////////////////////////////// +template +inline typename impl::make_composite, A>::type +new_(A const& a) +{ + typedef impl::make_composite, A> make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_1(), + as_actor::convert(a) + )); +} + +////////////////////////////////// +template +inline typename impl::make_composite, A, B>::type +new_(A const& a, B const& b) +{ + typedef impl::make_composite, A, B> make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_2(), + as_actor::convert(a), + as_actor::convert(b) + )); +} + +////////////////////////////////// +template +inline typename impl::make_composite, A, B, C>::type +new_(A const& a, B const& b, C const& c) +{ + typedef impl::make_composite, A, B, C> make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_3(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c) + )); +} + +#if PHOENIX_CONSTRUCT_LIMIT > 3 +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D +> +inline typename impl::make_composite, A, B, C, D>::type +new_( + A const& a, B const& b, C const& c, D const& d) +{ + typedef + impl::make_composite, A, B, C, D> + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_4(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E +> +inline typename impl::make_composite, A, B, C, D, E>::type +new_( + A const& a, B const& b, C const& c, D const& d, E const& e) +{ + typedef + impl::make_composite, A, B, C, D, E> + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_5(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F +> +inline typename impl::make_composite, A, B, C, D, E, F>::type +new_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f) +{ + typedef + impl::make_composite, A, B, C, D, E, F> + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_6(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f) + )); +} + +#if PHOENIX_CONSTRUCT_LIMIT > 6 +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G +> +inline typename impl::make_composite, A, B, C, D, E, F, G>::type +new_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g) +{ + typedef + impl::make_composite, A, B, C, D, E, F, G> + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_7(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H +> +inline typename impl::make_composite, A, B, C, D, E, F, G, H>::type +new_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h) +{ + typedef + impl::make_composite, A, B, C, D, E, F, G, H> + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_8(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I +> +inline typename impl::make_composite, A, B, C, D, E, F, G, H, I>::type +new_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i) +{ + typedef + impl::make_composite, A, B, C, D, E, F, G, H, I> + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_9(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i) + )); +} + +#if PHOENIX_CONSTRUCT_LIMIT > 9 +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J +> +inline typename impl::make_composite< + new_10, A, B, C, D, E, F, G, H, I, J>::type +new_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j) +{ + typedef + impl::make_composite< + new_10, A, B, C, D, E, F, G, H, I, J + > + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_10(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, typename K +> +inline typename impl::make_composite< + new_11, A, B, C, D, E, F, G, H, I, J, K>::type +new_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k) +{ + typedef + impl::make_composite< + new_11, A, B, C, D, E, F, G, H, I, J, K + > + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_11(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, typename K, + typename L +> +inline typename impl::make_composite< + new_12, A, B, C, D, E, F, G, H, I, J, K, L>::type +new_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l) +{ + typedef + impl::make_composite< + new_12, A, B, C, D, E, F, G, H, I, J, K, L + > + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_12(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l) + )); +} + +#if PHOENIX_CONSTRUCT_LIMIT > 12 +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, typename K, + typename L, typename M +> +inline typename impl::make_composite< + new_13, A, B, C, D, E, F, G, H, I, J, K, L, M>::type +new_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m) +{ + typedef + impl::make_composite< + new_13, A, B, C, D, E, F, G, H, I, J, K, L, M + > + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_13(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l), + as_actor::convert(m) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, typename K, + typename L, typename M, typename N +> +inline typename impl::make_composite< + new_14, A, B, C, D, E, F, G, H, I, J, K, L, M>::type +new_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n) +{ + typedef + impl::make_composite< + new_14, A, B, C, D, E, F, G, H, I, J, K, L, M, N + > + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_14(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l), + as_actor::convert(m), + as_actor::convert(n) + )); +} + +////////////////////////////////// +template < + typename T, typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, typename K, + typename L, typename M, typename N, typename O +> +inline typename impl::make_composite< + new_15, A, B, C, D, E, F, G, H, I, J, K, L, M, O>::type +new_( + A const& a, B const& b, C const& c, D const& d, E const& e, + F const& f, G const& g, H const& h, I const& i, J const& j, + K const& k, L const& l, M const& m, N const& n, O const& o) +{ + typedef + impl::make_composite< + new_15, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O + > + make_composite_t; + + return make_composite_t::type(make_composite_t::composite_type(new_15(), + as_actor::convert(a), + as_actor::convert(b), + as_actor::convert(c), + as_actor::convert(d), + as_actor::convert(e), + as_actor::convert(f), + as_actor::convert(g), + as_actor::convert(h), + as_actor::convert(i), + as_actor::convert(j), + as_actor::convert(k), + as_actor::convert(l), + as_actor::convert(m), + as_actor::convert(n), + as_actor::convert(o) + )); +} + +#endif +#endif +#endif +#endif + +/////////////////////////////////////////////////////////////////////////////// +} // namespace phoenix + +#endif // PHOENIX_NEW_HPP diff --git a/boost/boost/spirit/phoenix/operators.hpp b/boost/boost/spirit/phoenix/operators.hpp new file mode 100644 index 0000000000..6d2d03b6a6 --- /dev/null +++ b/boost/boost/spirit/phoenix/operators.hpp @@ -0,0 +1,2214 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2001-2002 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef PHOENIX_OPERATORS_HPP +#define PHOENIX_OPERATORS_HPP + +/////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_NO_CWCTYPE) + #include +#endif + +#if defined(__BORLANDC__) || (defined(__ICL) && __ICL >= 700) +#define CREF const& +#else +#define CREF +#endif + +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix { + +/////////////////////////////////////////////////////////////////////////////// +// +// Operators +// +// Lazy operators +// +// This class provides a mechanism for lazily evaluating operators. +// Syntactically, a lazy operator looks like an ordinary C/C++ +// infix, prefix or postfix operator. The operator application +// looks the same. However, unlike ordinary operators, the actual +// operator execution is deferred. (see actor.hpp, primitives.hpp +// and composite.hpp for an overview). Samples: +// +// arg1 + arg2 +// 1 + arg1 * arg2 +// 1 / -arg1 +// arg1 < 150 +// +// T1 set of classes implement all the C++ free operators. Like +// lazy functions (see functions.hpp), lazy operators are not +// immediately executed when invoked. Instead, a composite (see +// composite.hpp) object is created and returned to the caller. +// Example: +// +// (arg1 + arg2) * arg3 +// +// does nothing more than return a composite. T1 second function +// call will evaluate the actual operators. Example: +// +// int i = 4, j = 5, k = 6; +// cout << ((arg1 + arg2) * arg3)(i, j, k); +// +// will print out "54". +// +// Arbitrarily complex expressions can be lazily evaluated +// following three simple rules: +// +// 1) Lazy evaluated binary operators apply when at least one +// of the operands is an actor object (see actor.hpp and +// primitives.hpp). Consequently, if an operand is not an actor +// object, it is implicitly converted to an object of type +// actor > (where T is the original type of the +// operand). +// +// 2) Lazy evaluated unary operators apply only to operands +// which are actor objects. +// +// 3) The result of a lazy operator is a composite actor object +// that can in turn apply to rule 1. +// +// Example: +// +// arg1 + 3 +// +// is a lazy expression involving the operator+. Following rule 1, +// lazy evaluation is triggered since arg1 is an instance of an +// actor > class (see primitives.hpp). The right +// operand <3> is implicitly converted to an actor >. +// The result of this binary + expression is a composite object, +// following rule 3. +// +// Take note that although at least one of the operands must be a +// valid actor class in order for lazy evaluation to take effect, +// if this is not the case and we still want to lazily evaluate an +// expression, we can use var(x), val(x) or cref(x) to transform +// the operand into a valid action object (see primitives.hpp). +// Example: +// +// val(1) << 3; +// +// Supported operators: +// +// Unary operators: +// +// prefix: ~, !, -, +, ++, --, & (reference), * (dereference) +// postfix: ++, -- +// +// Binary operators: +// +// =, [], +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>= +// +, -, *, /, %, &, |, ^, <<, >> +// ==, !=, <, >, <=, >= +// &&, || +// +// Each operator has a special tag type associated with it. For +// example the binary + operator has a plus_op tag type associated +// with it. This is used to specialize either the unary_operator or +// binary_operator template classes (see unary_operator and +// binary_operator below). Specializations of these unary_operator +// and binary_operator are the actual workhorses that implement the +// operations. The behavior of each lazy operator depends on these +// unary_operator and binary_operator specializations. 'preset' +// specializations conform to the canonical operator rules modeled +// by the behavior of integers and pointers: +// +// Prefix -, + and ~ accept constant arguments and return an +// object by value. +// +// The ! accept constant arguments and returns a boolean +// result. +// +// The & (address-of), * (dereference) both return a reference +// to an object. +// +// Prefix ++ returns a reference to its mutable argument after +// it is incremented. +// +// Postfix ++ returns the mutable argument by value before it +// is incremented. +// +// The += and its family accept mutable right hand side (rhs) +// operand and return a reference to the rhs operand. +// +// Infix + and its family accept constant arguments and return +// an object by value. +// +// The == and its family accept constant arguments and return a +// boolean result. +// +// Operators && and || accept constant arguments and return a +// boolean result and are short circuit evaluated as expected. +// +/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// +// Operator tags +// +// Each C++ operator has a corresponding tag type. This is +// used as a means for specializing the unary_operator and +// binary_operator (see below). The tag also serves as the +// lazy operator type compatible as a composite operation +// see (composite.hpp). +// +/////////////////////////////////////////////////////////////////////////////// + +// Unary operator tags + +struct negative_op; struct positive_op; +struct logical_not_op; struct invert_op; +struct reference_op; struct dereference_op; +struct pre_incr_op; struct pre_decr_op; +struct post_incr_op; struct post_decr_op; + +// Binary operator tags + +struct assign_op; struct index_op; +struct plus_assign_op; struct minus_assign_op; +struct times_assign_op; struct divide_assign_op; struct mod_assign_op; +struct and_assign_op; struct or_assign_op; struct xor_assign_op; +struct shift_l_assign_op; struct shift_r_assign_op; + +struct plus_op; struct minus_op; +struct times_op; struct divide_op; struct mod_op; +struct and_op; struct or_op; struct xor_op; +struct shift_l_op; struct shift_r_op; + +struct eq_op; struct not_eq_op; +struct lt_op; struct lt_eq_op; +struct gt_op; struct gt_eq_op; +struct logical_and_op; struct logical_or_op; + +/////////////////////////////////////////////////////////////////////////////// +// +// unary_operator +// +// The unary_operator class implements most of the C++ unary +// operators. Each specialization is basically a simple static eval +// function plus a result_type typedef that determines the return +// type of the eval function. +// +// TagT is one of the unary operator tags above and T is the data +// type (argument) involved in the operation. +// +// Only the behavior of C/C++ built-in types are taken into account +// in the specializations provided below. For user-defined types, +// these specializations may still be used provided that the +// operator overloads of such types adhere to the standard behavior +// of built-in types. +// +// T1 separate special_ops.hpp file implements more stl savvy +// specializations. Other more specialized unary_operator +// implementations may be defined by the client for specific +// unary operator tags/data types. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct unary_operator; + +////////////////////////////////// +template +struct unary_operator { + + typedef T const result_type; + static result_type eval(T const& v) + { return -v; } +}; + +////////////////////////////////// +template +struct unary_operator { + + typedef T const result_type; + static result_type eval(T const& v) + { return +v; } +}; + +////////////////////////////////// +template +struct unary_operator { + + typedef bool result_type; + static result_type eval(T const& v) + { return !v; } +}; + +////////////////////////////////// +template +struct unary_operator { + + typedef T const result_type; + static result_type eval(T const& v) + { return ~v; } +}; + +////////////////////////////////// +template +struct unary_operator { + + typedef T* result_type; + static result_type eval(T& v) + { return &v; } +}; + +////////////////////////////////// +template +struct unary_operator { + + typedef T& result_type; + static result_type eval(T* v) + { return *v; } +}; + +////////////////////////////////// +template +struct unary_operator { + + typedef T& result_type; + static result_type eval(T* const v) + { return *v; } +}; + +////////////////////////////////// +template <> +struct unary_operator { + + // G++ eager template instantiation + // somehow requires this. + typedef nil_t result_type; +}; + +////////////////////////////////// +#ifndef __BORLANDC__ +template <> +struct unary_operator { + + // G++ eager template instantiation + // somehow requires this. + typedef nil_t result_type; +}; +#endif + +////////////////////////////////// +template +struct unary_operator { + + typedef T& result_type; + static result_type eval(T& v) + { return ++v; } +}; + +////////////////////////////////// +template +struct unary_operator { + + typedef T& result_type; + static result_type eval(T& v) + { return --v; } +}; + +////////////////////////////////// +template +struct unary_operator { + + typedef T const result_type; + static result_type eval(T& v) + { T t(v); ++v; return t; } +}; + +////////////////////////////////// +template +struct unary_operator { + + typedef T const result_type; + static result_type eval(T& v) + { T t(v); --v; return t; } +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// rank +// +// rank class has a static int constant 'value' that defines the +// absolute rank of a type. rank is used to choose the result +// type of binary operators such as +. The type with the higher +// rank wins and is used as the operator's return type. T1 generic +// user defined type has a very high rank and always wins when +// compared against a user defined type. If this is not desireable, +// one can write a rank specialization for the type. +// +// Take note that ranks 0..9999 are reserved for the framework. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct rank { static int const value = INT_MAX; }; + +template <> struct rank { static int const value = 0; }; +template <> struct rank { static int const value = 10; }; + +template <> struct rank { static int const value = 20; }; +template <> struct rank { static int const value = 20; }; +template <> struct rank { static int const value = 30; }; +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) +template <> struct rank { static int const value = 40; }; +#endif // !defined(BOOST_NO_INTRINSIC_WCHAR_T) + +template <> struct rank { static int const value = 50; }; +template <> struct rank { static int const value = 60; }; + +template <> struct rank { static int const value = 70; }; +template <> struct rank { static int const value = 80; }; + +template <> struct rank { static int const value = 90; }; +template <> struct rank { static int const value = 100; }; + +#ifdef BOOST_HAS_LONG_LONG +template <> struct rank< ::boost::long_long_type> { static int const value = 110; }; +template <> struct rank< ::boost::ulong_long_type> { static int const value = 120; }; +#endif + +template <> struct rank { static int const value = 130; }; +template <> struct rank { static int const value = 140; }; +template <> struct rank { static int const value = 150; }; + +template struct rank +{ static int const value = 160; }; + +template struct rank +{ static int const value = 160; }; + +template struct rank +{ static int const value = 160; }; + +/////////////////////////////////////////////////////////////////////////////// +// +// higher_rank +// +// Chooses the type (T0 or T1) with the higher rank. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct higher_rank { + + enum { + + rank1 = rank::value, + rank2 = rank::value, + +#if defined __BORLANDC__ && __BORLANDC__ >= 0x561 + siz = (rank::value < rank::value) ? 1 : 2 +#else + siz = (rank1 < rank2) ? 1 : 2 +#endif + }; + + typedef char compare_rank[siz]; + typedef typename impl::if_t::type type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// binary_operator +// +// The binary_operator class implements most of the C++ binary +// operators. Each specialization is basically a simple static eval +// function plus a result_type typedef that determines the return +// type of the eval function. +// +// TagT is one of the binary operator tags above T0 and T1 are the +// (arguments') data types involved in the operation. +// +// Only the behavior of C/C++ built-in types are taken into account +// in the specializations provided below. For user-defined types, +// these specializations may still be used provided that the +// operator overloads of such types adhere to the standard behavior +// of built-in types. +// +// T1 separate special_ops.hpp file implements more stl savvy +// specializations. Other more specialized unary_operator +// implementations may be defined by the client for specific +// unary operator tags/data types. +// +// All binary_operator except the logical_and_op and logical_or_op +// have an eval static function that carries out the actual operation. +// The logical_and_op and logical_or_op d are special because these +// two operators are short-circuit evaluated. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct binary_operator; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0& lhs, T1 const& rhs) + { return lhs = rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + // G++ eager template instantiation + // somehow requires this. + typedef nil_t result_type; +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0* ptr, T1 const& index) + { return ptr[index]; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0* const ptr, T1 const& index) + { return ptr[index]; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0* ptr, T1 const& index) + { return ptr[index]; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0& lhs, T1 const& rhs) + { return lhs += rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0& lhs, T1 const& rhs) + { return lhs -= rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0& lhs, T1 const& rhs) + { return lhs *= rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0& lhs, T1 const& rhs) + { return lhs /= rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0& lhs, T1 const& rhs) + { return lhs %= rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0& lhs, T1 const& rhs) + { return lhs &= rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0& lhs, T1 const& rhs) + { return lhs |= rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0& lhs, T1 const& rhs) + { return lhs ^= rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0& lhs, T1 const& rhs) + { return lhs <<= rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0& result_type; + static result_type eval(T0& lhs, T1 const& rhs) + { return lhs >>= rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef typename higher_rank::type const result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs + rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef typename higher_rank::type const result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs - rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef typename higher_rank::type const result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs * rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef typename higher_rank::type const result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs / rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef typename higher_rank::type const result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs % rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef typename higher_rank::type const result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs & rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef typename higher_rank::type const result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs | rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef typename higher_rank::type const result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs ^ rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0 const result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs << rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef T0 const result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs >> rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef bool result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs == rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef bool result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs != rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef bool result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs < rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef bool result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs <= rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef bool result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs > rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef bool result_type; + static result_type eval(T0 const& lhs, T1 const& rhs) + { return lhs >= rhs; } +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef bool result_type; + // no eval function, see comment above. +}; + +////////////////////////////////// +template +struct binary_operator { + + typedef bool result_type; + // no eval function, see comment above. +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// negative lazy operator (prefix -) +// +/////////////////////////////////////////////////////////////////////////////// +struct negative_op { + + template + struct result { + + typedef typename unary_operator::result_type type; + }; + + template + typename unary_operator::result_type + operator()(T0& _0) const + { return unary_operator::eval(_0); } +}; + +////////////////////////////////// +template +inline typename impl::make_unary::type +operator-(actor const& _0) +{ + return impl::make_unary::construct(_0); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// positive lazy operator (prefix +) +// +/////////////////////////////////////////////////////////////////////////////// +struct positive_op { + + template + struct result { + + typedef typename unary_operator::result_type type; + }; + + template + typename unary_operator::result_type + operator()(T0& _0) const + { return unary_operator::eval(_0); } +}; + +////////////////////////////////// +template +inline typename impl::make_unary::type +operator+(actor const& _0) +{ + return impl::make_unary::construct(_0); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// logical not lazy operator (prefix !) +// +/////////////////////////////////////////////////////////////////////////////// +struct logical_not_op { + + template + struct result { + + typedef typename unary_operator::result_type type; + }; + + template + typename unary_operator::result_type + operator()(T0& _0) const + { return unary_operator::eval(_0); } +}; + +////////////////////////////////// +template +inline typename impl::make_unary::type +operator!(actor const& _0) +{ + return impl::make_unary::construct(_0); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// invert lazy operator (prefix ~) +// +/////////////////////////////////////////////////////////////////////////////// +struct invert_op { + + template + struct result { + + typedef typename unary_operator::result_type type; + }; + + template + typename unary_operator::result_type + operator()(T0& _0) const + { return unary_operator::eval(_0); } +}; + +////////////////////////////////// +template +inline typename impl::make_unary::type +operator~(actor const& _0) +{ + return impl::make_unary::construct(_0); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// reference lazy operator (prefix &) +// +/////////////////////////////////////////////////////////////////////////////// +struct reference_op { + + template + struct result { + + typedef typename unary_operator::result_type type; + }; + + template + typename unary_operator::result_type + operator()(T0& _0) const + { return unary_operator::eval(_0); } +}; + +////////////////////////////////// +template +inline typename impl::make_unary::type +operator&(actor const& _0) +{ + return impl::make_unary::construct(_0); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// dereference lazy operator (prefix *) +// +/////////////////////////////////////////////////////////////////////////////// +struct dereference_op { + + template + struct result { + + typedef typename unary_operator::result_type type; + }; + + template + typename unary_operator::result_type + operator()(T0& _0) const + { return unary_operator::eval(_0); } +}; + +////////////////////////////////// +template +inline typename impl::make_unary::type +operator*(actor const& _0) +{ + return impl::make_unary::construct(_0); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// pre increment lazy operator (prefix ++) +// +/////////////////////////////////////////////////////////////////////////////// +struct pre_incr_op { + + template + struct result { + + typedef typename unary_operator::result_type type; + }; + + template + typename unary_operator::result_type + operator()(T0& _0) const + { return unary_operator::eval(_0); } +}; + +////////////////////////////////// +template +inline typename impl::make_unary::type +operator++(actor const& _0) +{ + return impl::make_unary::construct(_0); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// pre decrement lazy operator (prefix --) +// +/////////////////////////////////////////////////////////////////////////////// +struct pre_decr_op { + + template + struct result { + + typedef typename unary_operator::result_type type; + }; + + template + typename unary_operator::result_type + operator()(T0& _0) const + { return unary_operator::eval(_0); } +}; + +////////////////////////////////// +template +inline typename impl::make_unary::type +operator--(actor const& _0) +{ + return impl::make_unary::construct(_0); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// post increment lazy operator (postfix ++) +// +/////////////////////////////////////////////////////////////////////////////// +struct post_incr_op { + + template + struct result { + + typedef typename unary_operator::result_type type; + }; + + template + typename unary_operator::result_type + operator()(T0& _0) const + { return unary_operator::eval(_0); } +}; + +////////////////////////////////// +template +inline typename impl::make_unary::type +operator++(actor const& _0, int) +{ + return impl::make_unary::construct(_0); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// post decrement lazy operator (postfix --) +// +/////////////////////////////////////////////////////////////////////////////// +struct post_decr_op { + + template + struct result { + + typedef typename unary_operator::result_type type; + }; + + template + typename unary_operator::result_type + operator()(T0& _0) const + { return unary_operator::eval(_0); } +}; + +////////////////////////////////// +template +inline typename impl::make_unary::type +operator--(actor const& _0, int) +{ + return impl::make_unary::construct(_0); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// assignment lazy operator (infix =) +// The acual lazy operator is a member of the actor class. +// +/////////////////////////////////////////////////////////////////////////////// +struct assign_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +template +inline typename impl::make_binary1::type +actor::operator=(B const& _1) const +{ + return impl::make_binary1::construct(*this, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// index lazy operator (array index []) +// The acual lazy operator is a member of the actor class. +// +/////////////////////////////////////////////////////////////////////////////// +struct index_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +template +inline typename impl::make_binary1::type +actor::operator[](B const& _1) const +{ + return impl::make_binary1::construct(*this, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// plus assign lazy operator (infix +=) +// +/////////////////////////////////////////////////////////////////////////////// +struct plus_assign_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator+=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// minus assign lazy operator (infix -=) +// +/////////////////////////////////////////////////////////////////////////////// +struct minus_assign_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator-=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// times assign lazy operator (infix *=) +// +/////////////////////////////////////////////////////////////////////////////// +struct times_assign_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator*=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// divide assign lazy operator (infix /=) +// +/////////////////////////////////////////////////////////////////////////////// +struct divide_assign_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator/=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// mod assign lazy operator (infix %=) +// +/////////////////////////////////////////////////////////////////////////////// +struct mod_assign_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator%=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// and assign lazy operator (infix &=) +// +/////////////////////////////////////////////////////////////////////////////// +struct and_assign_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator&=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// or assign lazy operator (infix |=) +// +/////////////////////////////////////////////////////////////////////////////// +struct or_assign_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator|=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// xor assign lazy operator (infix ^=) +// +/////////////////////////////////////////////////////////////////////////////// +struct xor_assign_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator^=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// shift left assign lazy operator (infix <<=) +// +/////////////////////////////////////////////////////////////////////////////// +struct shift_l_assign_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator<<=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// shift right assign lazy operator (infix >>=) +// +/////////////////////////////////////////////////////////////////////////////// +struct shift_r_assign_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator>>=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// plus lazy operator (infix +) +// +/////////////////////////////////////////////////////////////////////////////// +struct plus_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator+(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator+(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator+(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// minus lazy operator (infix -) +// +/////////////////////////////////////////////////////////////////////////////// +struct minus_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator-(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator-(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator-(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// times lazy operator (infix *) +// +/////////////////////////////////////////////////////////////////////////////// +struct times_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator*(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator*(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator*(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// divide lazy operator (infix /) +// +/////////////////////////////////////////////////////////////////////////////// +struct divide_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator/(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator/(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator/(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// mod lazy operator (infix %) +// +/////////////////////////////////////////////////////////////////////////////// +struct mod_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator%(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator%(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator%(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// and lazy operator (infix &) +// +/////////////////////////////////////////////////////////////////////////////// +struct and_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator&(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator&(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator&(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// or lazy operator (infix |) +// +/////////////////////////////////////////////////////////////////////////////// +struct or_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator|(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator|(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator|(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// xor lazy operator (infix ^) +// +/////////////////////////////////////////////////////////////////////////////// +struct xor_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator^(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator^(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator^(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// shift left lazy operator (infix <<) +// +/////////////////////////////////////////////////////////////////////////////// +struct shift_l_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator<<(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator<<(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator<<(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// shift right lazy operator (infix >>) +// +/////////////////////////////////////////////////////////////////////////////// +struct shift_r_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator>>(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator>>(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator>>(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// equal lazy operator (infix ==) +// +/////////////////////////////////////////////////////////////////////////////// +struct eq_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator==(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator==(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator==(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// not equal lazy operator (infix !=) +// +/////////////////////////////////////////////////////////////////////////////// +struct not_eq_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator!=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator!=(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator!=(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// less than lazy operator (infix <) +// +/////////////////////////////////////////////////////////////////////////////// +struct lt_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator<(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator<(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator<(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// less than equal lazy operator (infix <=) +// +/////////////////////////////////////////////////////////////////////////////// +struct lt_eq_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator<=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator<=(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator<=(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// greater than lazy operator (infix >) +// +/////////////////////////////////////////////////////////////////////////////// +struct gt_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator>(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator>(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator>(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// greater than equal lazy operator (infix >=) +// +/////////////////////////////////////////////////////////////////////////////// +struct gt_eq_op { + + template + struct result { + + typedef typename binary_operator + ::result_type type; + }; + + template + typename binary_operator::result_type + operator()(T0& _0, T1& _1) const + { return binary_operator::eval(_0, _1); } +}; + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator>=(actor const& _0, T1 CREF _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary2::type +operator>=(T0 CREF _0, actor const& _1) +{ + return impl::make_binary2::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary3::type +operator>=(actor const& _0, actor const& _1) +{ + return impl::make_binary3::construct(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// logical and lazy operator (infix &&) +// +// The logical_and_composite class and its corresponding generators are +// provided to allow short-circuit evaluation of the operator's +// operands. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct logical_and_composite { + + typedef logical_and_composite self_t; + + template + struct result { + + typedef typename binary_operator::plain_type, + typename actor_result::plain_type + >::result_type type; + }; + + logical_and_composite(A0 const& _0, A1 const& _1) + : a0(_0), a1(_1) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + return a0.eval(args) && a1.eval(args); + } + + A0 a0; A1 a1; // actors +}; + +#if !(defined(__ICL) && __ICL <= 500) +////////////////////////////////// +template +inline actor, typename as_actor::type> > +operator&&(actor const& _0, T1 CREF _1) +{ + return logical_and_composite + , typename as_actor::type> + (_0, as_actor::convert(_1)); +} + +////////////////////////////////// +template +inline actor::type, actor > > +operator&&(T0 CREF _0, actor const& _1) +{ + return logical_and_composite + ::type, actor > + (as_actor::convert(_0), _1); +} + +////////////////////////////////// +template +inline actor, actor > > +operator&&(actor const& _0, actor const& _1) +{ + return logical_and_composite + , actor > + (_0, _1); +} +#else +////////////////////////////////// +template +inline actor::type, typename as_actor::type> > +operator&&(T0 CREF _0, T1 CREF _1) +{ + return logical_and_composite + ::type, typename as_actor::type> + (as_actor::convert(_0), as_actor::convert(_1)); +} +#endif // !(__ICL && __ICL <= 500) + +/////////////////////////////////////////////////////////////////////////////// +// +// logical or lazy operator (infix ||) +// +// The logical_or_composite class and its corresponding generators are +// provided to allow short-circuit evaluation of the operator's +// operands. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct logical_or_composite { + + typedef logical_or_composite self_t; + + template + struct result { + + typedef typename binary_operator::plain_type, + typename actor_result::plain_type + >::result_type type; + }; + + logical_or_composite(A0 const& _0, A1 const& _1) + : a0(_0), a1(_1) {} + + template + typename actor_result::type + eval(TupleT const& args) const + { + return a0.eval(args) || a1.eval(args); + } + + A0 a0; A1 a1; // actors +}; + +////////////////////////////////// +template +inline actor, typename as_actor::type> > +operator||(actor const& _0, T1 CREF _1) +{ + return logical_or_composite + , typename as_actor::type> + (_0, as_actor::convert(_1)); +} + +////////////////////////////////// +template +inline actor::type, actor > > +operator||(T0 CREF _0, actor const& _1) +{ + return logical_or_composite + ::type, actor > + (as_actor::convert(_0), _1); +} + +////////////////////////////////// +template +inline actor, actor > > +operator||(actor const& _0, actor const& _1) +{ + return logical_or_composite + , actor > + (_0, _1); +} + +} // namespace phoenix + +#undef CREF +#endif diff --git a/boost/boost/spirit/phoenix/primitives.hpp b/boost/boost/spirit/phoenix/primitives.hpp new file mode 100644 index 0000000000..16d5925ea7 --- /dev/null +++ b/boost/boost/spirit/phoenix/primitives.hpp @@ -0,0 +1,248 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2001-2002 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef PHOENIX_PRIMITIVES_HPP +#define PHOENIX_PRIMITIVES_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix { + +/////////////////////////////////////////////////////////////////////////////// +// +// argument class +// +// Lazy arguments +// +// An actor base class that extracts and returns the Nth argument +// from the argument list passed in the 'args' tuple in the eval +// member function (see actor.hpp). There are some predefined +// argument constants that can be used as actors (arg1..argN). +// +// The argument actor is a place-holder for the actual arguments +// passed by the client. For example, wherever arg1 is seen placed +// in a lazy function (see functions.hpp) or lazy operator (see +// operators.hpp), this will be replaced by the actual first +// argument in the actual function evaluation. Argument actors are +// essentially lazy arguments. A lazy argument is a full actor in +// its own right and can be evaluated through the actor's operator(). +// +// Example: +// +// char c = 'A'; +// int i = 123; +// const char* s = "Hello World"; +// +// cout << arg1(c) << ' '; +// cout << arg1(i, s) << ' '; +// cout << arg2(i, s) << ' '; +// +// will print out "A 123 Hello World" +// +/////////////////////////////////////////////////////////////////////////////// +template +struct argument { + + template + struct result { typedef typename tuple_element::type type; }; + + template + typename tuple_element::type + eval(TupleT const& args) const + { + return args[tuple_index()]; + } +}; + +////////////////////////////////// +actor > const arg1 = argument<0>(); +actor > const arg2 = argument<1>(); +actor > const arg3 = argument<2>(); + +#if PHOENIX_LIMIT > 3 +actor > const arg4 = argument<3>(); +actor > const arg5 = argument<4>(); +actor > const arg6 = argument<5>(); + +#if PHOENIX_LIMIT > 6 +actor > const arg7 = argument<6>(); +actor > const arg8 = argument<7>(); +actor > const arg9 = argument<8>(); + +#if PHOENIX_LIMIT > 9 +actor > const arg10 = argument<9>(); +actor > const arg11 = argument<10>(); +actor > const arg12 = argument<11>(); + +#if PHOENIX_LIMIT > 12 +actor > const arg13 = argument<12>(); +actor > const arg14 = argument<13>(); +actor > const arg15 = argument<14>(); + +#endif +#endif +#endif +#endif +/////////////////////////////////////////////////////////////////////////////// +// +// value class +// +// Lazy values +// +// A bound actual parameter is kept in a value class for deferred +// access later when needed. A value object is immutable. Value +// objects are typically created through the val(x) free function +// which returns a value with T deduced from the type of x. x is +// held in the value object by value. +// +// Lazy values are actors. As such, lazy values can be evaluated +// through the actor's operator(). Such invocation gives the value's +// identity. Example: +// +// cout << val(3)() << val("Hello World")(); +// +// prints out "3 Hello World" +// +/////////////////////////////////////////////////////////////////////////////// +template +struct value { + + typedef typename boost::remove_reference::type plain_t; + + template + struct result { typedef plain_t const type; }; + + value(plain_t val_) + : val(val_) {} + + template + plain_t const + eval(TupleT const& /*args*/) const + { + return val; + } + + plain_t val; +}; + +////////////////////////////////// +template +inline actor > const +val(T v) +{ + return value(v); +} + +////////////////////////////////// +template +void +val(actor const& v); // This is undefined and not allowed. + +/////////////////////////////////////////////////////////////////////////// +// +// Arbitrary types T are typically converted to a actor > +// (see as_actor in actor.hpp). A specialization is also provided +// for arrays. T[N] arrays are converted to actor >. +// +/////////////////////////////////////////////////////////////////////////// +template +struct as_actor { + + typedef actor > type; + static type convert(T const& x) + { return value(x); } +}; + +////////////////////////////////// +template +struct as_actor { + + typedef actor > type; + static type convert(T const x[N]) + { return value(x); } +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// variable class +// +// Lazy variables +// +// A bound actual parameter may also be held by non-const reference +// in a variable class for deferred access later when needed. A +// variable object is mutable, i.e. its referenced variable can be +// modified. Variable objects are typically created through the +// var(x) free function which returns a variable with T deduced +// from the type of x. x is held in the value object by +// reference. +// +// Lazy variables are actors. As such, lazy variables can be +// evaluated through the actor's operator(). Such invocation gives +// the variables's identity. Example: +// +// int i = 3; +// char const* s = "Hello World"; +// cout << var(i)() << var(s)(); +// +// prints out "3 Hello World" +// +// Another free function const_(x) may also be used. const_(x) creates +// a variable object using a constant reference. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct variable { + + template + struct result { typedef T& type; }; + + variable(T& var_) + : var(var_) {} + + template + T& + eval(TupleT const& /*args*/) const + { + return var; + } + + T& var; +}; + +////////////////////////////////// +template +inline actor > const +var(T& v) +{ + return variable(v); +} + +////////////////////////////////// +template +inline actor > const +const_(T const& v) +{ + return variable(v); +} + +////////////////////////////////// +template +void +var(actor const& v); // This is undefined and not allowed. + +////////////////////////////////// +template +void +const_(actor const& v); // This is undefined and not allowed. + +/////////////////////////////////////////////////////////////////////////////// +} // namespace phoenix + +#endif diff --git a/boost/boost/spirit/phoenix/special_ops.hpp b/boost/boost/spirit/phoenix/special_ops.hpp new file mode 100644 index 0000000000..47cd9470b7 --- /dev/null +++ b/boost/boost/spirit/phoenix/special_ops.hpp @@ -0,0 +1,342 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2001-2002 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef PHOENIX_SPECIAL_OPS_HPP +#define PHOENIX_SPECIAL_OPS_HPP + +#include +#ifdef BOOST_NO_STRINGSTREAM +#include +#define PHOENIX_SSTREAM strstream +#else +#include +#define PHOENIX_SSTREAM stringstream +#endif + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +#if defined(_STLPORT_VERSION) && defined(__STL_USE_OWN_NAMESPACE) +#define PHOENIX_STD _STLP_STD +#define PHOENIX_NO_STD_NAMESPACE +#else +#define PHOENIX_STD std +#endif + +/////////////////////////////////////////////////////////////////////////////// +//#if !defined(PHOENIX_NO_STD_NAMESPACE) +namespace PHOENIX_STD +{ +//#endif + + template class complex; + +//#if !defined(PHOENIX_NO_STD_NAMESPACE) +} +//#endif + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix +{ + +/////////////////////////////////////////////////////////////////////////////// +// +// The following specializations take into account the C++ standard +// library components. There are a couple of issues that have to be +// dealt with to enable lazy operator overloads for the standard +// library classes. +// +// *iostream (e.g. cout, cin, strstream/ stringstream) uses non- +// canonical shift operator overloads where the lhs is taken in +// by reference. +// +// *I/O manipulators overloads for the RHS of the << and >> +// operators. +// +// *STL iterators can be objects that conform to pointer semantics. +// Some operators need to be specialized for these. +// +// *std::complex is given a rank (see rank class in operators.hpp) +// +/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// +// specialization for rank +// +/////////////////////////////////////////////////////////////////////////////// +template struct rank > +{ static int const value = 170 + rank::value; }; + +/////////////////////////////////////////////////////////////////////////////// +// +// specializations for std::istream +// +/////////////////////////////////////////////////////////////////////////////// +#if defined(__GNUC__) && (__GNUC__ < 3) + #if defined(_STLPORT_VERSION) + #define PHOENIX_ISTREAM _IO_istream_withassign + #else + #define PHOENIX_ISTREAM PHOENIX_STD::_IO_istream_withassign + #endif +#else +// #if (defined(__ICL) && defined(_STLPORT_VERSION)) +// #define PHOENIX_ISTREAM istream_withassign +// #else + #define PHOENIX_ISTREAM PHOENIX_STD::istream +// #endif +#endif + +////////////////////////////////// +#if defined(__GNUC__) && (__GNUC__ < 3) +// || (defined(__ICL) && defined(_STLPORT_VERSION)) +template +struct binary_operator +{ + typedef PHOENIX_STD::istream& result_type; + static result_type eval(PHOENIX_STD::istream& out, T1& rhs) + { return out >> rhs; } +}; +#endif + +////////////////////////////////// +template +struct binary_operator +{ + typedef PHOENIX_STD::istream& result_type; + static result_type eval(PHOENIX_STD::istream& out, T1& rhs) + { return out >> rhs; } +}; + +////////////////////////////////// +template +inline typename impl::make_binary3 + , BaseT>::type +operator>>(PHOENIX_ISTREAM& _0, actor const& _1) +{ + return impl::make_binary3 + , BaseT> + ::construct(var(_0), _1); +} + +#undef PHOENIX_ISTREAM +/////////////////////////////////////////////////////////////////////////////// +// +// specializations for std::ostream +// +/////////////////////////////////////////////////////////////////////////////// +#if defined(__GNUC__) && (__GNUC__ < 3) + #if defined(_STLPORT_VERSION) + #define PHOENIX_OSTREAM _IO_ostream_withassign + #else + #define PHOENIX_OSTREAM PHOENIX_STD::_IO_ostream_withassign + #endif +#else +// #if (defined(__ICL) && defined(_STLPORT_VERSION)) +// #define PHOENIX_OSTREAM ostream_withassign +// #else + #define PHOENIX_OSTREAM PHOENIX_STD::ostream +// #endif +#endif + +////////////////////////////////// +#if defined(__GNUC__) && (__GNUC__ < 3) +// || (defined(__ICL) && defined(_STLPORT_VERSION)) +template +struct binary_operator +{ + typedef PHOENIX_STD::ostream& result_type; + static result_type eval(PHOENIX_STD::ostream& out, T1 const& rhs) + { return out << rhs; } +}; +#endif + +////////////////////////////////// +template +struct binary_operator +{ + typedef PHOENIX_STD::ostream& result_type; + static result_type eval(PHOENIX_STD::ostream& out, T1 const& rhs) + { return out << rhs; } +}; + +////////////////////////////////// +template +inline typename impl::make_binary3 + , BaseT>::type +operator<<(PHOENIX_OSTREAM& _0, actor const& _1) +{ + return impl::make_binary3 + , BaseT> + ::construct(var(_0), _1); +} + +#undef PHOENIX_OSTREAM + +/////////////////////////////////////////////////////////////////////////////// +// +// specializations for std::strstream / stringstream +// +/////////////////////////////////////////////////////////////////////////////// +template +struct binary_operator +{ + typedef PHOENIX_STD::istream& result_type; + static result_type eval(PHOENIX_STD::istream& out, T1& rhs) + { return out >> rhs; } +}; + +////////////////////////////////// +template +inline typename impl::make_binary3 + , BaseT>::type +operator>>(PHOENIX_STD::PHOENIX_SSTREAM& _0, actor const& _1) +{ + return impl::make_binary3 + , BaseT> + ::construct(var(_0), _1); +} + +////////////////////////////////// +template +struct binary_operator +{ + typedef PHOENIX_STD::ostream& result_type; + static result_type eval(PHOENIX_STD::ostream& out, T1 const& rhs) + { return out << rhs; } +}; + +////////////////////////////////// +template +inline typename impl::make_binary3 + , BaseT>::type +operator<<(PHOENIX_STD::PHOENIX_SSTREAM& _0, actor const& _1) +{ + return impl::make_binary3 + , BaseT> + ::construct(var(_0), _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// I/O manipulator specializations +// +/////////////////////////////////////////////////////////////////////////////// +#if (!defined(__GNUC__) || (__GNUC__ > 2)) +// && !(defined(__ICL) && defined(_STLPORT_VERSION)) + +typedef PHOENIX_STD::ios_base& (*iomanip_t)(PHOENIX_STD::ios_base&); +typedef PHOENIX_STD::istream& (*imanip_t)(PHOENIX_STD::istream&); +typedef PHOENIX_STD::ostream& (*omanip_t)(PHOENIX_STD::ostream&); + +#if defined(__BORLANDC__) + +/////////////////////////////////////////////////////////////////////////////// +// +// Borland does not like i/o manipulators functions such as endl to +// be the rhs of a lazy << operator (Borland incorrectly reports +// ambiguity). To get around the problem, we provide function +// pointer versions of the same name with a single trailing +// underscore. +// +// You can use the same trick for other i/o manipulators. +// Alternatively, you can prefix the manipulator with a '&' +// operator. Example: +// +// cout << arg1 << &endl +// +/////////////////////////////////////////////////////////////////////////////// + +imanip_t ws_ = &PHOENIX_STD::ws; +iomanip_t dec_ = &PHOENIX_STD::dec; +iomanip_t hex_ = &PHOENIX_STD::hex; +iomanip_t oct_ = &PHOENIX_STD::oct; +omanip_t endl_ = &PHOENIX_STD::endl; +omanip_t ends_ = &PHOENIX_STD::ends; +omanip_t flush_ = &PHOENIX_STD::flush; + +#else // __BORLANDC__ + +/////////////////////////////////////////////////////////////////////////////// +// +// The following are overloads for I/O manipulators. +// +/////////////////////////////////////////////////////////////////////////////// +template +inline typename impl::make_binary1::type +operator>>(actor const& _0, imanip_t _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator>>(actor const& _0, iomanip_t _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator<<(actor const& _0, omanip_t _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +////////////////////////////////// +template +inline typename impl::make_binary1::type +operator<<(actor const& _0, iomanip_t _1) +{ + return impl::make_binary1::construct(_0, _1); +} + +#endif // __BORLANDC__ +#endif // !defined(__GNUC__) || (__GNUC__ > 2) + +/////////////////////////////////////////////////////////////////////////////// +// +// specializations for stl iterators and containers +// +/////////////////////////////////////////////////////////////////////////////// +template +struct unary_operator +{ + typedef typename T::reference result_type; + static result_type eval(T const& iter) + { return *iter; } +}; + +////////////////////////////////// +template +struct binary_operator +{ + typedef typename T0::reference result_type; + static result_type eval(T0& container, T1 const& index) + { return container[index]; } +}; + +////////////////////////////////// +template +struct binary_operator +{ + typedef typename T0::const_reference result_type; + static result_type eval(T0 const& container, T1 const& index) + { return container[index]; } +}; + +/////////////////////////////////////////////////////////////////////////////// +} // namespace phoenix + +#undef PHOENIX_SSTREAM +#undef PHOENIX_STD +#endif diff --git a/boost/boost/spirit/phoenix/statements.hpp b/boost/boost/spirit/phoenix/statements.hpp new file mode 100644 index 0000000000..d20d199818 --- /dev/null +++ b/boost/boost/spirit/phoenix/statements.hpp @@ -0,0 +1,444 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2001-2002 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef PHOENIX_STATEMENTS_HPP +#define PHOENIX_STATEMENTS_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix { + +/////////////////////////////////////////////////////////////////////////////// +// +// sequential_composite +// +// Two or more actors separated by the comma generates a +// sequential_composite which is a composite actor. Example: +// +// actor, +// actor, +// actor +// +// The actors are evaluated sequentially. The result type of this +// is void. Note that the last actor should not have a trailing +// comma. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct sequential_composite { + + typedef sequential_composite self_t; + + template + struct result { typedef void type; }; + + sequential_composite(A0 const& _0, A1 const& _1) + : a0(_0), a1(_1) {} + + template + void + eval(TupleT const& args) const + { + a0.eval(args); + a1.eval(args); + } + + A0 a0; A1 a1; // actors +}; + +////////////////////////////////// +template +inline actor, actor > > +operator,(actor const& _0, actor const& _1) +{ + return sequential_composite, actor >(_0, _1); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// if_then_else_composite +// +// This composite has two (2) forms: +// +// if_(condition) +// [ +// statement +// ] +// +// and +// +// if_(condition) +// [ +// true_statement +// ] +// .else_ +// [ +// false_statement +// ] +// +// where condition is an actor that evaluates to bool. If condition +// is true, the true_statement (again an actor) is executed +// otherwise, the false_statement (another actor) is executed. The +// result type of this is void. Note the trailing underscore after +// if_ and the the leading dot and the trailing underscore before +// and after .else_. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct if_then_else_composite { + + typedef if_then_else_composite self_t; + + template + struct result { + + typedef void type; + }; + + if_then_else_composite( + CondT const& cond_, + ThenT const& then_, + ElseT const& else__) + : cond(cond_), then(then_), else_(else__) {} + + template + void eval(TupleT const& args) const + { + if (cond.eval(args)) + then.eval(args); + else + else_.eval(args); + } + + CondT cond; ThenT then; ElseT else_; // actors +}; + +////////////////////////////////// +template +struct else_gen { + + else_gen(CondT const& cond_, ThenT const& then_) + : cond(cond_), then(then_) {} + + template + actor::type> > + operator[](ElseT const& else_) + { + typedef if_then_else_composite::type> + result; + + return result(cond, then, as_actor::convert(else_)); + } + + CondT cond; ThenT then; +}; + +////////////////////////////////// +template +struct if_then_composite { + + typedef if_then_composite self_t; + + template + struct result { typedef void type; }; + + if_then_composite(CondT const& cond_, ThenT const& then_) + : cond(cond_), then(then_), else_(cond, then) {} + + template + void eval(TupleT const& args) const + { + if (cond.eval(args)) + then.eval(args); + } + + CondT cond; ThenT then; // actors + else_gen else_; +}; + +////////////////////////////////// +template +struct if_gen { + + if_gen(CondT const& cond_) + : cond(cond_) {} + + template + actor::type, + typename as_actor::type> > + operator[](ThenT const& then) const + { + typedef if_then_composite< + typename as_actor::type, + typename as_actor::type> + result; + + return result( + as_actor::convert(cond), + as_actor::convert(then)); + } + + CondT cond; +}; + +////////////////////////////////// +template +inline if_gen +if_(CondT const& cond) +{ + return if_gen(cond); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// while_composite +// +// This composite has the form: +// +// while_(condition) +// [ +// statement +// ] +// +// While the condition (an actor) evaluates to true, statement +// (another actor) is executed. The result type of this is void. +// Note the trailing underscore after while_. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct while_composite { + + typedef while_composite self_t; + + template + struct result { typedef void type; }; + + while_composite(CondT const& cond_, DoT const& do__) + : cond(cond_), do_(do__) {} + + template + void eval(TupleT const& args) const + { + while (cond.eval(args)) + do_.eval(args); + } + + CondT cond; + DoT do_; +}; + +////////////////////////////////// +template +struct while_gen { + + while_gen(CondT const& cond_) + : cond(cond_) {} + + template + actor::type, + typename as_actor::type> > + operator[](DoT const& do_) const + { + typedef while_composite< + typename as_actor::type, + typename as_actor::type> + result; + + return result( + as_actor::convert(cond), + as_actor::convert(do_)); + } + + CondT cond; +}; + +////////////////////////////////// +template +inline while_gen +while_(CondT const& cond) +{ + return while_gen(cond); +} + +/////////////////////////////////////////////////////////////////////////////// +// +// do_composite +// +// This composite has the form: +// +// do_ +// [ +// statement +// ] +// .while_(condition) +// +// While the condition (an actor) evaluates to true, statement +// (another actor) is executed. The statement is executed at least +// once. The result type of this is void. Note the trailing +// underscore after do_ and the the leading dot and the trailing +// underscore before and after .while_. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct do_composite { + + typedef do_composite self_t; + + template + struct result { typedef void type; }; + + do_composite(DoT const& do__, CondT const& cond_) + : do_(do__), cond(cond_) {} + + template + void eval(TupleT const& args) const + { + do + do_.eval(args); + while (cond.eval(args)); + } + + DoT do_; + CondT cond; +}; + +//////////////////////////////////// +template +struct do_gen2 { + + do_gen2(DoT const& do__) + : do_(do__) {} + + template + actor::type, + typename as_actor::type> > + while_(CondT const& cond) const + { + typedef do_composite< + typename as_actor::type, + typename as_actor::type> + result; + + return result( + as_actor::convert(do_), + as_actor::convert(cond)); + } + + DoT do_; +}; + +//////////////////////////////////// +struct do_gen { + + template + do_gen2 + operator[](DoT const& do_) const + { + return do_gen2(do_); + } +}; + +do_gen const do_ = do_gen(); + +/////////////////////////////////////////////////////////////////////////////// +// +// for_composite +// +// This statement has the form: +// +// for_(init, condition, step) +// [ +// statement +// ] +// +// Where init, condition, step and statement are all actors. init +// is executed once before entering the for-loop. The for-loop +// exits once condition evaluates to false. At each loop iteration, +// step and statement is called. The result of this statement is +// void. Note the trailing underscore after for_. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct for_composite { + + typedef composite self_t; + + template + struct result { typedef void type; }; + + for_composite( + InitT const& init_, + CondT const& cond_, + StepT const& step_, + DoT const& do__) + : init(init_), cond(cond_), step(step_), do_(do__) {} + + template + void + eval(TupleT const& args) const + { + for (init.eval(args); cond.eval(args); step.eval(args)) + do_.eval(args); + } + + InitT init; CondT cond; StepT step; DoT do_; // actors +}; + +////////////////////////////////// +template +struct for_gen { + + for_gen( + InitT const& init_, + CondT const& cond_, + StepT const& step_) + : init(init_), cond(cond_), step(step_) {} + + template + actor::type, + typename as_actor::type, + typename as_actor::type, + typename as_actor::type> > + operator[](DoT const& do_) const + { + typedef for_composite< + typename as_actor::type, + typename as_actor::type, + typename as_actor::type, + typename as_actor::type> + result; + + return result( + as_actor::convert(init), + as_actor::convert(cond), + as_actor::convert(step), + as_actor::convert(do_)); + } + + InitT init; CondT cond; StepT step; +}; + +////////////////////////////////// +template +inline for_gen +for_(InitT const& init, CondT const& cond, StepT const& step) +{ + return for_gen(init, cond, step); +} + +} // namespace phoenix + +#endif diff --git a/boost/boost/spirit/phoenix/tuple_helpers.hpp b/boost/boost/spirit/phoenix/tuple_helpers.hpp new file mode 100644 index 0000000000..f8875e0c79 --- /dev/null +++ b/boost/boost/spirit/phoenix/tuple_helpers.hpp @@ -0,0 +1,1076 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2002 Joel de Guzman + Copyright (c) 2002-2003 Hartmut Kaiser + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef PHOENIX_TUPLEHELPERS_HPP +#define PHOENIX_TUPLEHELPERS_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix +{ + +/////////////////////////////////////////////////////////////////////////////// +// +// make_tuple template class +// +// This template class is used to calculate a tuple type required to hold +// the given template parameter type +// +/////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +// normal (non-tuple types are wrapped into a tuple) +template +struct make_tuple { + + typedef tuple type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// nil_t is converted to an empty tuple type +template <> +struct make_tuple { + + typedef tuple<> type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// tuple types are left alone without any refactoring +template < + typename A, typename B, typename C +#if PHOENIX_LIMIT > 3 + , typename D, typename E, typename F +#if PHOENIX_LIMIT > 6 + , typename G, typename H, typename I +#if PHOENIX_LIMIT > 9 + , typename J, typename K, typename L +#if PHOENIX_LIMIT > 12 + , typename M, typename N, typename O +#endif +#endif +#endif +#endif +> +struct make_tuple 3 + , D, E, F +#if PHOENIX_LIMIT > 6 + , G, H, I +#if PHOENIX_LIMIT > 9 + , J, K, L +#if PHOENIX_LIMIT > 12 + , M, N, O +#endif +#endif +#endif +#endif + > > { + +// the tuple parameter itself is the required tuple type + typedef tuple 3 + , D, E, F +#if PHOENIX_LIMIT > 6 + , G, H, I +#if PHOENIX_LIMIT > 9 + , J, K, L +#if PHOENIX_LIMIT > 12 + , M, N, O +#endif +#endif +#endif +#endif + > type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat_tuple type computer +// +// This class returns the type of a tuple, which is constructed by +// concatenating a tuple with a given type +// +/////////////////////////////////////////////////////////////////////////////// +template +struct concat_tuple; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <0 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template <> +struct concat_tuple, nil_t> { + + typedef tuple<> type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <1 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <2 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +#if PHOENIX_LIMIT > 3 +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <3 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <4 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C, typename D +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <5 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C, typename D, typename E +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +#if PHOENIX_LIMIT > 6 +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <6 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C, typename D, typename E, typename F +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <7 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <8 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +#if PHOENIX_LIMIT > 9 +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <9 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <10 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I, typename J, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I, typename J +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <11 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I, typename J, typename K, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I, typename J, typename K +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +#if PHOENIX_LIMIT > 12 +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <12 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I, typename J, typename K, typename L, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I, typename J, typename K, typename L +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <13 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I, typename J, typename K, typename L, + typename M, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I, typename J, typename K, typename L, + typename M +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// concat tuple <14 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I, typename J, typename K, typename L, + typename M, typename N, + typename AppendT +> +struct concat_tuple, AppendT> { + + typedef tuple type; +}; + +template < + typename A, typename B, typename C, typename D, typename E, typename F, + typename G, typename H, typename I, typename J, typename K, typename L, + typename M, typename N +> +struct concat_tuple, nil_t> { + + typedef tuple type; +}; + +#endif +#endif +#endif +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// concat_tuples type computer +// +// This template class returns the type of a tuple built from the +// concatenation of two given tuples. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct concat_tuple_element { + + typedef + typename concat_tuple_element< + typename concat_tuple::type, TupleT2, N+1, + typename tuple_element::type + >::type + type; +}; + +template +struct concat_tuple_element { + + typedef TupleT1 type; +}; + +template +struct concat_tuples { + + typedef + typename concat_tuple_element< + TupleT1, TupleT2, 0, + typename tuple_element<0, TupleT2>::type + >::type + type; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// convert_actors template function +// +// The convert_actors template functions constructs a new tuple object +// composed of the elements returned by the actors contained in the +// input tuple. (i.e. the given tuple type 'actor_tuple' contains a set +// of actors to evaluate and the resulting tuple contains the results of +// evaluating the actors.) +// +/////////////////////////////////////////////////////////////////////////////// +template +struct actor_result; // forward declaration + +namespace impl +{ + template + struct convert_actors_ {}; +} + +template +TupleResultT +convert_actors(ActorTupleT const& actor_tuple) +{ + BOOST_STATIC_ASSERT(ActorTupleT::length <= TupleResultT::length); + BOOST_STATIC_CONSTANT(int, length = TupleResultT::length); + return impl::convert_actors_ + ::template apply::do_(actor_tuple); +} + +namespace impl +{ + template + struct convert_actor + { + typedef typename tuple_element::type type; + + template + struct is_default_t {}; + typedef is_default_t is_default; + typedef is_default_t is_not_default; + + static type + actor_element(ActorTupleT const& /*actor_tuple*/, is_default) + { + return type(); // default construct + } + + static type + actor_element(ActorTupleT const& actor_tuple, is_not_default) + { + BOOST_STATIC_ASSERT(ActorTupleT::length <= TupleResultT::length); + return actor_tuple[tuple_index()](); // apply the actor + } + + static type + do_(ActorTupleT const& actor_tuple) + { + return actor_element( + actor_tuple, is_default_t<(N >= ActorTupleT::length)>()); + } + }; + + /////////////////////////////////////// + template <> + struct convert_actors_<1> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + + return TupleResultT( + converter0::do_(actor_tuple) + ); + } + }; + }; + + /////////////////////////////////////// + template <> + struct convert_actors_<2> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + ); + } + }; + }; + + /////////////////////////////////////// + template <> + struct convert_actors_<3> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + ); + } + }; + }; + + #if PHOENIX_LIMIT > 3 + + ///////////////////////////////////// + template <> + struct convert_actors_<4> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + ); + } + }; + }; + + ///////////////////////////////////// + template <> + struct convert_actors_<5> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + typedef impl::convert_actor<4, TupleResultT, ActorTupleT> converter4; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + , converter4::do_(actor_tuple) + ); + } + }; + }; + + ///////////////////////////////////// + template <> + struct convert_actors_<6> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + typedef impl::convert_actor<4, TupleResultT, ActorTupleT> converter4; + typedef impl::convert_actor<5, TupleResultT, ActorTupleT> converter5; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + , converter4::do_(actor_tuple) + , converter5::do_(actor_tuple) + ); + } + }; + }; + + #if PHOENIX_LIMIT > 6 + + ///////////////////////////////////// + template <> + struct convert_actors_<7> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + typedef impl::convert_actor<4, TupleResultT, ActorTupleT> converter4; + typedef impl::convert_actor<5, TupleResultT, ActorTupleT> converter5; + typedef impl::convert_actor<6, TupleResultT, ActorTupleT> converter6; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + , converter4::do_(actor_tuple) + , converter5::do_(actor_tuple) + , converter6::do_(actor_tuple) + ); + } + }; + }; + + ///////////////////////////////////// + template <> + struct convert_actors_<8> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + typedef impl::convert_actor<4, TupleResultT, ActorTupleT> converter4; + typedef impl::convert_actor<5, TupleResultT, ActorTupleT> converter5; + typedef impl::convert_actor<6, TupleResultT, ActorTupleT> converter6; + typedef impl::convert_actor<7, TupleResultT, ActorTupleT> converter7; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + , converter4::do_(actor_tuple) + , converter5::do_(actor_tuple) + , converter6::do_(actor_tuple) + , converter7::do_(actor_tuple) + ); + } + }; + }; + + ///////////////////////////////////// + template <> + struct convert_actors_<9> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + typedef impl::convert_actor<4, TupleResultT, ActorTupleT> converter4; + typedef impl::convert_actor<5, TupleResultT, ActorTupleT> converter5; + typedef impl::convert_actor<6, TupleResultT, ActorTupleT> converter6; + typedef impl::convert_actor<7, TupleResultT, ActorTupleT> converter7; + typedef impl::convert_actor<8, TupleResultT, ActorTupleT> converter8; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + , converter4::do_(actor_tuple) + , converter5::do_(actor_tuple) + , converter6::do_(actor_tuple) + , converter7::do_(actor_tuple) + , converter8::do_(actor_tuple) + ); + } + }; + }; + + #if PHOENIX_LIMIT > 9 + + ///////////////////////////////////// + template <> + struct convert_actors_<10> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + typedef impl::convert_actor<4, TupleResultT, ActorTupleT> converter4; + typedef impl::convert_actor<5, TupleResultT, ActorTupleT> converter5; + typedef impl::convert_actor<6, TupleResultT, ActorTupleT> converter6; + typedef impl::convert_actor<7, TupleResultT, ActorTupleT> converter7; + typedef impl::convert_actor<8, TupleResultT, ActorTupleT> converter8; + typedef impl::convert_actor<9, TupleResultT, ActorTupleT> converter9; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + , converter4::do_(actor_tuple) + , converter5::do_(actor_tuple) + , converter6::do_(actor_tuple) + , converter7::do_(actor_tuple) + , converter8::do_(actor_tuple) + , converter9::do_(actor_tuple) + ); + } + }; + }; + + ///////////////////////////////////// + template <> + struct convert_actors_<11> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + typedef impl::convert_actor<4, TupleResultT, ActorTupleT> converter4; + typedef impl::convert_actor<5, TupleResultT, ActorTupleT> converter5; + typedef impl::convert_actor<6, TupleResultT, ActorTupleT> converter6; + typedef impl::convert_actor<7, TupleResultT, ActorTupleT> converter7; + typedef impl::convert_actor<8, TupleResultT, ActorTupleT> converter8; + typedef impl::convert_actor<9, TupleResultT, ActorTupleT> converter9; + typedef impl::convert_actor<10, TupleResultT, ActorTupleT> converter10; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + , converter4::do_(actor_tuple) + , converter5::do_(actor_tuple) + , converter6::do_(actor_tuple) + , converter7::do_(actor_tuple) + , converter8::do_(actor_tuple) + , converter9::do_(actor_tuple) + , converter10::do_(actor_tuple) + ); + } + }; + }; + + ///////////////////////////////////// + template <> + struct convert_actors_<12> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + typedef impl::convert_actor<4, TupleResultT, ActorTupleT> converter4; + typedef impl::convert_actor<5, TupleResultT, ActorTupleT> converter5; + typedef impl::convert_actor<6, TupleResultT, ActorTupleT> converter6; + typedef impl::convert_actor<7, TupleResultT, ActorTupleT> converter7; + typedef impl::convert_actor<8, TupleResultT, ActorTupleT> converter8; + typedef impl::convert_actor<9, TupleResultT, ActorTupleT> converter9; + typedef impl::convert_actor<10, TupleResultT, ActorTupleT> converter10; + typedef impl::convert_actor<11, TupleResultT, ActorTupleT> converter11; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + , converter4::do_(actor_tuple) + , converter5::do_(actor_tuple) + , converter6::do_(actor_tuple) + , converter7::do_(actor_tuple) + , converter8::do_(actor_tuple) + , converter9::do_(actor_tuple) + , converter10::do_(actor_tuple) + , converter11::do_(actor_tuple) + ); + } + }; + }; + + #if PHOENIX_LIMIT > 12 + + ///////////////////////////////////// + template <> + struct convert_actors_<13> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + typedef impl::convert_actor<4, TupleResultT, ActorTupleT> converter4; + typedef impl::convert_actor<5, TupleResultT, ActorTupleT> converter5; + typedef impl::convert_actor<6, TupleResultT, ActorTupleT> converter6; + typedef impl::convert_actor<7, TupleResultT, ActorTupleT> converter7; + typedef impl::convert_actor<8, TupleResultT, ActorTupleT> converter8; + typedef impl::convert_actor<9, TupleResultT, ActorTupleT> converter9; + typedef impl::convert_actor<10, TupleResultT, ActorTupleT> converter10; + typedef impl::convert_actor<11, TupleResultT, ActorTupleT> converter11; + typedef impl::convert_actor<12, TupleResultT, ActorTupleT> converter12; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + , converter4::do_(actor_tuple) + , converter5::do_(actor_tuple) + , converter6::do_(actor_tuple) + , converter7::do_(actor_tuple) + , converter8::do_(actor_tuple) + , converter9::do_(actor_tuple) + , converter10::do_(actor_tuple) + , converter11::do_(actor_tuple) + , converter12::do_(actor_tuple) + ); + } + }; + }; + + /////////////////////////////////////// + template <> + struct convert_actors_<14> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + typedef impl::convert_actor<4, TupleResultT, ActorTupleT> converter4; + typedef impl::convert_actor<5, TupleResultT, ActorTupleT> converter5; + typedef impl::convert_actor<6, TupleResultT, ActorTupleT> converter6; + typedef impl::convert_actor<7, TupleResultT, ActorTupleT> converter7; + typedef impl::convert_actor<8, TupleResultT, ActorTupleT> converter8; + typedef impl::convert_actor<9, TupleResultT, ActorTupleT> converter9; + typedef impl::convert_actor<10, TupleResultT, ActorTupleT> converter10; + typedef impl::convert_actor<11, TupleResultT, ActorTupleT> converter11; + typedef impl::convert_actor<12, TupleResultT, ActorTupleT> converter12; + typedef impl::convert_actor<13, TupleResultT, ActorTupleT> converter13; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + , converter4::do_(actor_tuple) + , converter5::do_(actor_tuple) + , converter6::do_(actor_tuple) + , converter7::do_(actor_tuple) + , converter8::do_(actor_tuple) + , converter9::do_(actor_tuple) + , converter10::do_(actor_tuple) + , converter11::do_(actor_tuple) + , converter12::do_(actor_tuple) + , converter13::do_(actor_tuple) + ); + } + }; + }; + + /////////////////////////////////////// + template <> + struct convert_actors_<15> + { + template + struct apply + { + static TupleResultT + do_(ActorTupleT const& actor_tuple) + { + typedef impl::convert_actor<0, TupleResultT, ActorTupleT> converter0; + typedef impl::convert_actor<1, TupleResultT, ActorTupleT> converter1; + typedef impl::convert_actor<2, TupleResultT, ActorTupleT> converter2; + typedef impl::convert_actor<3, TupleResultT, ActorTupleT> converter3; + typedef impl::convert_actor<4, TupleResultT, ActorTupleT> converter4; + typedef impl::convert_actor<5, TupleResultT, ActorTupleT> converter5; + typedef impl::convert_actor<6, TupleResultT, ActorTupleT> converter6; + typedef impl::convert_actor<7, TupleResultT, ActorTupleT> converter7; + typedef impl::convert_actor<8, TupleResultT, ActorTupleT> converter8; + typedef impl::convert_actor<9, TupleResultT, ActorTupleT> converter9; + typedef impl::convert_actor<10, TupleResultT, ActorTupleT> converter10; + typedef impl::convert_actor<11, TupleResultT, ActorTupleT> converter11; + typedef impl::convert_actor<12, TupleResultT, ActorTupleT> converter12; + typedef impl::convert_actor<13, TupleResultT, ActorTupleT> converter13; + typedef impl::convert_actor<14, TupleResultT, ActorTupleT> converter14; + + using namespace tuple_index_names; + return TupleResultT( + converter0::do_(actor_tuple) + , converter1::do_(actor_tuple) + , converter2::do_(actor_tuple) + , converter3::do_(actor_tuple) + , converter4::do_(actor_tuple) + , converter5::do_(actor_tuple) + , converter6::do_(actor_tuple) + , converter7::do_(actor_tuple) + , converter8::do_(actor_tuple) + , converter9::do_(actor_tuple) + , converter10::do_(actor_tuple) + , converter11::do_(actor_tuple) + , converter12::do_(actor_tuple) + , converter13::do_(actor_tuple) + , converter14::do_(actor_tuple) + ); + } + }; + }; + + #endif + #endif + #endif + #endif +} // namespace impl + + +/////////////////////////////////////////////////////////////////////////////// +} // namespace phoenix + +#endif // PHOENIX_TUPLEHELPERS_HPP diff --git a/boost/boost/spirit/phoenix/tuples.hpp b/boost/boost/spirit/phoenix/tuples.hpp new file mode 100644 index 0000000000..0cde04127f --- /dev/null +++ b/boost/boost/spirit/phoenix/tuples.hpp @@ -0,0 +1,1330 @@ +/*============================================================================= + Phoenix V1.2.1 + Copyright (c) 2001-2002 Joel de Guzman + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef PHOENIX_TUPLES_HPP +#define PHOENIX_TUPLES_HPP + +#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) +#error "Sorry, Phoenix does not support VC6 and VC7. Please upgrade to at least VC7.1" +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// Phoenix predefined maximum limit. This limit defines the maximum +// number of elements a tuple can hold. This number defaults to 3. The +// actual maximum is rounded up in multiples of 3. Thus, if this value +// is 4, the actual limit is 6. The ultimate maximum limit in this +// implementation is 15. +// +/////////////////////////////////////////////////////////////////////////////// +#ifndef PHOENIX_LIMIT +#define PHOENIX_LIMIT 3 +#endif + +#if defined(__BORLANDC__) && (__BORLANDC__ <= 0x561) +namespace phoenix { namespace borland_only +{ + namespace ftors + { + // We define these dummy template functions. Borland complains when + // a template class has the same name as a template function, + // regardless if they are in different namespaces. + + template void if_(T) {} + template void for_(T) {} + template void while_(T) {} + template void do_(T) {} + } + + namespace tmpls + { + // We define these dummy template functions. Borland complains when + // a template class has the same name as a template function, + // regardless if they are in different namespaces. + + template struct if_ {}; + template struct for_ {}; + template struct while_ {}; + template struct do_ {}; + } + +}} // namespace phoenix::borland_only +#endif + +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace phoenix { + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple +// +// Tuples hold heterogeneous types up to a predefined maximum. Only +// the most basic functionality needed is provided. Unlike other +// recursive list-like tuple implementations, this tuple +// implementation uses simple structs similar to std::pair with +// specialization for 0 to N tuple elements. +// +// 1) Construction +// Here are examples on how to construct tuples: +// +// typedef tuple t1_t; +// typedef tuple t2_t; +// +// // this tuple has an int and char members +// t1_t t1(3, 'c'); +// +// // this tuple has an int, std::string and double members +// t2_t t2(3, "hello", 3.14); +// +// Tuples can also be constructed from other tuples. The +// source and destination tuples need not have exactly the +// same element types. The only requirement is that the +// source tuple have the same number of elements as the +// destination and that each element slot in the +// destination can be copy constructed from the source +// element. For example: +// +// tuple t3(t1); // OK. Compatible tuples +// tuple t4(t2); // Error! Incompatible tuples +// +// 2) Member access +// A member in a tuple can be accessed using the +// tuple's [] operator by specifying the Nth +// tuple_index. Here are some examples: +// +// tuple_index<0> ix0; // 0th index == 1st item +// tuple_index<1> ix1; // 1st index == 2nd item +// tuple_index<2> ix2; // 2nd index == 3rd item +// +// t1[ix0] = 33; // sets the int member of the tuple t1 +// t2[ix2] = 6e6; // sets the double member of the tuple t2 +// t1[ix1] = 'a'; // sets the char member of the tuple t1 +// +// There are some predefined names are provided in sub- +// namespace tuple_index_names: +// +// tuple_index<0> _1; +// tuple_index<1> _2; +// ... +// tuple_index _N; +// +// These indexes may be used by 'using' namespace +// phoenix::tuple_index_names. +// +// Access to out of bound indexes returns a nil_t value. +// +// 3) Member type inquiry +// The type of an individual member can be queried. +// Example: +// +// tuple_element<1, t2_t>::type +// +// Refers to the type of the second member (note zero based, +// thus 0 = 1st item, 1 = 2nd item) of the tuple. +// +// Aside from tuple_element::type, there are two +// more types that tuple_element provides: rtype and +// crtype. While 'type' is the plain underlying type, +// 'rtype' is the reference type, or type& and 'crtype' +// is the constant reference type or type const&. The +// latter two are provided to make it easy for the +// client in dealing with the possibility of reference +// to reference when type is already a reference, which +// is illegal in C++. +// +// Access to out of bound indexes returns a nil_t type. +// +// 4) Tuple length +// The number of elements in a tuple can be queried. +// Example: +// +// int n = t1.length; +// +// gets the number of elements in tuple t1. +// +// length is a static constant. Thus, TupleT::length +// also works. Example: +// +// int n = t1_t::length; +// +/////////////////////////////////////////////////////////////////////////////// +struct nil_t {}; +using boost::remove_reference; +using boost::call_traits; + +////////////////////////////////// +namespace impl { + + template + struct access { + + typedef const T& ctype; + typedef T& type; + }; + + template + struct access { + + typedef T& ctype; + typedef T& type; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple_element +// +// A query class that gets the Nth element inside a tuple. +// Examples: +// +// tuple_element<1, tuple >::type // plain +// tuple_element<1, tuple >::rtype // ref +// tuple_element<1, tuple >::crtype // const ref +// +// Has type char which is the 2nd type in the tuple +// (note zero based, thus 0 = 1st item, 1 = 2nd item). +// +// Given a tuple object, the static function tuple_element::get(tuple) gets the Nth element in the tuple. The +// tuple class' tuple::operator[] uses this to get its Nth +// element. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct tuple_element +{ + typedef nil_t type; + typedef nil_t& rtype; + typedef nil_t const& crtype; + + static nil_t get(TupleT const& t) { return nil_t(); } +}; + +////////////////////////////////// +template +struct tuple_element<0, TupleT> +{ + typedef typename TupleT::a_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.a; } + static crtype get(TupleT const& t) { return t.a; } +}; + +////////////////////////////////// +template +struct tuple_element<1, TupleT> +{ + typedef typename TupleT::b_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.b; } + static crtype get(TupleT const& t) { return t.b; } +}; + +////////////////////////////////// +template +struct tuple_element<2, TupleT> +{ + typedef typename TupleT::c_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.c; } + static crtype get(TupleT const& t) { return t.c; } +}; + +#if PHOENIX_LIMIT > 3 +////////////////////////////////// +template +struct tuple_element<3, TupleT> +{ + typedef typename TupleT::d_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.d; } + static crtype get(TupleT const& t) { return t.d; } +}; + +////////////////////////////////// +template +struct tuple_element<4, TupleT> +{ + typedef typename TupleT::e_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.e; } + static crtype get(TupleT const& t) { return t.e; } +}; + +////////////////////////////////// +template +struct tuple_element<5, TupleT> +{ + typedef typename TupleT::f_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.f; } + static crtype get(TupleT const& t) { return t.f; } +}; + +#if PHOENIX_LIMIT > 6 +////////////////////////////////// +template +struct tuple_element<6, TupleT> +{ + typedef typename TupleT::g_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.g; } + static crtype get(TupleT const& t) { return t.g; } +}; + +////////////////////////////////// +template +struct tuple_element<7, TupleT> +{ + typedef typename TupleT::h_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.h; } + static crtype get(TupleT const& t) { return t.h; } +}; + +////////////////////////////////// +template +struct tuple_element<8, TupleT> +{ + typedef typename TupleT::i_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.i; } + static crtype get(TupleT const& t) { return t.i; } +}; + +#if PHOENIX_LIMIT > 9 +////////////////////////////////// +template +struct tuple_element<9, TupleT> +{ + typedef typename TupleT::j_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.j; } + static crtype get(TupleT const& t) { return t.j; } +}; + +////////////////////////////////// +template +struct tuple_element<10, TupleT> +{ + typedef typename TupleT::k_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.k; } + static crtype get(TupleT const& t) { return t.k; } +}; + +////////////////////////////////// +template +struct tuple_element<11, TupleT> +{ + typedef typename TupleT::l_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.l; } + static crtype get(TupleT const& t) { return t.l; } +}; + +#if PHOENIX_LIMIT > 12 +////////////////////////////////// +template +struct tuple_element<12, TupleT> +{ + typedef typename TupleT::m_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.m; } + static crtype get(TupleT const& t) { return t.m; } +}; + +////////////////////////////////// +template +struct tuple_element<13, TupleT> +{ + typedef typename TupleT::n_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.n; } + static crtype get(TupleT const& t) { return t.n; } +}; + +////////////////////////////////// +template +struct tuple_element<14, TupleT> +{ + typedef typename TupleT::o_type type; + typedef typename impl::access::type rtype; + typedef typename impl::access::ctype crtype; + + static rtype get(TupleT& t) { return t.o; } + static crtype get(TupleT const& t) { return t.o; } +}; + +#endif +#endif +#endif +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple forward declaration. +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A = nil_t + , typename B = nil_t + , typename C = nil_t + +#if PHOENIX_LIMIT > 3 + , typename D = nil_t + , typename E = nil_t + , typename F = nil_t + +#if PHOENIX_LIMIT > 6 + , typename G = nil_t + , typename H = nil_t + , typename I = nil_t + +#if PHOENIX_LIMIT > 9 + , typename J = nil_t + , typename K = nil_t + , typename L = nil_t + +#if PHOENIX_LIMIT > 12 + , typename M = nil_t + , typename N = nil_t + , typename O = nil_t + +#endif +#endif +#endif +#endif + + , typename NU = nil_t // Not used +> +struct tuple; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple_index +// +// This class wraps an integer in a type to be used for indexing +// the Nth element in a tuple. See tuple operator[]. Some +// predefined names are provided in sub-namespace +// tuple_index_names. +// +/////////////////////////////////////////////////////////////////////////////// +template +struct tuple_index {}; + +////////////////////////////////// +namespace tuple_index_names { + + tuple_index<0> const _1 = tuple_index<0>(); + tuple_index<1> const _2 = tuple_index<1>(); + tuple_index<2> const _3 = tuple_index<2>(); + +#if PHOENIX_LIMIT > 3 + tuple_index<3> const _4 = tuple_index<3>(); + tuple_index<4> const _5 = tuple_index<4>(); + tuple_index<5> const _6 = tuple_index<5>(); + +#if PHOENIX_LIMIT > 6 + tuple_index<6> const _7 = tuple_index<6>(); + tuple_index<7> const _8 = tuple_index<7>(); + tuple_index<8> const _9 = tuple_index<8>(); + +#if PHOENIX_LIMIT > 9 + tuple_index<9> const _10 = tuple_index<9>(); + tuple_index<10> const _11 = tuple_index<10>(); + tuple_index<11> const _12 = tuple_index<11>(); + +#if PHOENIX_LIMIT > 12 + tuple_index<12> const _13 = tuple_index<12>(); + tuple_index<13> const _14 = tuple_index<13>(); + tuple_index<14> const _15 = tuple_index<14>(); + +#endif +#endif +#endif +#endif +} + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple_common class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct tuple_base { + + typedef nil_t a_type; + typedef nil_t b_type; + typedef nil_t c_type; + +#if PHOENIX_LIMIT > 3 + typedef nil_t d_type; + typedef nil_t e_type; + typedef nil_t f_type; + +#if PHOENIX_LIMIT > 6 + typedef nil_t g_type; + typedef nil_t h_type; + typedef nil_t i_type; + +#if PHOENIX_LIMIT > 9 + typedef nil_t j_type; + typedef nil_t k_type; + typedef nil_t l_type; + +#if PHOENIX_LIMIT > 12 + typedef nil_t m_type; + typedef nil_t n_type; + typedef nil_t o_type; + +#endif +#endif +#endif +#endif + + template + typename tuple_element::crtype + operator[](tuple_index) const + { + return tuple_element + ::get(*static_cast(this)); + } + + template + typename tuple_element::rtype + operator[](tuple_index) + { + return tuple_element + ::get(*static_cast(this)); + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <0 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template <> +struct tuple<> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 0); +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <1 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct tuple 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 1); + typedef A a_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_ + ): a(a_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <2 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct tuple 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 2); + typedef A a_type; typedef B b_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_ + ): a(a_), b(b_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <3 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct tuple 3 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 3); + typedef A a_type; typedef B b_type; + typedef C c_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_ + ): a(a_), b(b_), c(c_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; +}; + +#if PHOENIX_LIMIT > 3 +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <4 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct tuple 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 4); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_ + ): a(a_), b(b_), c(c_), d(d_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <5 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template +struct tuple 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 5); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + typedef E e_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_, + typename call_traits::param_type e_ + ): a(a_), b(b_), c(c_), d(d_), e(e_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]), + e(init[tuple_index<4>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; E e; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <6 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, + typename F> +struct tuple 6 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 6); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + typedef E e_type; typedef F f_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_, + typename call_traits::param_type e_, + typename call_traits::param_type f_ + ): a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]), + e(init[tuple_index<4>()]), f(init[tuple_index<5>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; E e; + F f; +}; + +#if PHOENIX_LIMIT > 6 +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <7 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G> +struct tuple 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 7); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + typedef E e_type; typedef F f_type; + typedef G g_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_, + typename call_traits::param_type e_, + typename call_traits::param_type f_, + typename call_traits::param_type g_ + ): a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]), + e(init[tuple_index<4>()]), f(init[tuple_index<5>()]), + g(init[tuple_index<6>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; E e; + F f; G g; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <8 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H> +struct tuple 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 8); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + typedef E e_type; typedef F f_type; + typedef G g_type; typedef H h_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_, + typename call_traits::param_type e_, + typename call_traits::param_type f_, + typename call_traits::param_type g_, + typename call_traits::param_type h_ + ): a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]), + e(init[tuple_index<4>()]), f(init[tuple_index<5>()]), + g(init[tuple_index<6>()]), h(init[tuple_index<7>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; E e; + F f; G g; H h; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <9 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I> +struct tuple 9 + nil_t, nil_t, nil_t, +#if PHOENIX_LIMIT > 12 + nil_t, nil_t, nil_t, +#endif +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 9); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + typedef E e_type; typedef F f_type; + typedef G g_type; typedef H h_type; + typedef I i_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_, + typename call_traits::param_type e_, + typename call_traits::param_type f_, + typename call_traits::param_type g_, + typename call_traits::param_type h_, + typename call_traits::param_type i_ + ): a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]), + e(init[tuple_index<4>()]), f(init[tuple_index<5>()]), + g(init[tuple_index<6>()]), h(init[tuple_index<7>()]), + i(init[tuple_index<8>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; E e; + F f; G g; H h; I i; +}; + +#if PHOENIX_LIMIT > 9 +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <10 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J> +struct tuple 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 10); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + typedef E e_type; typedef F f_type; + typedef G g_type; typedef H h_type; + typedef I i_type; typedef J j_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_, + typename call_traits::param_type e_, + typename call_traits::param_type f_, + typename call_traits::param_type g_, + typename call_traits::param_type h_, + typename call_traits::param_type i_, + typename call_traits::param_type j_ + ): a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]), + e(init[tuple_index<4>()]), f(init[tuple_index<5>()]), + g(init[tuple_index<6>()]), h(init[tuple_index<7>()]), + i(init[tuple_index<8>()]), j(init[tuple_index<9>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; E e; + F f; G g; H h; I i; J j; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <11 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K> +struct tuple 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 11); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + typedef E e_type; typedef F f_type; + typedef G g_type; typedef H h_type; + typedef I i_type; typedef J j_type; + typedef K k_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_, + typename call_traits::param_type e_, + typename call_traits::param_type f_, + typename call_traits::param_type g_, + typename call_traits::param_type h_, + typename call_traits::param_type i_, + typename call_traits::param_type j_, + typename call_traits::param_type k_ + ): a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_), + k(k_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]), + e(init[tuple_index<4>()]), f(init[tuple_index<5>()]), + g(init[tuple_index<6>()]), h(init[tuple_index<7>()]), + i(init[tuple_index<8>()]), j(init[tuple_index<9>()]), + k(init[tuple_index<10>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; E e; + F f; G g; H h; I i; J j; + K k; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <12 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L> +struct tuple 12 + nil_t, nil_t, nil_t, +#endif + nil_t // Unused +> +: public tuple_base > { + + BOOST_STATIC_CONSTANT(int, length = 12); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + typedef E e_type; typedef F f_type; + typedef G g_type; typedef H h_type; + typedef I i_type; typedef J j_type; + typedef K k_type; typedef L l_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_, + typename call_traits::param_type e_, + typename call_traits::param_type f_, + typename call_traits::param_type g_, + typename call_traits::param_type h_, + typename call_traits::param_type i_, + typename call_traits::param_type j_, + typename call_traits::param_type k_, + typename call_traits::param_type l_ + ): a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_), + k(k_), l(l_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]), + e(init[tuple_index<4>()]), f(init[tuple_index<5>()]), + g(init[tuple_index<6>()]), h(init[tuple_index<7>()]), + i(init[tuple_index<8>()]), j(init[tuple_index<9>()]), + k(init[tuple_index<10>()]), l(init[tuple_index<11>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; E e; + F f; G g; H h; I i; J j; + K k; L l; +}; + +#if PHOENIX_LIMIT > 12 +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <13 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M> +struct tuple +: public tuple_base< + tuple > { + + BOOST_STATIC_CONSTANT(int, length = 13); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + typedef E e_type; typedef F f_type; + typedef G g_type; typedef H h_type; + typedef I i_type; typedef J j_type; + typedef K k_type; typedef L l_type; + typedef M m_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_, + typename call_traits::param_type e_, + typename call_traits::param_type f_, + typename call_traits::param_type g_, + typename call_traits::param_type h_, + typename call_traits::param_type i_, + typename call_traits::param_type j_, + typename call_traits::param_type k_, + typename call_traits::param_type l_, + typename call_traits::param_type m_ + ): a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_), + k(k_), l(l_), m(m_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]), + e(init[tuple_index<4>()]), f(init[tuple_index<5>()]), + g(init[tuple_index<6>()]), h(init[tuple_index<7>()]), + i(init[tuple_index<8>()]), j(init[tuple_index<9>()]), + k(init[tuple_index<10>()]), l(init[tuple_index<11>()]), + m(init[tuple_index<12>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; E e; + F f; G g; H h; I i; J j; + K k; L l; M m; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <14 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N> +struct tuple +: public tuple_base< + tuple > { + + BOOST_STATIC_CONSTANT(int, length = 14); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + typedef E e_type; typedef F f_type; + typedef G g_type; typedef H h_type; + typedef I i_type; typedef J j_type; + typedef K k_type; typedef L l_type; + typedef M m_type; typedef N n_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_, + typename call_traits::param_type e_, + typename call_traits::param_type f_, + typename call_traits::param_type g_, + typename call_traits::param_type h_, + typename call_traits::param_type i_, + typename call_traits::param_type j_, + typename call_traits::param_type k_, + typename call_traits::param_type l_, + typename call_traits::param_type m_, + typename call_traits::param_type n_ + ): a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_), + k(k_), l(l_), m(m_), n(n_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]), + e(init[tuple_index<4>()]), f(init[tuple_index<5>()]), + g(init[tuple_index<6>()]), h(init[tuple_index<7>()]), + i(init[tuple_index<8>()]), j(init[tuple_index<9>()]), + k(init[tuple_index<10>()]), l(init[tuple_index<11>()]), + m(init[tuple_index<12>()]), n(init[tuple_index<13>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; E e; + F f; G g; H h; I i; J j; + K k; L l; M m; N n; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// tuple <15 member> class +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename A, typename B, typename C, typename D, typename E, + typename F, typename G, typename H, typename I, typename J, + typename K, typename L, typename M, typename N, typename O> +struct tuple +: public tuple_base< + tuple > { + + BOOST_STATIC_CONSTANT(int, length = 15); + typedef A a_type; typedef B b_type; + typedef C c_type; typedef D d_type; + typedef E e_type; typedef F f_type; + typedef G g_type; typedef H h_type; + typedef I i_type; typedef J j_type; + typedef K k_type; typedef L l_type; + typedef M m_type; typedef N n_type; + typedef O o_type; + + tuple() {} + + tuple( + typename call_traits::param_type a_, + typename call_traits::param_type b_, + typename call_traits::param_type c_, + typename call_traits::param_type d_, + typename call_traits::param_type e_, + typename call_traits::param_type f_, + typename call_traits::param_type g_, + typename call_traits::param_type h_, + typename call_traits::param_type i_, + typename call_traits::param_type j_, + typename call_traits::param_type k_, + typename call_traits::param_type l_, + typename call_traits::param_type m_, + typename call_traits::param_type n_, + typename call_traits::param_type o_ + ): a(a_), b(b_), c(c_), d(d_), e(e_), + f(f_), g(g_), h(h_), i(i_), j(j_), + k(k_), l(l_), m(m_), n(n_), o(o_) {} + + template + tuple(TupleT const& init) + : a(init[tuple_index<0>()]), b(init[tuple_index<1>()]), + c(init[tuple_index<2>()]), d(init[tuple_index<3>()]), + e(init[tuple_index<4>()]), f(init[tuple_index<5>()]), + g(init[tuple_index<6>()]), h(init[tuple_index<7>()]), + i(init[tuple_index<8>()]), j(init[tuple_index<9>()]), + k(init[tuple_index<10>()]), l(init[tuple_index<11>()]), + m(init[tuple_index<12>()]), n(init[tuple_index<13>()]), + o(init[tuple_index<14>()]) + { BOOST_STATIC_ASSERT(TupleT::length == length); } + + A a; B b; C c; D d; E e; + F f; G g; H h; I i; J j; + K k; L l; M m; N n; O o; +}; + +#endif +#endif +#endif +#endif + +/////////////////////////////////////////////////////////////////////////////// +} // namespace phoenix + +#endif diff --git a/boost/boost/spirit/symbols.hpp b/boost/boost/spirit/symbols.hpp new file mode 100644 index 0000000000..24d913acff --- /dev/null +++ b/boost/boost/spirit/symbols.hpp @@ -0,0 +1,22 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_SYMBOLS_MAIN_HPP) +#define BOOST_SPIRIT_SYMBOLS_MAIN_HPP + +#include + +/////////////////////////////////////////////////////////////////////////////// +// +// Master header for Spirit.Symbols +// +/////////////////////////////////////////////////////////////////////////////// + +#include + +#endif // !defined(BOOST_SPIRIT_SYMBOLS_MAIN_HPP) diff --git a/boost/boost/spirit/symbols/impl/symbols.ipp b/boost/boost/spirit/symbols/impl/symbols.ipp new file mode 100644 index 0000000000..20d746cb7b --- /dev/null +++ b/boost/boost/spirit/symbols/impl/symbols.ipp @@ -0,0 +1,113 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_SYMBOLS_IPP +#define BOOST_SPIRIT_SYMBOLS_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +// MSVC: void warning about the use of 'this' pointer in constructors +#if defined(BOOST_MSVC) +#pragma warning(disable : 4355) +#endif + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// symbols class implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +inline symbols::symbols() +: SetT() +, add(*this) +{ +} + +////////////////////////////////// +template +symbols::symbols(symbols const& other) +: SetT(other) +// Tru64 CXX seems to be confused by the explicit call of the default +// constructor and generates wrong code which invalidates the just contructed +// first base class in the line above. +#if !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590041)) +, parser >() +#endif +, add(*this) +{ +} + +////////////////////////////////// +template +inline symbols::~symbols() +{} + +////////////////////////////////// +template +inline symbols& +symbols::operator=(symbols const& other) +{ + SetT::operator=(other); + return *this; +} + +////////////////////////////////// +template +inline symbol_inserter const& +symbols::operator=(CharT const* str) +{ + return add, str; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// Symbol table utilities +// +/////////////////////////////////////////////////////////////////////////////// +template +inline T* +find(symbols const& table, CharT const* sym) +{ + CharT const* last = sym; + while (*last) + last++; + scanner scan(sym, last); + T* result = table.find(scan); + return scan.at_end()? result: 0; +} + +////////////////////////////////// +template +inline T* +add(symbols& table, CharT const* sym, T const& data) +{ + CharT const* first = sym; + CharT const* last = sym; + while (*last) + last++; + scanner scan(first, last); + if (table.find(scan) && scan.at_end()) + return 0; // symbol already contained in symbol table + table.add(sym, last, data); + first = sym; + return table.find(scan); // refind the inserted symbol +} + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#if defined(BOOST_MSVC) +#pragma warning(default : 4355) +#endif + +#endif diff --git a/boost/boost/spirit/symbols/impl/tst.ipp b/boost/boost/spirit/symbols/impl/tst.ipp new file mode 100644 index 0000000000..f328453e88 --- /dev/null +++ b/boost/boost/spirit/symbols/impl/tst.ipp @@ -0,0 +1,270 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_TST_IPP +#define BOOST_SPIRIT_TST_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include // for std::auto_ptr + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + + namespace impl + { + +/////////////////////////////////////////////////////////////////////////////// +// +// tst class +// +// Ternary Search Tree implementation. The data structure is faster than +// hashing for many typical search problems especially when the search +// interface is iterator based. Searching for a string of length k in a +// ternary search tree with n strings will require at most O(log n+k) +// character comparisons. TSTs are many times faster than hash tables +// for unsuccessful searches since mismatches are discovered earlier +// after examining only a few characters. Hash tables always examine an +// entire key when searching. +// +// For details see http://www.cs.princeton.edu/~rs/strings/. +// +// *** This is a low level class and is +// not meant for public consumption *** +// +/////////////////////////////////////////////////////////////////////////////// + template + struct tst_node + { + tst_node(CharT value_) + : value(value_) + , left(0) + , right(0) + { middle.link = 0; } + + ~tst_node() + { + delete left; + delete right; + if (value) + delete middle.link; + else + delete middle.data; + } + + tst_node* + clone() const + { + std::auto_ptr copy(new tst_node(value)); + + if (left) + copy->left = left->clone(); + if (right) + copy->right = right->clone(); + + if (value && middle.link) + { + copy->middle.link = middle.link->clone(); + } + else + { + std::auto_ptr mid_data(new T(*middle.data)); + copy->middle.data = mid_data.release(); + } + + return copy.release(); + } + + union center { + + tst_node* link; + T* data; + }; + + CharT value; + tst_node* left; + center middle; + tst_node* right; + }; + + /////////////////////////////////////////////////////////////////////////// + template + class tst + { + public: + + struct search_info + { + T* data; + std::size_t length; + }; + + tst() + : root(0) {} + + tst(tst const& other) + : root(other.root ? other.root->clone() : 0) {} + + ~tst() + { delete root; } + + tst& + operator=(tst const& other) + { + if (this != &other) + { + node_t* new_root = other.root ? other.root->clone() : 0; + delete root; + root = new_root; + } + return *this; + } + + template + T* add(IteratorT first, IteratorT const& last, T const& data) + { + if (first == last) + return 0; + + node_t** np = &root; + CharT ch = *first; + + for (;;) + { + if (*np == 0 || ch == 0) + { + node_t* right = 0; + if (np != 0) + right = *np; + *np = new node_t(ch); + if (right) + (**np).right = right; + } + + if (ch < (**np).value) + { + np = &(**np).left; + } + else + { + if (ch == (**np).value) + { + if (ch == 0) + { + if ((**np).middle.data == 0) + { + (**np).middle.data = new T(data); + return (**np).middle.data; + } + else + { + // re-addition is disallowed + return 0; + } + } + ++first; + ch = (first == last) ? 0 : *first; + np = &(**np).middle.link; + } + else + { + np = &(**np).right; + } + } + } + } + + template + search_info find(ScannerT const& scan) const + { + search_info result = { 0, 0 }; + if (scan.at_end()) { + return result; + } + + typedef typename ScannerT::iterator_t iterator_t; + node_t* np = root; + CharT ch = *scan; + iterator_t save = scan.first; + iterator_t latest = scan.first; + std::size_t latest_len = 0; + + while (np) + { + if (ch < np->value) + { + if (np->value == 0) + { + result.data = np->middle.data; + if (result.data) + { + latest = scan.first; + latest_len = result.length; + } + } + np = np->left; + } + else + { + if (ch == np->value) + { + if (scan.at_end()) + { + result.data = np->middle.data; + if (result.data) + { + latest = scan.first; + latest_len = result.length; + } + break; + } + + ++scan; + ch = scan.at_end() ? 0 : *scan; + np = np->middle.link; + ++result.length; + } + else + { + if (np->value == 0) + { + result.data = np->middle.data; + if (result.data) + { + latest = scan.first; + latest_len = result.length; + } + } + np = np->right; + } + } + } + + if (result.data == 0) + { + scan.first = save; + } + else + { + scan.first = latest; + result.length = latest_len; + } + return result; + } + + private: + + typedef tst_node node_t; + node_t* root; + }; + +/////////////////////////////////////////////////////////////////////////////// + } // namespace impl + +}} // namespace boost::spirit + +#endif diff --git a/boost/boost/spirit/symbols/symbols.hpp b/boost/boost/spirit/symbols/symbols.hpp new file mode 100644 index 0000000000..7896611550 --- /dev/null +++ b/boost/boost/spirit/symbols/symbols.hpp @@ -0,0 +1,237 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_SYMBOLS_HPP +#define BOOST_SPIRIT_SYMBOLS_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include + +#include + +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// Forward Declarations + +namespace impl +{ + template + class tst; +} + +template +class symbol_inserter; + +/////////////////////////////////////////////////////////////////////////////// +// +// symbols class +// +// This class implements a symbol table. The symbol table holds a +// dictionary of symbols where each symbol is a sequence of CharTs. +// The template class can work efficiently with 8, 16 and 32 bit +// characters. Mutable data of type T is associated with each +// symbol. +// +// The class is a parser. The parse member function returns +// additional information in the symbol_match class (see below). +// The additional data is a pointer to some data associated with +// the matching symbol. +// +// The actual set implementation is supplied by the SetT template +// parameter. By default, this uses the tst class (see tst.ipp). +// +// Symbols are added into the symbol table statically using the +// construct: +// +// sym = a, b, c, d ...; +// +// where sym is a symbol table and a..d are strings. Example: +// +// sym = "pineapple", "orange", "banana", "apple"; +// +// Alternatively, symbols may be added dynamically through the +// member functor 'add' (see symbol_inserter below). The member +// functor 'add' may be attached to a parser as a semantic action +// taking in a begin/end pair: +// +// p[sym.add] +// +// where p is a parser (and sym is a symbol table). On success, +// the matching portion of the input is added to the symbol table. +// +// 'add' may also be used to directly initialize data. Examples: +// +// sym.add("hello", 1)("crazy", 2)("world", 3); +// +/////////////////////////////////////////////////////////////////////////////// +template +< + typename T = int, + typename CharT = char, + typename SetT = impl::tst +> +class symbols +: private SetT +, public parser > +{ +public: + + typedef parser > parser_base_t; + typedef symbols self_t; + typedef self_t const& embed_t; + typedef T symbol_data_t; + typedef boost::reference_wrapper symbol_ref_t; + + symbols(); + symbols(symbols const& other); + ~symbols(); + + symbols& + operator=(symbols const& other); + + symbol_inserter const& + operator=(CharT const* str); + + template + struct result + { + typedef typename match_result::type type; + }; + + template + typename parser_result::type + parse_main(ScannerT const& scan) const + { + typedef typename ScannerT::iterator_t iterator_t; + iterator_t first = scan.first; + typename SetT::search_info result = SetT::find(scan); + + if (result.data) + return scan. + create_match( + result.length, + symbol_ref_t(*result.data), + first, + scan.first); + else + return scan.no_match(); + } + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + typedef typename parser_result::type result_t; + return impl::implicit_lexeme_parse + (*this, scan, scan); + } + + template < typename ScannerT > + T* find(ScannerT const& scan) const + { return SetT::find(scan).data; } + + symbol_inserter const add; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Symbol table utilities +// +// add +// +// adds a symbol 'sym' (string) to a symbol table 'table' plus an +// optional data 'data' associated with the symbol. Returns a pointer to +// the data associated with the symbol or NULL if add failed (e.g. when +// the symbol is already added before). +// +// find +// +// finds a symbol 'sym' (string) from a symbol table 'table'. Returns a +// pointer to the data associated with the symbol or NULL if not found +// +/////////////////////////////////////////////////////////////////////////////// +template +T* add(symbols& table, CharT const* sym, T const& data = T()); + +template +T* find(symbols const& table, CharT const* sym); + +/////////////////////////////////////////////////////////////////////////////// +// +// symbol_inserter class +// +// The symbols class holds an instance of this class named 'add'. +// This can be called directly just like a member function, +// passing in a first/last iterator and optional data: +// +// sym.add(first, last, data); +// +// Or, passing in a C string and optional data: +// +// sym.add(c_string, data); +// +// where sym is a symbol table. The 'data' argument is optional. +// This may also be used as a semantic action since it conforms +// to the action interface (see action.hpp): +// +// p[sym.add] +// +/////////////////////////////////////////////////////////////////////////////// +template +class symbol_inserter +{ +public: + + symbol_inserter(SetT& set_) + : set(set_) {} + + template + symbol_inserter const& + operator()(IteratorT first, IteratorT const& last, T const& data = T()) const + { + set.add(first, last, data); + return *this; + } + + template + symbol_inserter const& + operator()(CharT const* str, T const& data = T()) const + { + CharT const* last = str; + while (*last) + last++; + set.add(str, last, data); + return *this; + } + + template + symbol_inserter const& + operator,(CharT const* str) const + { + CharT const* last = str; + while (*last) + last++; + set.add(str, last, T()); + return *this; + } + +private: + + SetT& set; +}; + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#include +#endif diff --git a/boost/boost/spirit/utility.hpp b/boost/boost/spirit/utility.hpp new file mode 100644 index 0000000000..6fdf7ba835 --- /dev/null +++ b/boost/boost/spirit/utility.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + Copyright (c) 1998-2003 Joel de Guzman + Copyright (c) 2001-2003 Daniel Nuffer + Copyright (c) 2001-2003 Hartmut Kaiser + Copyright (c) 2002-2003 Martin Wille + Copyright (c) 2002 Juan Carlos Arevalo-Baeza + Copyright (c) 2002 Raghavendra Satish + Copyright (c) 2002 Jeff Westfahl + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_UTILITY_MAIN_HPP) +#define BOOST_SPIRIT_UTILITY_MAIN_HPP + +#include + +/////////////////////////////////////////////////////////////////////////////// +// +// Master header for Spirit.Utilities +// +/////////////////////////////////////////////////////////////////////////////// + +// Utility.Parsers +#include +#include +#include +#include +#include +#include +#include +#include + +// Utility.Support +#include +#include + + +#endif // !defined(BOOST_SPIRIT_UTILITY_MAIN_HPP) diff --git a/boost/boost/spirit/utility/chset.hpp b/boost/boost/spirit/utility/chset.hpp new file mode 100644 index 0000000000..4273d1ce24 --- /dev/null +++ b/boost/boost/spirit/utility/chset.hpp @@ -0,0 +1,183 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2001-2003 Daniel Nuffer + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_CHSET_HPP +#define BOOST_SPIRIT_CHSET_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +namespace utility { namespace impl { + + // This is here because some compilers choke on out-of-line member + // template functions. And we don't want to put the whole algorithm + // in the chset constructor in the class definition. + template + void construct_chset(boost::shared_ptr >& ptr, + CharT2 const* definition); + +}} // namespace utility::impl + +/////////////////////////////////////////////////////////////////////////////// +// +// chset class +// +/////////////////////////////////////////////////////////////////////////////// +template +class chset: public char_parser > { + +public: + chset(); + chset(chset const& arg_); + explicit chset(CharT arg_); + explicit chset(anychar_parser arg_); + explicit chset(nothing_parser arg_); + explicit chset(chlit const& arg_); + explicit chset(range const& arg_); + explicit chset(negated_char_parser > const& arg_); + explicit chset(negated_char_parser > const& arg_); + + template + explicit chset(CharT2 const* definition) + : ptr(new basic_chset()) + { + utility::impl::construct_chset(ptr, definition); + } + ~chset(); + + chset& operator=(chset const& rhs); + chset& operator=(CharT rhs); + chset& operator=(anychar_parser rhs); + chset& operator=(nothing_parser rhs); + chset& operator=(chlit const& rhs); + chset& operator=(range const& rhs); + chset& operator=(negated_char_parser > const& rhs); + chset& operator=(negated_char_parser > const& rhs); + + void set(range const& arg_); + void set(negated_char_parser > const& arg_); + void set(negated_char_parser > const& arg_); + + void clear(range const& arg_); + void clear(negated_char_parser > const& arg_); + bool test(CharT ch) const; + chset& inverse(); + void swap(chset& x); + + chset& operator|=(chset const& x); + chset& operator&=(chset const& x); + chset& operator-=(chset const& x); + chset& operator^=(chset const& x); + +private: + + boost::shared_ptr > ptr; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Generator functions +// +/////////////////////////////////////////////////////////////////////////////// +template +inline chset +chset_p(chlit const& arg_) +{ return chset(arg_); } + +////////////////////////////////// +template +inline chset +chset_p(range const& arg_) +{ return chset(arg_); } + +template +inline chset +chset_p(negated_char_parser > const& arg_) +{ return chset(arg_); } + +template +inline chset +chset_p(negated_char_parser > const& arg_) +{ return chset(arg_); } + +////////////////////////////////// +inline chset +chset_p(char const* init) +{ return chset(init); } + +////////////////////////////////// +inline chset +chset_p(wchar_t const* init) +{ return chset(init); } + +////////////////////////////////// +inline chset +chset_p(char ch) +{ return chset(ch); } + +////////////////////////////////// +inline chset +chset_p(wchar_t ch) +{ return chset(ch); } + +////////////////////////////////// +inline chset +chset_p(int ch) +{ return chset(ch); } + +////////////////////////////////// +inline chset +chset_p(unsigned int ch) +{ return chset(ch); } + +////////////////////////////////// +inline chset +chset_p(short ch) +{ return chset(ch); } + +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) +////////////////////////////////// +inline chset +chset_p(unsigned short ch) +{ return chset(ch); } +#endif +////////////////////////////////// +inline chset +chset_p(long ch) +{ return chset(ch); } + +////////////////////////////////// +inline chset +chset_p(unsigned long ch) +{ return chset(ch); } + +#ifdef BOOST_HAS_LONG_LONG +////////////////////////////////// +inline chset< ::boost::long_long_type> +chset_p( ::boost::long_long_type ch) +{ return chset< ::boost::long_long_type>(ch); } + +////////////////////////////////// +inline chset< ::boost::ulong_long_type> +chset_p( ::boost::ulong_long_type ch) +{ return chset< ::boost::ulong_long_type>(ch); } +#endif + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif + +#include +#include diff --git a/boost/boost/spirit/utility/chset_operators.hpp b/boost/boost/spirit/utility/chset_operators.hpp new file mode 100644 index 0000000000..e1446ff5f7 --- /dev/null +++ b/boost/boost/spirit/utility/chset_operators.hpp @@ -0,0 +1,398 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2001-2003 Daniel Nuffer + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_CHSET_OPERATORS_HPP +#define BOOST_SPIRIT_CHSET_OPERATORS_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// chset free operators +// +// Where a and b are both chsets, implements: +// +// a | b, a & b, a - b, a ^ b +// +// Where a is a chset, implements: +// +// ~a +// +/////////////////////////////////////////////////////////////////////////////// +template +chset +operator~(chset const& a); + +////////////////////////////////// +template +chset +operator|(chset const& a, chset const& b); + +////////////////////////////////// +template +chset +operator&(chset const& a, chset const& b); + +////////////////////////////////// +template +chset +operator-(chset const& a, chset const& b); + +////////////////////////////////// +template +chset +operator^(chset const& a, chset const& b); + +/////////////////////////////////////////////////////////////////////////////// +// +// range <--> chset free operators +// +// Where a is a chset and b is a range, and vice-versa, implements: +// +// a | b, a & b, a - b, a ^ b +// +/////////////////////////////////////////////////////////////////////////////// +template +chset +operator|(chset const& a, range const& b); + +////////////////////////////////// +template +chset +operator&(chset const& a, range const& b); + +////////////////////////////////// +template +chset +operator-(chset const& a, range const& b); + +////////////////////////////////// +template +chset +operator^(chset const& a, range const& b); + +////////////////////////////////// +template +chset +operator|(range const& a, chset const& b); + +////////////////////////////////// +template +chset +operator&(range const& a, chset const& b); + +////////////////////////////////// +template +chset +operator-(range const& a, chset const& b); + +////////////////////////////////// +template +chset +operator^(range const& a, chset const& b); + +/////////////////////////////////////////////////////////////////////////////// +// +// chlit <--> chset free operators +// +// Where a is a chset and b is a chlit, and vice-versa, implements: +// +// a | b, a & b, a - b, a ^ b +// +/////////////////////////////////////////////////////////////////////////////// +template +chset +operator|(chset const& a, chlit const& b); + +////////////////////////////////// +template +chset +operator&(chset const& a, chlit const& b); + +////////////////////////////////// +template +chset +operator-(chset const& a, chlit const& b); + +////////////////////////////////// +template +chset +operator^(chset const& a, chlit const& b); + +////////////////////////////////// +template +chset +operator|(chlit const& a, chset const& b); + +////////////////////////////////// +template +chset +operator&(chlit const& a, chset const& b); + +////////////////////////////////// +template +chset +operator-(chlit const& a, chset const& b); + +////////////////////////////////// +template +chset +operator^(chlit const& a, chset const& b); + +/////////////////////////////////////////////////////////////////////////////// +// +// negated_char_parser <--> chset free operators +// +// Where a is a chset and b is a range, and vice-versa, implements: +// +// a | b, a & b, a - b, a ^ b +// +/////////////////////////////////////////////////////////////////////////////// +template +chset +operator|(chset const& a, negated_char_parser > const& b); + +////////////////////////////////// +template +chset +operator&(chset const& a, negated_char_parser > const& b); + +////////////////////////////////// +template +chset +operator-(chset const& a, negated_char_parser > const& b); + +////////////////////////////////// +template +chset +operator^(chset const& a, negated_char_parser > const& b); + +////////////////////////////////// +template +chset +operator|(negated_char_parser > const& a, chset const& b); + +////////////////////////////////// +template +chset +operator&(negated_char_parser > const& a, chset const& b); + +////////////////////////////////// +template +chset +operator-(negated_char_parser > const& a, chset const& b); + +////////////////////////////////// +template +chset +operator^(negated_char_parser > const& a, chset const& b); + +/////////////////////////////////////////////////////////////////////////////// +// +// negated_char_parser <--> chset free operators +// +// Where a is a chset and b is a chlit, and vice-versa, implements: +// +// a | b, a & b, a - b, a ^ b +// +/////////////////////////////////////////////////////////////////////////////// +template +chset +operator|(chset const& a, negated_char_parser > const& b); + +////////////////////////////////// +template +chset +operator&(chset const& a, negated_char_parser > const& b); + +////////////////////////////////// +template +chset +operator-(chset const& a, negated_char_parser > const& b); + +////////////////////////////////// +template +chset +operator^(chset const& a, negated_char_parser > const& b); + +////////////////////////////////// +template +chset +operator|(negated_char_parser > const& a, chset const& b); + +////////////////////////////////// +template +chset +operator&(negated_char_parser > const& a, chset const& b); + +////////////////////////////////// +template +chset +operator-(negated_char_parser > const& a, chset const& b); + +////////////////////////////////// +template +chset +operator^(negated_char_parser > const& a, chset const& b); + +/////////////////////////////////////////////////////////////////////////////// +// +// literal primitives <--> chset free operators +// +// Where a is a chset and b is a literal primitive, +// and vice-versa, implements: +// +// a | b, a & b, a - b, a ^ b +// +/////////////////////////////////////////////////////////////////////////////// +template +chset +operator|(chset const& a, CharT b); + +////////////////////////////////// +template +chset +operator&(chset const& a, CharT b); + +////////////////////////////////// +template +chset +operator-(chset const& a, CharT b); + +////////////////////////////////// +template +chset +operator^(chset const& a, CharT b); + +////////////////////////////////// +template +chset +operator|(CharT a, chset const& b); + +////////////////////////////////// +template +chset +operator&(CharT a, chset const& b); + +////////////////////////////////// +template +chset +operator-(CharT a, chset const& b); + +////////////////////////////////// +template +chset +operator^(CharT a, chset const& b); + +/////////////////////////////////////////////////////////////////////////////// +// +// anychar_parser <--> chset free operators +// +// Where a is chset and b is a anychar_parser, and vice-versa, implements: +// +// a | b, a & b, a - b, a ^ b +// +/////////////////////////////////////////////////////////////////////////////// +template +chset +operator|(chset const& a, anychar_parser b); + +////////////////////////////////// +template +chset +operator&(chset const& a, anychar_parser b); + +////////////////////////////////// +template +chset +operator-(chset const& a, anychar_parser b); + +////////////////////////////////// +template +chset +operator^(chset const& a, anychar_parser b); + +////////////////////////////////// +template +chset +operator|(anychar_parser a, chset const& b); + +////////////////////////////////// +template +chset +operator&(anychar_parser a, chset const& b); + +////////////////////////////////// +template +chset +operator-(anychar_parser a, chset const& b); + +////////////////////////////////// +template +chset +operator^(anychar_parser a, chset const& b); + +/////////////////////////////////////////////////////////////////////////////// +// +// nothing_parser <--> chset free operators +// +// Where a is chset and b is nothing_parser, and vice-versa, implements: +// +// a | b, a & b, a - b, a ^ b +// +/////////////////////////////////////////////////////////////////////////////// +template +chset +operator|(chset const& a, nothing_parser b); + +////////////////////////////////// +template +chset +operator&(chset const& a, nothing_parser b); + +////////////////////////////////// +template +chset +operator-(chset const& a, nothing_parser b); + +////////////////////////////////// +template +chset +operator^(chset const& a, nothing_parser b); + +////////////////////////////////// +template +chset +operator|(nothing_parser a, chset const& b); + +////////////////////////////////// +template +chset +operator&(nothing_parser a, chset const& b); + +////////////////////////////////// +template +chset +operator-(nothing_parser a, chset const& b); + +////////////////////////////////// +template +chset +operator^(nothing_parser a, chset const& b); + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif + +#include diff --git a/boost/boost/spirit/utility/confix.hpp b/boost/boost/spirit/utility/confix.hpp new file mode 100644 index 0000000000..d6b48c2e89 --- /dev/null +++ b/boost/boost/spirit/utility/confix.hpp @@ -0,0 +1,396 @@ +/*============================================================================= + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_CONFIX_HPP +#define BOOST_SPIRIT_CONFIX_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// confix_parser class +// +// Parses a sequence of 3 sub-matches. This class may +// be used to parse structures, where the opening part is possibly +// contained in the expression part and the whole sequence is only +// parsed after seeing the closing part matching the first opening +// subsequence. Example: C-comments: +// +// /* This is a C-comment */ +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct confix_parser_gen; + +template < + typename OpenT, typename ExprT, typename CloseT, typename CategoryT, + typename NestedT = non_nested, typename LexemeT = non_lexeme +> +struct confix_parser : + public parser< + confix_parser + > +{ + typedef + confix_parser + self_t; + + confix_parser(OpenT const &open_, ExprT const &expr_, CloseT const &close_) + : open(open_), expr(expr_), close(close_) + {} + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + return impl::confix_parser_type:: + parse(NestedT(), LexemeT(), *this, scan, open, expr, close); + } + +private: + + typename as_parser::type::embed_t open; + typename as_parser::type::embed_t expr; + typename as_parser::type::embed_t close; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Confix parser generator template +// +// This is a helper for generating a correct confix_parser<> from +// auxiliary parameters. There are the following types supported as +// parameters yet: parsers, single characters and strings (see +// as_parser). +// +// If the body parser is an action_parser_category type parser (a parser +// with an attached semantic action) we have to do something special. This +// happens, if the user wrote something like: +// +// confix_p(open, body[f], close) +// +// where 'body' is the parser matching the body of the confix sequence +// and 'f' is a functor to be called after matching the body. If we would +// do nothing, the resulting code would parse the sequence as follows: +// +// start >> (body[f] - close) >> close +// +// what in most cases is not what the user expects. +// (If this _is_ what you've expected, then please use the confix_p +// generator function 'direct()', which will inhibit +// re-attaching the actor to the body parser). +// +// To make the confix parser behave as expected: +// +// start >> (body - close)[f] >> close +// +// the actor attached to the 'body' parser has to be re-attached to the +// (body - close) parser construct, which will make the resulting confix +// parser 'do the right thing'. This refactoring is done by the help of +// the refactoring parsers (see the files refactoring.[hi]pp). +// +// Additionally special care must be taken, if the body parser is a +// unary_parser_category type parser as +// +// confix_p(open, *anychar_p, close) +// +// which without any refactoring would result in +// +// start >> (*anychar_p - close) >> close +// +// and will not give the expected result (*anychar_p will eat up all the +// input up to the end of the input stream). So we have to refactor this +// into: +// +// start >> *(anychar_p - close) >> close +// +// what will give the correct result. +// +// The case, where the body parser is a combination of the two mentioned +// problems (i.e. the body parser is a unary parser with an attached +// action), is handled accordingly too: +// +// confix_p(start, (*anychar_p)[f], end) +// +// will be parsed as expected: +// +// start >> (*(anychar_p - end))[f] >> end. +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct confix_parser_gen +{ + // Generic generator function for creation of concrete confix parsers + + template + confix_parser< + typename as_parser::type, + typename as_parser::type, + typename as_parser::type, + typename as_parser::type::parser_category_t, + NestedT, + LexemeT + > + operator()( + StartT const &start_, ExprT const &expr_, EndT const &end_) const + { + typedef typename as_parser::type start_t; + typedef typename as_parser::type expr_t; + typedef typename as_parser::type end_t; + typedef + typename as_parser::type::parser_category_t + parser_category_t; + + typedef + confix_parser< + start_t, expr_t, end_t, parser_category_t, NestedT, LexemeT + > + return_t; + + return return_t( + as_parser::convert(start_), + as_parser::convert(expr_), + as_parser::convert(end_) + ); + } + + // Generic generator function for creation of concrete confix parsers + // which have an action directly attached to the ExprT part of the + // parser (see comment above, no automatic refactoring) + + template + confix_parser< + typename as_parser::type, + typename as_parser::type, + typename as_parser::type, + plain_parser_category, // do not re-attach action + NestedT, + LexemeT + > + direct(StartT const &start_, ExprT const &expr_, EndT const &end_) const + { + typedef typename as_parser::type start_t; + typedef typename as_parser::type expr_t; + typedef typename as_parser::type end_t; + typedef plain_parser_category parser_category_t; + + typedef + confix_parser< + start_t, expr_t, end_t, parser_category_t, NestedT, LexemeT + > + return_t; + + return return_t( + as_parser::convert(start_), + as_parser::convert(expr_), + as_parser::convert(end_) + ); + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Predefined non_nested confix parser generators +// +/////////////////////////////////////////////////////////////////////////////// + +const confix_parser_gen confix_p = + confix_parser_gen(); + +/////////////////////////////////////////////////////////////////////////////// +// +// Comments are special types of confix parsers +// +// Comment parser generator template. This is a helper for generating a +// correct confix_parser<> from auxiliary parameters, which is able to +// parse comment constructs: (StartToken >> Comment text >> EndToken). +// +// There are the following types supported as parameters yet: parsers, +// single characters and strings (see as_parser). +// +// There are two diffenerent predefined comment parser generators +// (comment_p and comment_nest_p, see below), which may be used for +// creating special comment parsers in two different ways. +// +// If these are used with one parameter, a comment starting with the given +// first parser parameter up to the end of the line is matched. So for +// instance the following parser matches C++ style comments: +// +// comment_p("//"). +// +// If these are used with two parameters, a comment starting with the +// first parser parameter up to the second parser parameter is matched. +// For instance a C style comment parser should be constrcuted as: +// +// comment_p("/*", "*/"). +// +// Please note, that a comment is parsed implicitly as if the whole +// comment_p(...) statement were embedded into a lexeme_d[] directive. +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct comment_parser_gen +{ + // Generic generator function for creation of concrete comment parsers + // from an open token. The newline parser eol_p is used as the + // closing token. + + template + confix_parser< + typename as_parser::type, + kleene_star, + alternative, + unary_parser_category, // there is no action to re-attach + NestedT, + is_lexeme // insert implicit lexeme_d[] + > + operator() (StartT const &start_) const + { + typedef typename as_parser::type start_t; + typedef kleene_star expr_t; + typedef alternative end_t; + typedef unary_parser_category parser_category_t; + + typedef + confix_parser< + start_t, expr_t, end_t, parser_category_t, NestedT, is_lexeme + > + return_t; + + return return_t( + as_parser::convert(start_), + *anychar_p, + eol_p | end_p + ); + } + + // Generic generator function for creation of concrete comment parsers + // from an open and a close tokens. + + template + confix_parser< + typename as_parser::type, + kleene_star, + typename as_parser::type, + unary_parser_category, // there is no action to re-attach + NestedT, + is_lexeme // insert implicit lexeme_d[] + > + operator() (StartT const &start_, EndT const &end_) const + { + typedef typename as_parser::type start_t; + typedef kleene_star expr_t; + typedef typename as_parser::type end_t; + typedef unary_parser_category parser_category_t; + + typedef + confix_parser< + start_t, expr_t, end_t, parser_category_t, NestedT, is_lexeme + > + return_t; + + return return_t( + as_parser::convert(start_), + *anychar_p, + as_parser::convert(end_) + ); + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Predefined non_nested comment parser generator +// +/////////////////////////////////////////////////////////////////////////////// + +const comment_parser_gen comment_p = + comment_parser_gen(); + +/////////////////////////////////////////////////////////////////////////////// +// +// comment_nest_parser class +// +// Parses a nested comments. +// Example: nested PASCAL-comments: +// +// { This is a { nested } PASCAL-comment } +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct comment_nest_parser: + public parser > +{ + typedef comment_nest_parser self_t; + + comment_nest_parser(OpenT const &open_, CloseT const &close_): + open(open_), close(close_) + {} + + template + typename parser_result::type + parse(ScannerT const &scan) const + { + return do_parse( + open >> *(*this | (anychar_p - close)) >> close, + scan); + } + +private: + template + typename parser_result::type + do_parse(ParserT const &p, ScannerT const &scan) const + { + return + impl::contiguous_parser_parse< + BOOST_DEDUCED_TYPENAME parser_result::type + >(p, scan, scan); + } + + typename as_parser::type::embed_t open; + typename as_parser::type::embed_t close; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Predefined nested comment parser generator +// +/////////////////////////////////////////////////////////////////////////////// + +template +inline +comment_nest_parser< + typename as_parser::type, + typename as_parser::type +> + comment_nest_p(OpenT const &open, CloseT const &close) +{ + return + comment_nest_parser< + BOOST_DEDUCED_TYPENAME as_parser::type, + BOOST_DEDUCED_TYPENAME as_parser::type + >( + as_parser::convert(open), + as_parser::convert(close) + ); +} + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif diff --git a/boost/boost/spirit/utility/distinct.hpp b/boost/boost/spirit/utility/distinct.hpp new file mode 100644 index 0000000000..4e1625f08a --- /dev/null +++ b/boost/boost/spirit/utility/distinct.hpp @@ -0,0 +1,225 @@ +/*============================================================================= + Copyright (c) 1998-2003 Joel de Guzman + Copyright (c) 2003 Vaclav Vesely + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_DISTINCT_HPP) +#define BOOST_SPIRIT_DISTINCT_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace boost { + namespace spirit { +//----------------------------------------------------------------------------- +// distinct_parser class + +template > +class distinct_parser +{ +public: + typedef + contiguous< + sequence< + chseq, + negated_empty_match_parser< + TailT + > + > + > + result_t; + + distinct_parser() + : tail(chset()) + { + } + + explicit distinct_parser(parser const & tail_) + : tail(tail_.derived()) + { + } + + explicit distinct_parser(CharT const* letters) + : tail(chset_p(letters)) + { + } + + result_t operator()(CharT const* str) const + { + return lexeme_d[chseq_p(str) >> ~epsilon_p(tail)]; + } + + TailT tail; +}; + +//----------------------------------------------------------------------------- +// distinct_directive class + +template > +class distinct_directive +{ +public: + template + struct result { + typedef + contiguous< + sequence< + ParserT, + negated_empty_match_parser< + TailT + > + > + > + type; + }; + + distinct_directive() + : tail(chset()) + { + } + + explicit distinct_directive(CharT const* letters) + : tail(chset_p(letters)) + { + } + + explicit distinct_directive(parser const & tail_) + : tail(tail_.derived()) + { + } + + template + typename result::type>::type + operator[](ParserT const &subject) const + { + return + lexeme_d[as_parser::convert(subject) >> ~epsilon_p(tail)]; + } + + TailT tail; +}; + +//----------------------------------------------------------------------------- +// dynamic_distinct_parser class + +template > +class dynamic_distinct_parser +{ +public: + typedef typename ScannerT::value_t char_t; + + typedef + rule< + typename no_actions_scanner< + typename lexeme_scanner::type + >::type + > + tail_t; + + typedef + contiguous< + sequence< + chseq, + negated_empty_match_parser< + tail_t + > + > + > + result_t; + + dynamic_distinct_parser() + : tail(nothing_p) + { + } + + template + explicit dynamic_distinct_parser(parser const & tail_) + : tail(tail_.derived()) + { + } + + explicit dynamic_distinct_parser(char_t const* letters) + : tail(chset_p(letters)) + { + } + + result_t operator()(char_t const* str) const + { + return lexeme_d[chseq_p(str) >> ~epsilon_p(tail)]; + } + + tail_t tail; +}; + +//----------------------------------------------------------------------------- +// dynamic_distinct_directive class + +template > +class dynamic_distinct_directive +{ +public: + typedef typename ScannerT::value_t char_t; + + typedef + rule< + typename no_actions_scanner< + typename lexeme_scanner::type + >::type + > + tail_t; + + template + struct result { + typedef + contiguous< + sequence< + ParserT, + negated_empty_match_parser< + tail_t + > + > + > + type; + }; + + dynamic_distinct_directive() + : tail(nothing_p) + { + } + + template + explicit dynamic_distinct_directive(parser const & tail_) + : tail(tail_.derived()) + { + } + + explicit dynamic_distinct_directive(char_t const* letters) + : tail(chset_p(letters)) + { + } + + template + typename result::type>::type + operator[](ParserT const &subject) const + { + return + lexeme_d[as_parser::convert(subject) >> ~epsilon_p(tail)]; + } + + tail_t tail; +}; + +//----------------------------------------------------------------------------- + } // namespace spirit +} // namespace boost + +#endif // !defined(BOOST_SPIRIT_DISTINCT_HPP) diff --git a/boost/boost/spirit/utility/escape_char.hpp b/boost/boost/spirit/utility/escape_char.hpp new file mode 100644 index 0000000000..6adeeceeed --- /dev/null +++ b/boost/boost/spirit/utility/escape_char.hpp @@ -0,0 +1,177 @@ +/*============================================================================= + Copyright (c) 2001-2003 Daniel Nuffer + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_ESCAPE_CHAR_HPP +#define BOOST_SPIRIT_ESCAPE_CHAR_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include + +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// escape_char_action class +// +// Links an escape char parser with a user defined semantic action. +// The semantic action may be a function or a functor. A function +// should be compatible with the interface: +// +// void f(CharT ch); +// +// A functor should have a member operator() with a compatible signature +// as above. The matching character is passed into the function/functor. +// This is the default class that character parsers use when dealing with +// the construct: +// +// p[f] +// +// where p is a parser and f is a function or functor. +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename ParserT, typename ActionT, + unsigned long Flags, typename CharT +> +struct escape_char_action +: public unary > > +{ + typedef escape_char_action + self_t; + typedef action_parser_category parser_category_t; + typedef unary > base_t; + + template + struct result + { + typedef typename match_result::type type; + }; + + escape_char_action(ParserT const& p, ActionT const& a) + : base_t(p), actor(a) {} + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + return impl::escape_char_action_parse:: + parse(scan, *this); + } + + ActionT const& predicate() const { return actor; } + +private: + + ActionT actor; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// escape_char_parser class +// +// The escape_char_parser helps in conjunction with the escape_char_action +// template class (see above) in parsing escaped characters. There are two +// different variants of this parser: one for parsing C style escaped +// characters and one for parsing LEX style escaped characters. +// +// The C style escaped character parser is generated, when the template +// parameter 'Flags' is equal to 'c_escapes' (a constant defined in the +// file impl/escape_char.ipp). This parser recognizes all valid C escape +// character sequences: '\t', '\b', '\f', '\n', '\r', '\"', '\'', '\\' +// and the numeric style escapes '\120' (octal) and '\x2f' (hexadecimal) +// and converts these to their character equivalent, for instance the +// sequence of a backslash and a 'b' is parsed as the character '\b'. +// All other escaped characters are rejected by this parser. +// +// The LEX style escaped character parser is generated, when the template +// parameter 'Flags' is equal to 'lex_escapes' (a constant defined in the +// file impl/escape_char.ipp). This parser recognizes all the C style +// escaped character sequences (as described above) and additionally +// does not reject all other escape sequences. All not mentioned escape +// sequences are converted by the parser to the plain character, for +// instance '\a' will be parsed as 'a'. +// +// All not escaped characters are parsed without modification. +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct escape_char_action_parser_gen; + +template +struct escape_char_parser : + public parser > { + + // only the values c_escapes and lex_escapes are valid for Flags + BOOST_STATIC_ASSERT(Flags == c_escapes || Flags == lex_escapes); + + typedef escape_char_parser self_t; + typedef + escape_char_action_parser_gen + action_parser_generator_t; + + template + struct result { + + typedef typename match_result::type type; + }; + + template + escape_char_action + operator[](ActionT const& actor) const + { + return escape_char_action(*this, actor); + } + + template + typename parser_result::type + parse(ScannerT const &scan) const + { + return impl::escape_char_parse::parse(scan, *this); + } +}; + +template +struct escape_char_action_parser_gen { + + template + static escape_char_action + generate (ParserT const &p, ActionT const &actor) + { + typedef + escape_char_action + action_parser_t; + return action_parser_t(p, actor); + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// predefined escape_char_parser objects +// +// These objects should be used for generating correct escaped character +// parsers. +// +/////////////////////////////////////////////////////////////////////////////// +const escape_char_parser lex_escape_ch_p = + escape_char_parser(); + +const escape_char_parser c_escape_ch_p = + escape_char_parser(); + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif diff --git a/boost/boost/spirit/utility/flush_multi_pass.hpp b/boost/boost/spirit/utility/flush_multi_pass.hpp new file mode 100644 index 0000000000..c33ea0a446 --- /dev/null +++ b/boost/boost/spirit/utility/flush_multi_pass.hpp @@ -0,0 +1,73 @@ +/*============================================================================= + Copyright (c) 2001-2003 Daniel Nuffer + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP +#define BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + + namespace impl { + + template + void flush_iterator(T &) {} + + template + void flush_iterator(boost::spirit::multi_pass< + T1, T2, T3, T4, boost::spirit::multi_pass_policies::std_deque> &i) + { + i.clear_queue(); + } + + } // namespace impl + + /////////////////////////////////////////////////////////////////////////// + // + // flush_multi_pass_parser + // + // The flush_multi_pass_parser flushes an underlying + // multi_pass_iterator during the normal parsing process. This may + // be used at certain points during the parsing process, when it is + // clear, that no backtracking is needed anymore and the input + // gathered so far may be discarded. + // + /////////////////////////////////////////////////////////////////////////// + class flush_multi_pass_parser + : public parser + { + public: + typedef flush_multi_pass_parser this_t; + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + impl::flush_iterator(scan.first); + return scan.empty_match(); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // predefined flush_multi_pass_p object + // + // This object should may used to flush a multi_pass_iterator along + // the way during the normal parsing process. + // + /////////////////////////////////////////////////////////////////////////// + + flush_multi_pass_parser const + flush_multi_pass_p = flush_multi_pass_parser(); + +}} // namespace boost::spirit + +#endif // BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP diff --git a/boost/boost/spirit/utility/functor_parser.hpp b/boost/boost/spirit/utility/functor_parser.hpp new file mode 100644 index 0000000000..fe72d4e313 --- /dev/null +++ b/boost/boost/spirit/utility/functor_parser.hpp @@ -0,0 +1,67 @@ +/*============================================================================= + Copyright (c) 2002-2003 Joel de Guzman + Copyright (c) 2002-2003 Juan Carlos Arevalo-Baeza + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_FUNCTOR_PARSER_HPP +#define BOOST_SPIRIT_FUNCTOR_PARSER_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // + // functor_parser class + // + // Once a functor parser has been defined, you can build a real + // parser from it by passing it to this class as the template + // parameter. + // + /////////////////////////////////////////////////////////////////////////// + template < class FunctorT > + struct functor_parser : public parser > + { + FunctorT functor; + + functor_parser(): functor() {} + functor_parser(FunctorT const& functor_): functor(functor_) {} + + typedef typename FunctorT::result_t functor_result_t; + typedef functor_parser self_t; + + template + struct result + { + typedef typename match_result::type + type; + }; + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + typedef typename parser_result::type result_t; + typedef typename ScannerT::value_t value_t; + typedef typename ScannerT::iterator_t iterator_t; + + iterator_t const s(scan.first); + functor_result_t result; + std::ptrdiff_t len = functor(scan, result); + + if (len < 0) + return scan.no_match(); + else + return scan.create_match(std::size_t(len), result, s, scan.first); + } + }; + +}} // namespace boost::spirit + +#endif diff --git a/boost/boost/spirit/utility/impl/chset.ipp b/boost/boost/spirit/utility/impl/chset.ipp new file mode 100644 index 0000000000..91d11a4dcb --- /dev/null +++ b/boost/boost/spirit/utility/impl/chset.ipp @@ -0,0 +1,362 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2001-2003 Daniel Nuffer + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_CHSET_IPP +#define BOOST_SPIRIT_CHSET_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// chset class +// +/////////////////////////////////////////////////////////////////////////////// +namespace utility { namespace impl { + template + inline void + detach(boost::shared_ptr >& ptr) + { + if (!ptr.unique()) + ptr = boost::shared_ptr > + (new basic_chset(*ptr)); + } + + template + inline void + detach_clear(boost::shared_ptr >& ptr) + { + if (ptr.unique()) + ptr->clear(); + else + ptr.reset(new basic_chset()); + } + + template + void construct_chset(boost::shared_ptr >& ptr, + CharT2 const* definition) + { + CharT2 ch = *definition++; + while (ch) + { + CharT2 next = *definition++; + if (next == '-') + { + next = *definition++; + if (next == 0) + { + ptr->set(ch); + ptr->set('-'); + break; + } + ptr->set(ch, next); + } + else + { + ptr->set(ch); + } + ch = next; + } + } + + ////////////////////////////////// + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + + template + void chset_negated_set(boost::shared_ptr > &ptr, chlit const &ch, + FakeT) + { + if(ch.ch != (std::numeric_limits::min)()) { + ptr->set((std::numeric_limits::min)(), ch.ch - 1); + } + if(ch.ch != (std::numeric_limits::max)()) { + ptr->set(ch.ch + 1, (std::numeric_limits::max)()); + } + } + + template + void chset_negated_set(boost::shared_ptr > &ptr, + spirit::range const &rng, FakeT) + { + if(rng.first != (std::numeric_limits::min)()) { + ptr->set((std::numeric_limits::min)(), rng.first - 1); + } + if(rng.last != (std::numeric_limits::max)()) { + ptr->set(rng.last + 1, (std::numeric_limits::max)()); + } + } + +#endif // BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +////////////////////////////////// + +}} // namespace utility::impl + +template +inline chset::chset() +: ptr(new basic_chset()) {} + +template +inline chset::chset(chset const& arg_) +: ptr(new basic_chset(*arg_.ptr)) {} + +template +inline chset::chset(CharT arg_) +: ptr(new basic_chset()) +{ ptr->set(arg_); } + +template +inline chset::chset(anychar_parser /*arg*/) +: ptr(new basic_chset()) +{ + ptr->set( + (std::numeric_limits::min)(), + (std::numeric_limits::max)() + ); +} + +template +inline chset::chset(nothing_parser arg_) +: ptr(new basic_chset()) {} + +template +inline chset::chset(chlit const& arg_) +: ptr(new basic_chset()) +{ ptr->set(arg_.ch); } + +template +inline chset::chset(range const& arg_) +: ptr(new basic_chset()) +{ ptr->set(arg_.first, arg_.last); } + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +template +inline chset::chset(negated_char_parser > const& arg_) +: ptr(new basic_chset()) +{ + set(arg_); +} + +template +inline chset::chset(negated_char_parser > const& arg_) +: ptr(new basic_chset()) +{ + set(arg_); +} + +#endif // !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +template +inline chset::~chset() {} + +template +inline chset& +chset::operator=(chset const& rhs) +{ + ptr = rhs.ptr; + return *this; +} + +template +inline chset& +chset::operator=(CharT rhs) +{ + utility::impl::detach_clear(ptr); + ptr->set(rhs); + return *this; +} + +template +inline chset& +chset::operator=(anychar_parser rhs) +{ + utility::impl::detach_clear(ptr); + ptr->set( + (std::numeric_limits::min)(), + (std::numeric_limits::max)() + ); + return *this; +} + +template +inline chset& +chset::operator=(nothing_parser rhs) +{ + utility::impl::detach_clear(ptr); + return *this; +} + +template +inline chset& +chset::operator=(chlit const& rhs) +{ + utility::impl::detach_clear(ptr); + ptr->set(rhs.ch); + return *this; +} + +template +inline chset& +chset::operator=(range const& rhs) +{ + utility::impl::detach_clear(ptr); + ptr->set(rhs.first, rhs.last); + return *this; +} + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +template +inline chset& +chset::operator=(negated_char_parser > const& rhs) +{ + utility::impl::detach_clear(ptr); + set(rhs); + return *this; +} + +template +inline chset& +chset::operator=(negated_char_parser > const& rhs) +{ + utility::impl::detach_clear(ptr); + set(rhs); + return *this; +} + +#endif // !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +template +inline void +chset::set(range const& arg_) +{ + utility::impl::detach(ptr); + ptr->set(arg_.first, arg_.last); +} + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +template +inline void +chset::set(negated_char_parser > const& arg_) +{ + utility::impl::detach(ptr); + + if(arg_.positive.ch != (std::numeric_limits::min)()) { + ptr->set((std::numeric_limits::min)(), arg_.positive.ch - 1); + } + if(arg_.positive.ch != (std::numeric_limits::max)()) { + ptr->set(arg_.positive.ch + 1, (std::numeric_limits::max)()); + } +} + +template +inline void +chset::set(negated_char_parser > const& arg_) +{ + utility::impl::detach(ptr); + + if(arg_.positive.first != (std::numeric_limits::min)()) { + ptr->set((std::numeric_limits::min)(), arg_.positive.first - 1); + } + if(arg_.positive.last != (std::numeric_limits::max)()) { + ptr->set(arg_.positive.last + 1, (std::numeric_limits::max)()); + } +} + +#endif // !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +template +inline void +chset::clear(range const& arg_) +{ + utility::impl::detach(ptr); + ptr->clear(arg_.first, arg_.last); +} + +template +inline void +chset::clear(negated_char_parser > const& arg_) +{ + utility::impl::detach(ptr); + + if(arg_.positive.first != (std::numeric_limits::min)()) { + ptr->clear((std::numeric_limits::min)(), arg_.positive.first - 1); + } + if(arg_.positive.last != (std::numeric_limits::max)()) { + ptr->clear(arg_.positive.last + 1, (std::numeric_limits::max)()); + } +} + +template +inline bool +chset::test(CharT ch) const +{ return ptr->test(ch); } + +template +inline chset& +chset::inverse() +{ + utility::impl::detach(ptr); + ptr->inverse(); + return *this; +} + +template +inline void +chset::swap(chset& x) +{ ptr.swap(x.ptr); } + +template +inline chset& +chset::operator|=(chset const& x) +{ + utility::impl::detach(ptr); + *ptr |= *x.ptr; + return *this; +} + +template +inline chset& +chset::operator&=(chset const& x) +{ + utility::impl::detach(ptr); + *ptr &= *x.ptr; + return *this; +} + +template +inline chset& +chset::operator-=(chset const& x) +{ + utility::impl::detach(ptr); + *ptr -= *x.ptr; + return *this; +} + +template +inline chset& +chset::operator^=(chset const& x) +{ + utility::impl::detach(ptr); + *ptr ^= *x.ptr; + return *this; +} + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif + diff --git a/boost/boost/spirit/utility/impl/chset/basic_chset.hpp b/boost/boost/spirit/utility/impl/chset/basic_chset.hpp new file mode 100644 index 0000000000..57413dc6ca --- /dev/null +++ b/boost/boost/spirit/utility/impl/chset/basic_chset.hpp @@ -0,0 +1,102 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2001-2003 Daniel Nuffer + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_BASIC_CHSET_HPP +#define BOOST_SPIRIT_BASIC_CHSET_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // + // basic_chset: basic character set implementation using range_run + // + /////////////////////////////////////////////////////////////////////////// + template + class basic_chset + { + public: + basic_chset(); + basic_chset(basic_chset const& arg_); + + bool test(CharT v) const; + void set(CharT from, CharT to); + void set(CharT c); + void clear(CharT from, CharT to); + void clear(CharT c); + void clear(); + + void inverse(); + void swap(basic_chset& x); + + basic_chset& operator|=(basic_chset const& x); + basic_chset& operator&=(basic_chset const& x); + basic_chset& operator-=(basic_chset const& x); + basic_chset& operator^=(basic_chset const& x); + + private: utility::impl::range_run rr; + }; + + #if (CHAR_BIT == 8) + + /////////////////////////////////////////////////////////////////////////// + // + // basic_chset: specializations for 8 bit chars using std::bitset + // + /////////////////////////////////////////////////////////////////////////// + template + class basic_chset_8bit { + + public: + basic_chset_8bit(); + basic_chset_8bit(basic_chset_8bit const& arg_); + + bool test(CharT v) const; + void set(CharT from, CharT to); + void set(CharT c); + void clear(CharT from, CharT to); + void clear(CharT c); + void clear(); + + void inverse(); + void swap(basic_chset_8bit& x); + + basic_chset_8bit& operator|=(basic_chset_8bit const& x); + basic_chset_8bit& operator&=(basic_chset_8bit const& x); + basic_chset_8bit& operator-=(basic_chset_8bit const& x); + basic_chset_8bit& operator^=(basic_chset_8bit const& x); + + private: std::bitset<256> bset; + }; + + ///////////////////////////////// + template <> + class basic_chset + : public basic_chset_8bit {}; + + ///////////////////////////////// + template <> + class basic_chset + : public basic_chset_8bit {}; + + ///////////////////////////////// + template <> + class basic_chset + : public basic_chset_8bit {}; + +#endif + +}} // namespace boost::spirit + +#endif + +#include diff --git a/boost/boost/spirit/utility/impl/chset/basic_chset.ipp b/boost/boost/spirit/utility/impl/chset/basic_chset.ipp new file mode 100644 index 0000000000..9370e3f8ad --- /dev/null +++ b/boost/boost/spirit/utility/impl/chset/basic_chset.ipp @@ -0,0 +1,241 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2001-2003 Daniel Nuffer + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_BASIC_CHSET_IPP +#define BOOST_SPIRIT_BASIC_CHSET_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// basic_chset: character set implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +inline basic_chset::basic_chset() {} + +////////////////////////////////// +template +inline basic_chset::basic_chset(basic_chset const& arg_) +: rr(arg_.rr) {} + +////////////////////////////////// +template +inline bool +basic_chset::test(CharT v) const +{ return rr.test(v); } + +////////////////////////////////// +template +inline void +basic_chset::set(CharT from, CharT to) +{ rr.set(utility::impl::range(from, to)); } + +////////////////////////////////// +template +inline void +basic_chset::set(CharT c) +{ rr.set(utility::impl::range(c, c)); } + +////////////////////////////////// +template +inline void +basic_chset::clear(CharT from, CharT to) +{ rr.clear(utility::impl::range(from, to)); } + +////////////////////////////////// +template +inline void +basic_chset::clear() +{ rr.clear(); } + +///////////////////////////////// +template +inline void +basic_chset::inverse() +{ + basic_chset inv; + inv.set( + (std::numeric_limits::min)(), + (std::numeric_limits::max)() + ); + inv -= *this; + swap(inv); +} + +///////////////////////////////// +template +inline void +basic_chset::swap(basic_chset& x) +{ rr.swap(x.rr); } + +///////////////////////////////// +template +inline basic_chset& +basic_chset::operator|=(basic_chset const& x) +{ + typedef typename utility::impl::range_run::const_iterator const_iterator; + for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter) + rr.set(*iter); + return *this; +} + +///////////////////////////////// +template +inline basic_chset& +basic_chset::operator&=(basic_chset const& x) +{ + basic_chset inv; + inv.set( + (std::numeric_limits::min)(), + (std::numeric_limits::max)() + ); + inv -= x; + *this -= inv; + return *this; +} + +///////////////////////////////// +template +inline basic_chset& +basic_chset::operator-=(basic_chset const& x) +{ + typedef typename utility::impl::range_run::const_iterator const_iterator; + for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter) + rr.clear(*iter); + return *this; +} + +///////////////////////////////// +template +inline basic_chset& +basic_chset::operator^=(basic_chset const& x) +{ + basic_chset bma = x; + bma -= *this; + *this -= x; + *this |= bma; + return *this; +} + +#if (CHAR_BIT == 8) + +/////////////////////////////////////////////////////////////////////////////// +// +// basic_chset: specializations for 8 bit chars using std::bitset +// +/////////////////////////////////////////////////////////////////////////////// +template +inline basic_chset_8bit::basic_chset_8bit() {} + +///////////////////////////////// +template +inline basic_chset_8bit::basic_chset_8bit(basic_chset_8bit const& arg_) +: bset(arg_.bset) {} + +///////////////////////////////// +template +inline bool +basic_chset_8bit::test(CharT v) const +{ return bset.test((unsigned char)v); } + +///////////////////////////////// +template +inline void +basic_chset_8bit::set(CharT from, CharT to) +{ + for (int i = from; i <= to; ++i) + bset.set((unsigned char)i); +} + +///////////////////////////////// +template +inline void +basic_chset_8bit::set(CharT c) +{ bset.set((unsigned char)c); } + +///////////////////////////////// +template +inline void +basic_chset_8bit::clear(CharT from, CharT to) +{ + for (int i = from; i <= to; ++i) + bset.reset((unsigned char)i); +} + +///////////////////////////////// +template +inline void +basic_chset_8bit::clear(CharT c) +{ bset.reset((unsigned char)c); } + +///////////////////////////////// +template +inline void +basic_chset_8bit::clear() +{ bset.reset(); } + +///////////////////////////////// +template +inline void +basic_chset_8bit::inverse() +{ bset.flip(); } + +///////////////////////////////// +template +inline void +basic_chset_8bit::swap(basic_chset_8bit& x) +{ std::swap(bset, x.bset); } + +///////////////////////////////// +template +inline basic_chset_8bit& +basic_chset_8bit::operator|=(basic_chset_8bit const& x) +{ + bset |= x.bset; + return *this; +} + +///////////////////////////////// +template +inline basic_chset_8bit& +basic_chset_8bit::operator&=(basic_chset_8bit const& x) +{ + bset &= x.bset; + return *this; +} + +///////////////////////////////// +template +inline basic_chset_8bit& +basic_chset_8bit::operator-=(basic_chset_8bit const& x) +{ + bset &= ~x.bset; + return *this; +} + +///////////////////////////////// +template +inline basic_chset_8bit& +basic_chset_8bit::operator^=(basic_chset_8bit const& x) +{ + bset ^= x.bset; + return *this; +} + +#endif +}} // namespace boost::spirit + +#endif + diff --git a/boost/boost/spirit/utility/impl/chset/range_run.hpp b/boost/boost/spirit/utility/impl/chset/range_run.hpp new file mode 100644 index 0000000000..2a9318f933 --- /dev/null +++ b/boost/boost/spirit/utility/impl/chset/range_run.hpp @@ -0,0 +1,111 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_RANGE_RUN_HPP +#define BOOST_SPIRIT_RANGE_RUN_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { namespace utility { namespace impl { + + /////////////////////////////////////////////////////////////////////////// + // + // range class + // + // Implements a closed range of values. This class is used in + // the implementation of the range_run class. + // + // { Low level implementation detail } + // { Not to be confused with boost::spirit::range } + // + /////////////////////////////////////////////////////////////////////////// + template + struct range { + + range(CharT first, CharT last); + + bool is_valid() const; + bool includes(CharT v) const; + bool includes(range const& r) const; + bool overlaps(range const& r) const; + void merge(range const& r); + + CharT first; + CharT last; + }; + + ////////////////////////////////// + template + struct range_char_compare { + + bool operator()(range const& x, const CharT y) const + { return x.first < y; } + + bool operator()(const CharT x, range const& y) const + { return x < y.first; } + }; + + ////////////////////////////////// + template + struct range_compare { + + bool operator()(range const& x, range const& y) const + { return x.first < y.first; } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // range_run + // + // An implementation of a sparse bit (boolean) set. The set uses + // a sorted vector of disjoint ranges. This class implements the + // bare minimum essentials from which the full range of set + // operators can be implemented. The set is constructed from + // ranges. Internally, adjacent or overlapping ranges are + // coalesced. + // + // range_runs are very space-economical in situations where there + // are lots of ranges and a few individual disjoint values. + // Searching is O(log n) where n is the number of ranges. + // + // { Low level implementation detail } + // + /////////////////////////////////////////////////////////////////////////// + template + class range_run { + + public: + + typedef range range_t; + typedef std::vector run_t; + typedef typename run_t::iterator iterator; + typedef typename run_t::const_iterator const_iterator; + + void swap(range_run& rr); + bool test(CharT v) const; + void set(range_t const& r); + void clear(range_t const& r); + void clear(); + + const_iterator begin() const; + const_iterator end() const; + + private: + + void merge(iterator iter, range_t const& r); + + run_t run; + }; + +}}}} // namespace boost::spirit::utility::impl + +#endif + +#include diff --git a/boost/boost/spirit/utility/impl/chset/range_run.ipp b/boost/boost/spirit/utility/impl/chset/range_run.ipp new file mode 100644 index 0000000000..45491bc3fb --- /dev/null +++ b/boost/boost/spirit/utility/impl/chset/range_run.ipp @@ -0,0 +1,212 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_RANGE_RUN_IPP +#define BOOST_SPIRIT_RANGE_RUN_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include // for std::lower_bound +#include // for BOOST_SPIRIT_ASSERT +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + + namespace utility { namespace impl { + + /////////////////////////////////////////////////////////////////////// + // + // range class implementation + // + /////////////////////////////////////////////////////////////////////// + template + inline range::range(CharT first_, CharT last_) + : first(first_), last(last_) {} + + ////////////////////////////////// + template + inline bool + range::is_valid() const + { return first <= last; } + + ////////////////////////////////// + template + inline bool + range::includes(range const& r) const + { return (first <= r.first) && (last >= r.last); } + + ////////////////////////////////// + template + inline bool + range::includes(CharT v) const + { return (first <= v) && (last >= v); } + + ////////////////////////////////// + template + inline bool + range::overlaps(range const& r) const + { + CharT decr_first = + first == (std::numeric_limits::min)() ? first : first-1; + CharT incr_last = + last == (std::numeric_limits::max)() ? last : last+1; + + return (decr_first <= r.last) && (incr_last >= r.first); + } + + ////////////////////////////////// + template + inline void + range::merge(range const& r) + { + first = (std::min)(first, r.first); + last = (std::max)(last, r.last); + } + + /////////////////////////////////////////////////////////////////////// + // + // range_run class implementation + // + /////////////////////////////////////////////////////////////////////// + template + inline bool + range_run::test(CharT v) const + { + if (!run.empty()) + { + const_iterator iter = + std::lower_bound( + run.begin(), run.end(), v, + range_char_compare() + ); + + if (iter != run.end() && iter->includes(v)) + return true; + if (iter != run.begin()) + return (--iter)->includes(v); + } + return false; + } + + ////////////////////////////////// + template + inline void + range_run::swap(range_run& rr) + { run.swap(rr.run); } + + ////////////////////////////////// + template + void + range_run::merge(iterator iter, range const& r) + { + iter->merge(r); + iterator i = iter + 1; + + while (i != run.end() && iter->overlaps(*i)) + iter->merge(*i++); + + run.erase(iter+1, i); + } + + ////////////////////////////////// + template + void + range_run::set(range const& r) + { + BOOST_SPIRIT_ASSERT(r.is_valid()); + if (!run.empty()) + { + iterator iter = + std::lower_bound( + run.begin(), run.end(), r, + range_compare() + ); + + if (iter != run.end() && iter->includes(r) || + ((iter != run.begin()) && (iter - 1)->includes(r))) + return; + + if (iter != run.begin() && (iter - 1)->overlaps(r)) + merge(--iter, r); + + else if (iter != run.end() && iter->overlaps(r)) + merge(iter, r); + + else + run.insert(iter, r); + } + else + { + run.push_back(r); + } + } + + ////////////////////////////////// + template + void + range_run::clear(range const& r) + { + BOOST_SPIRIT_ASSERT(r.is_valid()); + if (!run.empty()) + { + iterator iter = + std::lower_bound( + run.begin(), run.end(), r, + range_compare() + ); + + iterator left_iter; + + if ((iter != run.begin()) && + (left_iter = (iter - 1))->includes(r.first)) + if (left_iter->last > r.last) + { + CharT save_last = left_iter->last; + left_iter->last = r.first-1; + run.insert(iter, range(r.last+1, save_last)); + return; + } + else + { + left_iter->last = r.first-1; + } + + iterator i = iter; + while (i != run.end() && r.includes(*i)) + i++; + if (i != run.end() && i->includes(r.last)) + i->first = r.last+1; + run.erase(iter, i); + } + } + + ////////////////////////////////// + template + inline void + range_run::clear() + { run.clear(); } + + ////////////////////////////////// + template + inline typename range_run::const_iterator + range_run::begin() const + { return run.begin(); } + + ////////////////////////////////// + template + inline typename range_run::const_iterator + range_run::end() const + { return run.end(); } + + }} // namespace utility::impl + +}} // namespace boost::spirit + +#endif diff --git a/boost/boost/spirit/utility/impl/chset_operators.ipp b/boost/boost/spirit/utility/impl/chset_operators.ipp new file mode 100644 index 0000000000..dddbcea07a --- /dev/null +++ b/boost/boost/spirit/utility/impl/chset_operators.ipp @@ -0,0 +1,662 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_CHSET_OPERATORS_IPP +#define BOOST_SPIRIT_CHSET_OPERATORS_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +inline chset +operator|(chset const& a, chset const& b) +{ + return chset(a) |= b; +} + +////////////////////////////////// +template +inline chset +operator-(chset const& a, chset const& b) +{ + return chset(a) -= b; +} + +////////////////////////////////// +template +inline chset +operator~(chset const& a) +{ + return chset(a).inverse(); +} + +////////////////////////////////// +template +inline chset +operator&(chset const& a, chset const& b) +{ + return chset(a) &= b; +} + +////////////////////////////////// +template +inline chset +operator^(chset const& a, chset const& b) +{ + return chset(a) ^= b; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// range <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +inline chset +operator|(chset const& a, range const& b) +{ + chset a_(a); + a_.set(b); + return a_; +} + +////////////////////////////////// +template +inline chset +operator&(chset const& a, range const& b) +{ + chset a_(a); + if(b.first != (std::numeric_limits::min)()) { + a_.clear(range((std::numeric_limits::min)(), b.first - 1)); + } + if(b.last != (std::numeric_limits::max)()) { + a_.clear(range(b.last + 1, (std::numeric_limits::max)())); + } + return a_; +} + +////////////////////////////////// +template +inline chset +operator-(chset const& a, range const& b) +{ + chset a_(a); + a_.clear(b); + return a_; +} + +////////////////////////////////// +template +inline chset +operator^(chset const& a, range const& b) +{ + return a ^ chset(b); +} + +////////////////////////////////// +template +inline chset +operator|(range const& a, chset const& b) +{ + chset b_(b); + b_.set(a); + return b_; +} + +////////////////////////////////// +template +inline chset +operator&(range const& a, chset const& b) +{ + chset b_(b); + if(a.first != (std::numeric_limits::min)()) { + b_.clear(range((std::numeric_limits::min)(), a.first - 1)); + } + if(a.last != (std::numeric_limits::max)()) { + b_.clear(range(a.last + 1, (std::numeric_limits::max)())); + } + return b_; +} + +////////////////////////////////// +template +inline chset +operator-(range const& a, chset const& b) +{ + return chset(a) - b; +} + +////////////////////////////////// +template +inline chset +operator^(range const& a, chset const& b) +{ + return chset(a) ^ b; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// literal primitives <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +inline chset +operator|(chset const& a, CharT b) +{ + return a | chset(b); +} + +////////////////////////////////// +template +inline chset +operator&(chset const& a, CharT b) +{ + return a & chset(b); +} + +////////////////////////////////// +template +inline chset +operator-(chset const& a, CharT b) +{ + return a - chset(b); +} + +////////////////////////////////// +template +inline chset +operator^(chset const& a, CharT b) +{ + return a ^ chset(b); +} + +////////////////////////////////// +template +inline chset +operator|(CharT a, chset const& b) +{ + return chset(a) | b; +} + +////////////////////////////////// +template +inline chset +operator&(CharT a, chset const& b) +{ + return chset(a) & b; +} + +////////////////////////////////// +template +inline chset +operator-(CharT a, chset const& b) +{ + return chset(a) - b; +} + +////////////////////////////////// +template +inline chset +operator^(CharT a, chset const& b) +{ + return chset(a) ^ b; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// chlit <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +inline chset +operator|(chset const& a, chlit const& b) +{ + return a | chset(b.ch); +} + +////////////////////////////////// +template +inline chset +operator&(chset const& a, chlit const& b) +{ + return a & chset(b.ch); +} + +////////////////////////////////// +template +inline chset +operator-(chset const& a, chlit const& b) +{ + return a - chset(b.ch); +} + +////////////////////////////////// +template +inline chset +operator^(chset const& a, chlit const& b) +{ + return a ^ chset(b.ch); +} + +////////////////////////////////// +template +inline chset +operator|(chlit const& a, chset const& b) +{ + return chset(a.ch) | b; +} + +////////////////////////////////// +template +inline chset +operator&(chlit const& a, chset const& b) +{ + return chset(a.ch) & b; +} + +////////////////////////////////// +template +inline chset +operator-(chlit const& a, chset const& b) +{ + return chset(a.ch) - b; +} + +////////////////////////////////// +template +inline chset +operator^(chlit const& a, chset const& b) +{ + return chset(a.ch) ^ b; +} + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +/////////////////////////////////////////////////////////////////////////////// +// +// negated_char_parser <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +inline chset +operator|(chset const& a, negated_char_parser const& b) +{ + return a | chset(b); +} + +////////////////////////////////// +template +inline chset +operator&(chset const& a, negated_char_parser const& b) +{ + return a & chset(b); +} + +////////////////////////////////// +template +inline chset +operator-(chset const& a, negated_char_parser const& b) +{ + return a - chset(b); +} + +////////////////////////////////// +template +inline chset +operator^(chset const& a, negated_char_parser const& b) +{ + return a ^ chset(b); +} + +////////////////////////////////// +template +inline chset +operator|(negated_char_parser const& a, chset const& b) +{ + return chset(a) | b; +} + +////////////////////////////////// +template +inline chset +operator&(negated_char_parser const& a, chset const& b) +{ + return chset(a) & b; +} + +////////////////////////////////// +template +inline chset +operator-(negated_char_parser const& a, chset const& b) +{ + return chset(a) - b; +} + +////////////////////////////////// +template +inline chset +operator^(negated_char_parser const& a, chset const& b) +{ + return chset(a) ^ b; +} + +#else // BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +/////////////////////////////////////////////////////////////////////////////// +// +// negated_char_parser <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +inline chset +operator|(chset const& a, negated_char_parser > const& b) +{ + return a | chset(b); +} + +////////////////////////////////// +template +inline chset +operator&(chset const& a, negated_char_parser > const& b) +{ + return a & chset(b); +} + +////////////////////////////////// +template +inline chset +operator-(chset const& a, negated_char_parser > const& b) +{ + return a - chset(b); +} + +////////////////////////////////// +template +inline chset +operator^(chset const& a, negated_char_parser > const& b) +{ + return a ^ chset(b); +} + +////////////////////////////////// +template +inline chset +operator|(negated_char_parser > const& a, chset const& b) +{ + return chset(a) | b; +} + +////////////////////////////////// +template +inline chset +operator&(negated_char_parser > const& a, chset const& b) +{ + return chset(a) & b; +} + +////////////////////////////////// +template +inline chset +operator-(negated_char_parser > const& a, chset const& b) +{ + return chset(a) - b; +} + +////////////////////////////////// +template +inline chset +operator^(negated_char_parser > const& a, chset const& b) +{ + return chset(a) ^ b; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// negated_char_parser <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +inline chset +operator|(chset const& a, negated_char_parser > const& b) +{ + return a | chset(b); +} + +////////////////////////////////// +template +inline chset +operator&(chset const& a, negated_char_parser > const& b) +{ + return a & chset(b); +} + +////////////////////////////////// +template +inline chset +operator-(chset const& a, negated_char_parser > const& b) +{ + return a - chset(b); +} + +////////////////////////////////// +template +inline chset +operator^(chset const& a, negated_char_parser > const& b) +{ + return a ^ chset(b); +} + +////////////////////////////////// +template +inline chset +operator|(negated_char_parser > const& a, chset const& b) +{ + return chset(a) | b; +} + +////////////////////////////////// +template +inline chset +operator&(negated_char_parser > const& a, chset const& b) +{ + return chset(a) & b; +} + +////////////////////////////////// +template +inline chset +operator-(negated_char_parser > const& a, chset const& b) +{ + return chset(a) - b; +} + +////////////////////////////////// +template +inline chset +operator^(negated_char_parser > const& a, chset const& b) +{ + return chset(a) ^ b; +} + +#endif // BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +/////////////////////////////////////////////////////////////////////////////// +// +// anychar_parser <--> chset free operators +// +// Where a is chset and b is a anychar_parser, and vice-versa, implements: +// +// a | b, a & b, a - b, a ^ b +// +/////////////////////////////////////////////////////////////////////////////// +namespace impl { + + template + inline boost::spirit::range const& + full() + { + static boost::spirit::range full_( + (std::numeric_limits::min)(), + (std::numeric_limits::max)()); + return full_; + } + + template + inline boost::spirit::range const& + empty() + { + static boost::spirit::range empty_; + return empty_; + } +} + +////////////////////////////////// +template +inline chset +operator|(chset const&, anychar_parser) +{ + return chset(impl::full()); +} + +////////////////////////////////// +template +inline chset +operator&(chset const& a, anychar_parser) +{ + return a; +} + +////////////////////////////////// +template +inline chset +operator-(chset const&, anychar_parser) +{ + return chset(); +} + +////////////////////////////////// +template +inline chset +operator^(chset const& a, anychar_parser) +{ + return ~a; +} + +////////////////////////////////// +template +inline chset +operator|(anychar_parser, chset const& /*b*/) +{ + return chset(impl::full()); +} + +////////////////////////////////// +template +inline chset +operator&(anychar_parser, chset const& b) +{ + return b; +} + +////////////////////////////////// +template +inline chset +operator-(anychar_parser, chset const& b) +{ + return ~b; +} + +////////////////////////////////// +template +inline chset +operator^(anychar_parser, chset const& b) +{ + return ~b; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// nothing_parser <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template +inline chset +operator|(chset const& a, nothing_parser) +{ + return a; +} + +////////////////////////////////// +template +inline chset +operator&(chset const& /*a*/, nothing_parser) +{ + return impl::empty(); +} + +////////////////////////////////// +template +inline chset +operator-(chset const& a, nothing_parser) +{ + return a; +} + +////////////////////////////////// +template +inline chset +operator^(chset const& a, nothing_parser) +{ + return a; +} + +////////////////////////////////// +template +inline chset +operator|(nothing_parser, chset const& b) +{ + return b; +} + +////////////////////////////////// +template +inline chset +operator&(nothing_parser, chset const& /*b*/) +{ + return impl::empty(); +} + +////////////////////////////////// +template +inline chset +operator-(nothing_parser, chset const& /*b*/) +{ + return impl::empty(); +} + +////////////////////////////////// +template +inline chset +operator^(nothing_parser, chset const& b) +{ + return b; +} + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif + diff --git a/boost/boost/spirit/utility/impl/confix.ipp b/boost/boost/spirit/utility/impl/confix.ipp new file mode 100644 index 0000000000..1b1b5dc21f --- /dev/null +++ b/boost/boost/spirit/utility/impl/confix.ipp @@ -0,0 +1,217 @@ +/*============================================================================= + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_CONFIX_IPP +#define BOOST_SPIRIT_CONFIX_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// Types to distinguish nested and non-nested confix parsers +// +/////////////////////////////////////////////////////////////////////////////// +struct is_nested {}; +struct non_nested {}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Types to distinguish between confix parsers, which are implicitly lexems +// and without this behaviour +// +/////////////////////////////////////////////////////////////////////////////// +struct is_lexeme {}; +struct non_lexeme {}; + +/////////////////////////////////////////////////////////////////////////////// +// +// confix_parser_type class implementation +// +/////////////////////////////////////////////////////////////////////////////// +namespace impl { + + /////////////////////////////////////////////////////////////////////////// + // implicitly insert a lexeme_d into the parsing process + + template + struct select_confix_parse_lexeme; + + template <> + struct select_confix_parse_lexeme { + + template + static typename parser_result::type + parse(ParserT const& p, ScannerT const& scan) + { + typedef typename parser_result::type result_t; + return contiguous_parser_parse(p, scan, scan); + } + }; + + template <> + struct select_confix_parse_lexeme { + + template + static typename parser_result::type + parse(ParserT const& p, ScannerT const& scan) + { + return p.parse(scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // parse confix sequences with refactoring + + template + struct select_confix_parse_refactor; + + template <> + struct select_confix_parse_refactor { + + template < + typename LexemeT, typename ParserT, typename ScannerT, + typename OpenT, typename ExprT, typename CloseT + > + static typename parser_result::type + parse( + LexemeT const &, ParserT const& this_, ScannerT const& scan, + OpenT const& open, ExprT const& expr, CloseT const& close) + { + typedef refactor_action_gen > refactor_t; + const refactor_t refactor_body_d = refactor_t(refactor_unary_d); + + return select_confix_parse_lexeme::parse(( + open + >> (this_ | refactor_body_d[expr - close]) + >> close + ), scan); + } + }; + + template <> + struct select_confix_parse_refactor { + + template < + typename LexemeT, typename ParserT, typename ScannerT, + typename OpenT, typename ExprT, typename CloseT + > + static typename parser_result::type + parse( + LexemeT const &, ParserT const& /*this_*/, ScannerT const& scan, + OpenT const& open, ExprT const& expr, CloseT const& close) + { + typedef refactor_action_gen > refactor_t; + const refactor_t refactor_body_d = refactor_t(refactor_unary_d); + + return select_confix_parse_lexeme::parse(( + open + >> refactor_body_d[expr - close] + >> close + ), scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // parse confix sequences without refactoring + + template + struct select_confix_parse_no_refactor; + + template <> + struct select_confix_parse_no_refactor { + + template < + typename LexemeT, typename ParserT, typename ScannerT, + typename OpenT, typename ExprT, typename CloseT + > + static typename parser_result::type + parse( + LexemeT const &, ParserT const& this_, ScannerT const& scan, + OpenT const& open, ExprT const& expr, CloseT const& close) + { + return select_confix_parse_lexeme::parse(( + open + >> (this_ | (expr - close)) + >> close + ), scan); + } + }; + + template <> + struct select_confix_parse_no_refactor { + + template < + typename LexemeT, typename ParserT, typename ScannerT, + typename OpenT, typename ExprT, typename CloseT + > + static typename parser_result::type + parse( + LexemeT const &, ParserT const & /*this_*/, ScannerT const& scan, + OpenT const& open, ExprT const& expr, CloseT const& close) + { + return select_confix_parse_lexeme::parse(( + open + >> (expr - close) + >> close + ), scan); + } + }; + + // the refactoring is handled by the refactoring parsers, so here there + // is no need to pay attention to these issues. + + template + struct confix_parser_type { + + template < + typename NestedT, typename LexemeT, + typename ParserT, typename ScannerT, + typename OpenT, typename ExprT, typename CloseT + > + static typename parser_result::type + parse( + NestedT const &, LexemeT const &lexeme, + ParserT const& this_, ScannerT const& scan, + OpenT const& open, ExprT const& expr, CloseT const& close) + { + return select_confix_parse_refactor:: + parse(lexeme, this_, scan, open, expr, close); + } + }; + + template <> + struct confix_parser_type { + + template < + typename NestedT, typename LexemeT, + typename ParserT, typename ScannerT, + typename OpenT, typename ExprT, typename CloseT + > + static typename parser_result::type + parse( + NestedT const &, LexemeT const &lexeme, + ParserT const& this_, ScannerT const& scan, + OpenT const& open, ExprT const& expr, CloseT const& close) + { + return select_confix_parse_no_refactor:: + parse(lexeme, this_, scan, open, expr, close); + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif + diff --git a/boost/boost/spirit/utility/impl/escape_char.ipp b/boost/boost/spirit/utility/impl/escape_char.ipp new file mode 100644 index 0000000000..ad8a59b682 --- /dev/null +++ b/boost/boost/spirit/utility/impl/escape_char.ipp @@ -0,0 +1,215 @@ +/*============================================================================= + Copyright (c) 2001-2003 Daniel Nuffer + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_ESCAPE_CHAR_IPP +#define BOOST_SPIRIT_ESCAPE_CHAR_IPP + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// escape_char_parser class +// +/////////////////////////////////////////////////////////////////////////////// + +const unsigned long c_escapes = 1; +const unsigned long lex_escapes = c_escapes << 1; + +////////////////////////////////// +namespace impl { + + ////////////////////////////////// +#if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310)) +#pragma warning(push) +#pragma warning(disable:4127) +#endif + template + struct escape_char_action_parse { + + template + static typename parser_result::type + parse(ScannerT const& scan, ParserT const &p) + { + // Actually decode the escape char. + typedef CharT char_t; + typedef typename ScannerT::iterator_t iterator_t; + typedef typename parser_result::type result_t; + + if (scan.first != scan.last) { + + iterator_t save = scan.first; + if (result_t hit = p.subject().parse(scan)) { + + char_t unescaped; + + scan.first = save; + if (*scan.first == '\\') { + + ++scan.first; + switch (*scan.first) { + case 'b': unescaped = '\b'; ++scan.first; break; + case 't': unescaped = '\t'; ++scan.first; break; + case 'n': unescaped = '\n'; ++scan.first; break; + case 'f': unescaped = '\f'; ++scan.first; break; + case 'r': unescaped = '\r'; ++scan.first; break; + case '"': unescaped = '"'; ++scan.first; break; + case '\'': unescaped = '\''; ++scan.first; break; + case '\\': unescaped = '\\'; ++scan.first; break; + + case 'x': case 'X': + { + char_t hex = 0; + char_t const lim = + (std::numeric_limits::max)() >> 4; + + ++scan.first; + while (scan.first != scan.last) + { + char_t c = *scan.first; + if (hex > lim && impl::isxdigit_(c)) + { + // overflow detected + scan.first = save; + return scan.no_match(); + } + if (impl::isdigit_(c)) + { + hex <<= 4; + hex |= c - '0'; + ++scan.first; + } + else if (impl::isxdigit_(c)) + { + hex <<= 4; + c = impl::toupper_(c); + hex |= c - 'A' + 0xA; + ++scan.first; + } + else + { + break; // reached the end of the number + } + } + unescaped = hex; + } + break; + + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + { + char_t oct = 0; + char_t const lim = + (std::numeric_limits::max)() >> 3; + while (scan.first != scan.last) + { + char_t c = *scan.first; + if (oct > lim && (c >= '0' && c <= '7')) + { + // overflow detected + scan.first = save; + return scan.no_match(); + } + + if (c >= '0' && c <= '7') + { + oct <<= 3; + oct |= c - '0'; + ++scan.first; + } + else + { + break; // reached end of digits + } + } + unescaped = oct; + } + break; + + default: + if (Flags & c_escapes) + { + // illegal C escape sequence + scan.first = save; + return scan.no_match(); + } + else + { + unescaped = *scan.first; + ++scan.first; + } + break; + } + } + else { + unescaped = *scan.first; + ++scan.first; + } + + scan.do_action(p.predicate(), unescaped, save, scan.first); + return hit; + } + } + return scan.no_match(); // overflow detected + } + }; +#if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310)) +#pragma warning(pop) +#endif + + ////////////////////////////////// + template + struct escape_char_parse { + + template + static typename parser_result::type + parse(ScannerT const &scan, ParserT const &/*p*/) + { + typedef + uint_parser::digits / 3 + 1 + > + oct_parser_t; + typedef + uint_parser::digits / 4 + 1 + > + hex_parser_t; + + typedef alternative >, + sequence, alternative >, hex_parser_t > >, + difference > >, oct_parser_t > > > > + parser_t; + + static parser_t p = + ( (anychar_p - chlit(CharT('\\'))) + | (chlit(CharT('\\')) >> + ( oct_parser_t() + | as_lower_d[chlit(CharT('x'))] >> hex_parser_t() + | (anychar_p - as_lower_d[chlit(CharT('x'))] - oct_parser_t()) + ) + )); + + BOOST_SPIRIT_DEBUG_TRACE_NODE(p, + (BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_ESCAPE_CHAR) != 0); + + return p.parse(scan); + } + }; + +/////////////////////////////////////////////////////////////////////////////// +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif + diff --git a/boost/boost/spirit/utility/impl/lists.ipp b/boost/boost/spirit/utility/impl/lists.ipp new file mode 100644 index 0000000000..43662fb15d --- /dev/null +++ b/boost/boost/spirit/utility/impl/lists.ipp @@ -0,0 +1,164 @@ +/*============================================================================= + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_LISTS_IPP +#define BOOST_SPIRIT_LISTS_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// list_parser_type class implementation +// +/////////////////////////////////////////////////////////////////////////////// +struct no_list_endtoken { typedef no_list_endtoken embed_t; }; + +namespace impl { + +/////////////////////////////////////////////////////////////////////////////// +// +// Refactor the original list item parser +// +/////////////////////////////////////////////////////////////////////////////// + + // match list with 'extended' syntax + template + struct select_list_parse_refactor { + + template < + typename ParserT, typename ScannerT, + typename ItemT, typename DelimT + > + static typename parser_result::type + parse(ScannerT const& scan, ParserT const& /*p*/, + ItemT const &item, DelimT const &delim, EndT const &end) + { + typedef refactor_action_gen > refactor_t; + const refactor_t refactor_item_d = refactor_t(refactor_unary_d); + + return ( + refactor_item_d[item - (end | delim)] + >> *(delim >> refactor_item_d[item - (end | delim)]) + >> !(delim >> end) + ).parse(scan); + } + }; + + // match list with 'normal' syntax (without an 'end' parser) + template <> + struct select_list_parse_refactor { + + template < + typename ParserT, typename ScannerT, + typename ItemT, typename DelimT + > + static typename parser_result::type + parse(ScannerT const& scan, ParserT const& /*p*/, + ItemT const &item, DelimT const &delim, no_list_endtoken const&) + { + typedef refactor_action_gen > refactor_t; + const refactor_t refactor_item_d = refactor_t(refactor_unary_d); + + return ( + refactor_item_d[item - delim] + >> *(delim >> refactor_item_d[item - delim]) + ).parse(scan); + } + }; + +/////////////////////////////////////////////////////////////////////////////// +// +// Do not refactor the original list item parser. +// +/////////////////////////////////////////////////////////////////////////////// + + // match list with 'extended' syntax + template + struct select_list_parse_no_refactor { + + template < + typename ParserT, typename ScannerT, + typename ItemT, typename DelimT + > + static typename parser_result::type + parse(ScannerT const& scan, ParserT const& /*p*/, + ItemT const &item, DelimT const &delim, EndT const &end) + { + return ( + (item - (end | delim)) + >> *(delim >> (item - (end | delim))) + >> !(delim >> end) + ).parse(scan); + } + }; + + // match list with 'normal' syntax (without an 'end' parser) + template <> + struct select_list_parse_no_refactor { + + template < + typename ParserT, typename ScannerT, + typename ItemT, typename DelimT + > + static typename parser_result::type + parse(ScannerT const& scan, ParserT const& /*p*/, + ItemT const &item, DelimT const &delim, no_list_endtoken const&) + { + return ( + (item - delim) + >> *(delim >> (item - delim)) + ).parse(scan); + } + }; + + // the refactoring is handled by the refactoring parsers, so here there + // is no need to pay attention to these issues. + + template + struct list_parser_type { + + template < + typename ParserT, typename ScannerT, + typename ItemT, typename DelimT, typename EndT + > + static typename parser_result::type + parse(ScannerT const& scan, ParserT const& p, + ItemT const &item, DelimT const &delim, EndT const &end) + { + return select_list_parse_refactor:: + parse(scan, p, item, delim, end); + } + }; + + template <> + struct list_parser_type { + + template < + typename ParserT, typename ScannerT, + typename ItemT, typename DelimT, typename EndT + > + static typename parser_result::type + parse(ScannerT const& scan, ParserT const& p, + ItemT const &item, DelimT const &delim, EndT const &end) + { + return select_list_parse_no_refactor:: + parse(scan, p, item, delim, end); + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif + diff --git a/boost/boost/spirit/utility/lists.hpp b/boost/boost/spirit/utility/lists.hpp new file mode 100644 index 0000000000..489f2700a6 --- /dev/null +++ b/boost/boost/spirit/utility/lists.hpp @@ -0,0 +1,335 @@ +/*============================================================================= + Copyright (c) 2002-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef BOOST_SPIRIT_LISTS_HPP +#define BOOST_SPIRIT_LISTS_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +/////////////////////////////////////////////////////////////////////////////// +// +// list_parser class +// +// List parsers allow to parse constructs like +// +// item >> *(delim >> item) +// +// where 'item' is an auxiliary expression to parse and 'delim' is an +// auxiliary delimiter to parse. +// +// The list_parser class also can match an optional closing delimiter +// represented by the 'end' parser at the end of the list: +// +// item >> *(delim >> item) >> !end. +// +// If ItemT is an action_parser_category type (parser with an attached +// semantic action) we have to do something special. This happens, if the +// user wrote something like: +// +// list_p(item[f], delim) +// +// where 'item' is the parser matching one item of the list sequence and +// 'f' is a functor to be called after matching one item. If we would do +// nothing, the resulting code would parse the sequence as follows: +// +// (item[f] - delim) >> *(delim >> (item[f] - delim)) +// +// what in most cases is not what the user expects. +// (If this _is_ what you've expected, then please use one of the list_p +// generator functions 'direct()', which will inhibit re-attaching +// the actor to the item parser). +// +// To make the list parser behave as expected: +// +// (item - delim)[f] >> *(delim >> (item - delim)[f]) +// +// the actor attached to the 'item' parser has to be re-attached to the +// *(item - delim) parser construct, which will make the resulting list +// parser 'do the right thing'. +// +// Additionally special care must be taken, if the item parser is a +// unary_parser_category type parser as +// +// list_p(*anychar_p, ',') +// +// which without any refactoring would result in +// +// (*anychar_p - ch_p(',')) +// >> *( ch_p(',') >> (*anychar_p - ch_p(',')) ) +// +// and will not give the expected result (the first *anychar_p will eat up +// all the input up to the end of the input stream). So we have to +// refactor this into: +// +// *(anychar_p - ch_p(',')) +// >> *( ch_p(',') >> *(anychar_p - ch_p(',')) ) +// +// what will give the correct result. +// +// The case, where the item parser is a combination of the two mentioned +// problems (i.e. the item parser is a unary parser with an attached +// action), is handled accordingly too: +// +// list_p((*anychar_p)[f], ',') +// +// will be parsed as expected: +// +// (*(anychar_p - ch_p(',')))[f] +// >> *( ch_p(',') >> (*(anychar_p - ch_p(',')))[f] ). +// +/////////////////////////////////////////////////////////////////////////////// +template < + typename ItemT, typename DelimT, typename EndT = no_list_endtoken, + typename CategoryT = plain_parser_category +> +struct list_parser : + public parser > { + + typedef list_parser self_t; + typedef CategoryT parser_category_t; + + list_parser(ItemT const &item_, DelimT const &delim_, + EndT const& end_ = no_list_endtoken()) + : item(item_), delim(delim_), end(end_) + {} + + template + typename parser_result::type + parse(ScannerT const& scan) const + { + return impl::list_parser_type + ::parse(scan, *this, item, delim, end); + } + +private: + typename as_parser::type::embed_t item; + typename as_parser::type::embed_t delim; + typename as_parser::type::embed_t end; +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// List parser generator template +// +// This is a helper for generating a correct list_parser<> from +// auxiliary parameters. There are the following types supported as +// parameters yet: parsers, single characters and strings (see +// as_parser<> in meta/as_parser.hpp). +// +// The list_parser_gen by itself can be used for parsing comma separated +// lists without item formatting: +// +// list_p.parse(...) +// matches any comma separated list. +// +// If list_p is used with one parameter, this parameter is used to match +// the delimiter: +// +// list_p(';').parse(...) +// matches any semicolon separated list. +// +// If list_p is used with two parameters, the first parameter is used to +// match the items and the second parameter matches the delimiters: +// +// list_p(uint_p, ',').parse(...) +// matches comma separated unsigned integers. +// +// If list_p is used with three parameters, the first parameter is used +// to match the items, the second one is used to match the delimiters and +// the third one is used to match an optional ending token sequence: +// +// list_p(real_p, ';', eol_p).parse(...) +// matches a semicolon separated list of real numbers optionally +// followed by an end of line. +// +// The list_p in the previous examples denotes the predefined parser +// generator, which should be used to define list parsers (see below). +// +/////////////////////////////////////////////////////////////////////////////// + +template +struct list_parser_gen : + public list_parser, chlit > +{ + typedef list_parser_gen self_t; + +// construct the list_parser_gen object as an list parser for comma separated +// lists without item formatting. + list_parser_gen() + : list_parser, chlit > + (*anychar_p, chlit(',')) + {} + +// The following generator functions should be used under normal circumstances. +// (the operator()(...) functions) + + // Generic generator functions for creation of concrete list parsers, which + // support 'normal' syntax: + // + // item >> *(delim >> item) + // + // If item isn't given, everything between two delimiters is matched. + + template + list_parser< + kleene_star, + typename as_parser::type, + no_list_endtoken, + unary_parser_category // there is no action to re-attach + > + operator()(DelimT const &delim_) const + { + typedef kleene_star item_t; + typedef typename as_parser::type delim_t; + + typedef + list_parser + return_t; + + return return_t(*anychar_p, as_parser::convert(delim_)); + } + + template + list_parser< + typename as_parser::type, + typename as_parser::type, + no_list_endtoken, + typename as_parser::type::parser_category_t + > + operator()(ItemT const &item_, DelimT const &delim_) const + { + typedef typename as_parser::type item_t; + typedef typename as_parser::type delim_t; + typedef list_parser + return_t; + + return return_t( + as_parser::convert(item_), + as_parser::convert(delim_) + ); + } + + // Generic generator function for creation of concrete list parsers, which + // support 'extended' syntax: + // + // item >> *(delim >> item) >> !end + + template + list_parser< + typename as_parser::type, + typename as_parser::type, + typename as_parser::type, + typename as_parser::type::parser_category_t + > + operator()( + ItemT const &item_, DelimT const &delim_, EndT const &end_) const + { + typedef typename as_parser::type item_t; + typedef typename as_parser::type delim_t; + typedef typename as_parser::type end_t; + + typedef list_parser + return_t; + + return return_t( + as_parser::convert(item_), + as_parser::convert(delim_), + as_parser::convert(end_) + ); + } + +// The following functions should be used, if the 'item' parser has an attached +// semantic action or is a unary_parser_category type parser and the structure +// of the resulting list parser should _not_ be refactored during parser +// construction (see comment above). + + // Generic generator function for creation of concrete list parsers, which + // support 'normal' syntax: + // + // item >> *(delim >> item) + + template + list_parser< + typename as_parser::type, + typename as_parser::type, + no_list_endtoken, + plain_parser_category // inhibit action re-attachment + > + direct(ItemT const &item_, DelimT const &delim_) const + { + typedef typename as_parser::type item_t; + typedef typename as_parser::type delim_t; + typedef list_parser + return_t; + + return return_t( + as_parser::convert(item_), + as_parser::convert(delim_) + ); + } + + // Generic generator function for creation of concrete list parsers, which + // support 'extended' syntax: + // + // item >> *(delim >> item) >> !end + + template + list_parser< + typename as_parser::type, + typename as_parser::type, + typename as_parser::type, + plain_parser_category // inhibit action re-attachment + > + direct( + ItemT const &item_, DelimT const &delim_, EndT const &end_) const + { + typedef typename as_parser::type item_t; + typedef typename as_parser::type delim_t; + typedef typename as_parser::type end_t; + + typedef + list_parser + return_t; + + return return_t( + as_parser::convert(item_), + as_parser::convert(delim_), + as_parser::convert(end_) + ); + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// Predefined list parser generator +// +// The list_p parser generator can be used +// - by itself for parsing comma separated lists without item formatting +// or +// - for generating list parsers with auxiliary parser parameters +// for the 'item', 'delim' and 'end' subsequences. +// (see comment above) +// +/////////////////////////////////////////////////////////////////////////////// +const list_parser_gen<> list_p = list_parser_gen<>(); + +/////////////////////////////////////////////////////////////////////////////// +}} // namespace boost::spirit + +#endif diff --git a/boost/boost/spirit/utility/loops.hpp b/boost/boost/spirit/utility/loops.hpp new file mode 100644 index 0000000000..f42776a029 --- /dev/null +++ b/boost/boost/spirit/utility/loops.hpp @@ -0,0 +1,313 @@ +/*============================================================================= + Copyright (c) 1998-2003 Joel de Guzman + Copyright (c) 2002 Raghavendra Satish + Copyright (c) 2002 Jeff Westfahl + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_LOOPS_HPP) +#define BOOST_SPIRIT_LOOPS_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // + // fixed_loop class + // + // This class takes care of the construct: + // + // repeat_p (exact) [p] + // + // where 'p' is a parser and 'exact' is the number of times to + // repeat. The parser iterates over the input exactly 'exact' times. + // The parse function fails if the parser does not match the input + // exactly 'exact' times. + // + // This class is parametizable and can accept constant arguments + // (e.g. repeat_p (5) [p]) as well as references to variables (e.g. + // repeat_p (ref (n)) [p]). + // + /////////////////////////////////////////////////////////////////////////// + template + class fixed_loop + : public unary > > + { + public: + + typedef fixed_loop self_t; + typedef unary > base_t; + + fixed_loop (ParserT const & subject, ExactT const & exact) + : base_t(subject), m_exact(exact) {} + + template + typename parser_result ::type + parse (ScannerT const & scan) const + { + typedef typename parser_result::type result_t; + result_t hit = scan.empty_match(); + std::size_t n = m_exact; + + for (std::size_t i = 0; i < n; ++i) + { + if (result_t next = this->subject().parse(scan)) + { + scan.concat_match(hit, next); + } + else + { + return scan.no_match(); + } + } + + return hit; + } + + template + struct result + { + typedef typename match_result::type type; + }; + + private: + + ExactT m_exact; + }; + + /////////////////////////////////////////////////////////////////////////////// + // + // finite_loop class + // + // This class takes care of the construct: + // + // repeat_p (min, max) [p] + // + // where 'p' is a parser, 'min' and 'max' specifies the minimum and + // maximum iterations over 'p'. The parser iterates over the input + // at least 'min' times and at most 'max' times. The parse function + // fails if the parser does not match the input at least 'min' times + // and at most 'max' times. + // + // This class is parametizable and can accept constant arguments + // (e.g. repeat_p (5, 10) [p]) as well as references to variables + // (e.g. repeat_p (ref (n1), ref (n2)) [p]). + // + /////////////////////////////////////////////////////////////////////////////// + template + class finite_loop + : public unary > > + { + public: + + typedef finite_loop self_t; + typedef unary > base_t; + + finite_loop (ParserT const & subject, MinT const & min, MaxT const & max) + : base_t(subject), m_min(min), m_max(max) {} + + template + typename parser_result ::type + parse(ScannerT const & scan) const + { + BOOST_SPIRIT_ASSERT(m_min <= m_max); + typedef typename parser_result::type result_t; + result_t hit = scan.empty_match(); + + std::size_t n1 = m_min; + std::size_t n2 = m_max; + + for (std::size_t i = 0; i < n2; ++i) + { + typename ScannerT::iterator_t save = scan.first; + result_t next = this->subject().parse(scan); + + if (!next) + { + if (i >= n1) + { + scan.first = save; + break; + } + else + { + return scan.no_match(); + } + } + + scan.concat_match(hit, next); + } + + return hit; + } + + template + struct result + { + typedef typename match_result::type type; + }; + + private: + + MinT m_min; + MaxT m_max; + }; + + /////////////////////////////////////////////////////////////////////////////// + // + // infinite_loop class + // + // This class takes care of the construct: + // + // repeat_p (min, more) [p] + // + // where 'p' is a parser, 'min' is the minimum iteration over 'p' + // and more specifies that the iteration should proceed + // indefinitely. The parser iterates over the input at least 'min' + // times and continues indefinitely until 'p' fails or all of the + // input is parsed. The parse function fails if the parser does not + // match the input at least 'min' times. + // + // This class is parametizable and can accept constant arguments + // (e.g. repeat_p (5, more) [p]) as well as references to variables + // (e.g. repeat_p (ref (n), more) [p]). + // + /////////////////////////////////////////////////////////////////////////////// + + struct more_t {}; + more_t const more = more_t (); + + template + class infinite_loop + : public unary > > + { + public: + + typedef infinite_loop self_t; + typedef unary > base_t; + + infinite_loop ( + ParserT const& subject, + MinT const& min, + more_t const& + ) + : base_t(subject), m_min(min) {} + + template + typename parser_result ::type + parse(ScannerT const & scan) const + { + typedef typename parser_result::type result_t; + result_t hit = scan.empty_match(); + std::size_t n = m_min; + + for (std::size_t i = 0; ; ++i) + { + typename ScannerT::iterator_t save = scan.first; + result_t next = this->subject().parse(scan); + + if (!next) + { + if (i >= n) + { + scan.first = save; + break; + } + else + { + return scan.no_match(); + } + } + + scan.concat_match(hit, next); + } + + return hit; + } + + template + struct result + { + typedef typename match_result::type type; + }; + + private: + + MinT m_min; + }; + + template + struct fixed_loop_gen + { + fixed_loop_gen (ExactT const & exact) + : m_exact (exact) {} + + template + fixed_loop + operator[](parser const & subject) const + { + return fixed_loop (subject.derived (), m_exact); + } + + ExactT m_exact; + }; + + namespace impl { + + template + struct loop_traits + { + typedef typename mpl::if_< + boost::is_same, + infinite_loop, + finite_loop + >::type type; + }; + + } // namespace impl + + template + struct nonfixed_loop_gen + { + nonfixed_loop_gen (MinT min, MaxT max) + : m_min (min), m_max (max) {} + + template + typename impl::loop_traits::type + operator[](parser const & subject) const + { + typedef typename impl::loop_traits::type ret_t; + return ret_t( + subject.derived(), + m_min, + m_max); + } + + MinT m_min; + MaxT m_max; + }; + + template + fixed_loop_gen + repeat_p(ExactT const & exact) + { + return fixed_loop_gen (exact); + } + + template + nonfixed_loop_gen + repeat_p(MinT const & min, MaxT const & max) + { + return nonfixed_loop_gen (min, max); + } + +}} // namespace boost::spirit + +#endif // #if !defined(BOOST_SPIRIT_LOOPS_HPP) diff --git a/boost/boost/spirit/utility/scoped_lock.hpp b/boost/boost/spirit/utility/scoped_lock.hpp new file mode 100644 index 0000000000..a22dd20a06 --- /dev/null +++ b/boost/boost/spirit/utility/scoped_lock.hpp @@ -0,0 +1,108 @@ +/*============================================================================= + Copyright (c) 2003 Martin Wille + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) + =============================================================================*/ +#ifndef BOOST_SPIRIT_UTILITY_SCOPED_LOCK_HPP +#define BOOST_SPIRIT_UTILITY_SCOPED_LOCK_HPP + +/////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_SPIRIT_COMPOSITE_HPP) +#include +#endif + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + + /////////////////////////////////////////////////////////////////////////// + // + // scoped_lock_parser class + // + // implements locking of a mutex during execution of + // the parse method of an embedded parser + // + /////////////////////////////////////////////////////////////////////////// + template + struct scoped_lock_parser + : public unary< ParserT, parser< scoped_lock_parser > > + { + typedef scoped_lock_parser self_t; + typedef MutexT mutex_t; + typedef ParserT parser_t; + + template + struct result + { + typedef typename parser_result::type type; + }; + + scoped_lock_parser(mutex_t &m, parser_t const &p) + : unary< ParserT, parser< scoped_lock_parser > >(p) + , mutex(m) + {} + + + template + typename parser_result::type + parse(ScannerT const &scan) const + { + typedef typename mutex_t::scoped_lock scoped_lock_t; + scoped_lock_t lock(mutex); + return this->subject().parse(scan); + } + + mutex_t &mutex; + }; + + /////////////////////////////////////////////////////////////////////////// + // + // scoped_lock_parser_gen + // + // generator for scoped_lock_parser objects + // operator[] returns scoped_lock_parser according to its argument + // + /////////////////////////////////////////////////////////////////////////// + template + struct scoped_lock_parser_gen + { + typedef MutexT mutex_t; + explicit scoped_lock_parser_gen(mutex_t &m) : mutex(m) {} + + template + scoped_lock_parser + < + MutexT, + typename as_parser::type + > + operator[](ParserT const &p) const + { + typedef ::boost::spirit::as_parser as_parser_t; + typedef typename as_parser_t::type parser_t; + + return scoped_lock_parser + (mutex, as_parser_t::convert(p)); + } + + mutex_t &mutex; + }; + + + /////////////////////////////////////////////////////////////////////////// + // + // scoped_lock_d parser directive + // + // constructs a scoped_lock_parser generator from its argument + // + /////////////////////////////////////////////////////////////////////////// + template + scoped_lock_parser_gen + scoped_lock_d(MutexT &mutex) + { + return scoped_lock_parser_gen(mutex); + } + +}} // namespace boost::spirit +#endif // BOOST_SPIRIT_UTILITY_SCOPED_LOCK_HPP diff --git a/boost/boost/spirit/version.hpp b/boost/boost/spirit/version.hpp new file mode 100644 index 0000000000..8d83ad00dc --- /dev/null +++ b/boost/boost/spirit/version.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(SPIRIT_VERSION_HPP) +#define SPIRIT_VERSION_HPP + +/////////////////////////////////////////////////////////////////////////////// +// +// This checks, whether the used Boost library is at least V1.32.0 +// +/////////////////////////////////////////////////////////////////////////////// +#include + +#if BOOST_VERSION < 103200 +#error "Spirit V1.8.1 needs at least Boost V1.32.0 to compile successfully." +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// This is the version of the current Spirit distribution +// +/////////////////////////////////////////////////////////////////////////////// +#define SPIRIT_VERSION 0x1801 +#define SPIRIT_PIZZA_VERSION SPIRIT_FOUR_SEASONS // :-) + +#endif // defined(SPIRIT_VERSION_HPP)