]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // as_marker.hpp | |
3 | // | |
4 | // Copyright 2008 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_TRANSFORMS_AS_MARKER_HPP_EAN_04_01_2007 | |
9 | #define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_MARKER_HPP_EAN_04_01_2007 | |
10 | ||
11 | // MS compatible compilers support #pragma once | |
12 | #if defined(_MSC_VER) | |
13 | # pragma once | |
14 | #endif | |
15 | ||
16 | #include <boost/xpressive/detail/detail_fwd.hpp> | |
17 | #include <boost/xpressive/detail/static/static.hpp> | |
18 | #include <boost/proto/core.hpp> | |
19 | ||
20 | namespace boost { namespace xpressive { namespace grammar_detail | |
21 | { | |
22 | ||
23 | /////////////////////////////////////////////////////////////////////////////// | |
24 | // as_marker | |
25 | // Insert mark tags before and after the expression | |
26 | struct as_marker : proto::transform<as_marker> | |
27 | { | |
28 | template<typename Expr, typename State, typename Data> | |
29 | struct impl : proto::transform_impl<Expr, State, Data> | |
30 | { | |
31 | typedef | |
32 | typename shift_right< | |
33 | terminal<detail::mark_begin_matcher>::type | |
34 | , typename shift_right< | |
35 | typename proto::result_of::right<typename impl::expr>::type | |
36 | , terminal<detail::mark_end_matcher>::type | |
37 | >::type | |
38 | >::type | |
39 | result_type; | |
40 | ||
41 | result_type operator ()( | |
42 | typename impl::expr_param expr | |
43 | , typename impl::state_param | |
44 | , typename impl::data_param | |
45 | ) const | |
46 | { | |
47 | int mark_nbr = detail::get_mark_number(proto::left(expr)); | |
48 | detail::mark_begin_matcher begin(mark_nbr); | |
49 | detail::mark_end_matcher end(mark_nbr); | |
50 | ||
51 | result_type that = {{begin}, {proto::right(expr), {end}}}; | |
52 | return that; | |
53 | } | |
54 | }; | |
55 | }; | |
56 | }}} | |
57 | ||
58 | #endif |