/////////////////////////////////////////////////////////////////////////////// // compile.hpp // // Copyright 2008 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_COMPILE_HPP_EAN_10_04_2005 #define BOOST_XPRESSIVE_DETAIL_STATIC_COMPILE_HPP_EAN_10_04_2005 // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace xpressive { namespace detail { /////////////////////////////////////////////////////////////////////////////// // static_compile_impl2 template void static_compile_impl2(Xpr const &xpr, shared_ptr > const &impl, Traits const &tr) { typedef typename iterator_value::type char_type; impl->tracking_clear(); impl->traits_ = new traits_holder(tr); // "compile" the regex and wrap it in an xpression_adaptor. typedef xpression_visitor visitor_type; visitor_type visitor(tr, impl); intrusive_ptr const> adxpr = make_adaptor >( typename Grammar::template impl()( xpr , end_xpression() , visitor ) ); // Link and optimize the regex common_compile(adxpr, *impl, visitor.traits()); // References changed, update dependencies. impl->tracking_update(); } /////////////////////////////////////////////////////////////////////////////// // pattern for imbued regexes. struct XpressiveLocaleModifier : proto::binary_expr< modifier_tag , proto::terminal > , proto::_ > {}; /////////////////////////////////////////////////////////////////////////////// // static_compile_impl1 template typename disable_if >::type static_compile_impl1(Xpr const &xpr, shared_ptr > const &impl) { // use default traits typedef typename iterator_value::type char_type; typedef typename default_regex_traits::type traits_type; traits_type tr; static_compile_impl2(xpr, impl, tr); } /////////////////////////////////////////////////////////////////////////////// // static_compile_impl1 template typename enable_if >::type static_compile_impl1(Xpr const &xpr, shared_ptr > const &impl) { // use specified traits typedef typename proto::result_of::value::type>::type::locale_type locale_type; typedef typename regex_traits_type::type traits_type; static_compile_impl2(proto::right(xpr), impl, traits_type(proto::value(proto::left(xpr)).getloc())); } /////////////////////////////////////////////////////////////////////////////// // static_compile template void static_compile(Xpr const &xpr, shared_ptr > const &impl) { static_compile_impl1(xpr, impl); } }}} // namespace boost::xpressive::detail #endif