/////////////////////////////////////////////////////////////////////////////// // alt_compilers.hpp // // Copyright 2004 Eric Niebler. Distributed under 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_XPRESSIVE_DETAIL_STATIC_PRODUCTIONS_ALT_COMPILERS_HPP_EAN_10_04_2005 #define BOOST_XPRESSIVE_DETAIL_STATIC_PRODUCTIONS_ALT_COMPILERS_HPP_EAN_10_04_2005 #include #include #include #include #include #include #include #include namespace boost { namespace xpressive { namespace detail { /////////////////////////////////////////////////////////////////////////////// // alt_branch // Describes how to construct an alternate xpression struct alt_branch { typedef boost::fusion::nil state_type; template struct apply { typedef static_xpression < alternate_matcher, typename Visitor::traits_type> , State > type; }; template static typename apply::type call(Op const &op, State const &state, Visitor &) { typedef alternate_matcher, typename Visitor::traits_type> alt_matcher; return make_static_xpression(alt_matcher(op), state); } }; /////////////////////////////////////////////////////////////////////////////// // alt_list_branch struct alt_list_branch { typedef alternate_end_xpression state_type; template struct apply { typedef boost::fusion::cons type; }; template static boost::fusion::cons call(Op const &op, State const &state, dont_care) { return boost::fusion::make_cons(op, state); } }; }}} namespace boost { namespace proto { // production for alternates in sequence template<> struct compiler : branch_compiler { }; // handle alternates with the alt branch compiler template struct compiler : branch_compiler { }; // production for alternates in alternate template<> struct compiler : fold_compiler { }; }} #endif