Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/xpressive/detail/static/compile.hpp @ 33

Last change on this file since 33 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 3.6 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2// compile.hpp
3//
4//  Copyright 2004 Eric Niebler. Distributed under the Boost
5//  Software License, Version 1.0. (See accompanying file
6//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_COMPILE_HPP_EAN_10_04_2005
9#define BOOST_XPRESSIVE_DETAIL_STATIC_COMPILE_HPP_EAN_10_04_2005
10
11// MS compatible compilers support #pragma once
12#if defined(_MSC_VER) && (_MSC_VER >= 1020)
13# pragma once
14#endif
15
16#include <boost/mpl/bool.hpp>
17#include <boost/iterator/iterator_traits.hpp>
18#include <boost/xpressive/proto/proto.hpp>
19#include <boost/xpressive/regex_traits.hpp>
20#include <boost/xpressive/detail/core/regex_impl.hpp>
21#include <boost/xpressive/detail/core/linker.hpp>
22#include <boost/xpressive/detail/core/optimize.hpp>
23#include <boost/xpressive/detail/core/adaptor.hpp>
24#include <boost/xpressive/detail/core/matcher/end_matcher.hpp>
25#include <boost/xpressive/detail/static/static.hpp>
26#include <boost/xpressive/detail/static/productions/visitor.hpp>
27#include <boost/xpressive/detail/static/productions/domain_tags.hpp>
28
29namespace boost { namespace xpressive { namespace detail
30{
31
32    ///////////////////////////////////////////////////////////////////////////////
33    // static_compile_impl2
34    template<typename Xpr, typename BidiIter, typename Traits>
35    void static_compile_impl2(Xpr const &xpr, regex_impl<BidiIter> &impl, Traits const &traits)
36    {
37        typedef typename iterator_value<BidiIter>::type char_type;
38        // "compile" the regex and wrap it in an xpression_adaptor
39        xpression_visitor<BidiIter, mpl::false_, Traits> visitor(traits, impl.shared_from_this());
40        visitor.impl().traits_.reset(new Traits(visitor.traits()));
41        visitor.impl().xpr_ = make_adaptor<BidiIter>(
42            proto::compile(xpr, end_xpression(), visitor, seq_tag()));
43
44        // "link" the regex
45        xpression_linker<char_type> linker(visitor.traits());
46        visitor.impl().xpr_->link(linker);
47
48        // optimization: get the peek chars OR the boyer-moore search string
49        optimize_regex(visitor.impl(), visitor.traits(), is_random<BidiIter>());
50
51        // copy the implementation
52        impl.tracking_copy(visitor.impl());
53    }
54
55    ///////////////////////////////////////////////////////////////////////////////
56    // static_compile_impl1
57    template<typename Xpr, typename BidiIter>
58    void static_compile_impl1(Xpr const &xpr, regex_impl<BidiIter> &impl)
59    {
60        // use default traits
61        typedef typename iterator_value<BidiIter>::type char_type;
62        typedef typename default_regex_traits<char_type>::type traits_type;
63        traits_type traits;
64        static_compile_impl2(xpr, impl, traits);
65    }
66
67    ///////////////////////////////////////////////////////////////////////////////
68    // static_compile_impl1
69    template<typename Locale, typename Xpr, typename BidiIter>
70    void static_compile_impl1
71    (
72        proto::binary_op<locale_modifier<Locale>, Xpr, modifier_tag> const &xpr
73      , regex_impl<BidiIter> &impl
74    )
75    {
76        // use specified traits
77        typedef typename regex_traits_type<Locale, BidiIter>::type traits_type;
78        static_compile_impl2(proto::right(xpr), impl, traits_type(proto::left(xpr).getloc()));
79    }
80
81    ///////////////////////////////////////////////////////////////////////////////
82    // static_compile
83    template<typename Xpr, typename BidiIter>
84    void static_compile(Xpr const &xpr, regex_impl<BidiIter> &impl)
85    {
86        static_compile_impl1(xpr, impl);
87    }
88
89}}} // namespace boost::xpressive::detail
90
91#endif
Note: See TracBrowser for help on using the repository browser.