1 ///////////////////////////////////////////////////////////////////////////////
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)
8 #ifndef BOOST_XPRESSIVE_DETAIL_STATIC_PRODUCTIONS_ALT_COMPILERS_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_STATIC_PRODUCTIONS_ALT_COMPILERS_HPP_EAN_10_04_2005
11 #include <boost/version.hpp>
12 #include <boost/xpressive/detail/detail_fwd.hpp>
13 #include <boost/xpressive/proto/proto.hpp>
14 #include <boost/xpressive/proto/compiler/fold.hpp>
15 #include <boost/xpressive/proto/compiler/branch.hpp>
16 #include <boost/xpressive/detail/utility/cons.hpp>
17 #include <boost/xpressive/detail/utility/dont_care.hpp>
18 #include <boost/xpressive/detail/static/productions/domain_tags.hpp>
20 namespace boost
{ namespace xpressive
{ namespace detail
23 ///////////////////////////////////////////////////////////////////////////////
25 // Describes how to construct an alternate xpression
28 typedef boost::fusion::nil state_type
;
30 template<typename Op
, typename State
, typename Visitor
>
33 typedef static_xpression
35 alternate_matcher
<alternates_list
<Op
>, typename
Visitor::traits_type
>
40 template<typename Op
, typename State
, typename Visitor
>
41 static typename apply
<Op
, State
, Visitor
>::type
42 call(Op
const &op
, State
const &state
, Visitor
&)
44 typedef alternate_matcher
<alternates_list
<Op
>, typename
Visitor::traits_type
> alt_matcher
;
45 return make_static_xpression(alt_matcher(op
), state
);
49 ///////////////////////////////////////////////////////////////////////////////
51 struct alt_list_branch
53 typedef alternate_end_xpression state_type
;
55 template<typename Op
, typename State
, typename
>
58 typedef boost::fusion::cons
<Op
, State
> type
;
61 template<typename Op
, typename State
>
62 static boost::fusion::cons
<Op
, State
>
63 call(Op
const &op
, State
const &state
, dont_care
)
65 return boost::fusion::make_cons(op
, state
);
71 namespace boost
{ namespace proto
73 // production for alternates in sequence
75 struct compiler
<bitor_tag
, xpressive::detail::seq_tag
, void>
76 : branch_compiler
<xpressive::detail::alt_branch
, xpressive::detail::alt_tag
>
80 // handle alternates with the alt branch compiler
81 template<typename OpTag
>
82 struct compiler
<OpTag
, xpressive::detail::alt_tag
, void>
83 : branch_compiler
<xpressive::detail::alt_list_branch
, xpressive::detail::seq_tag
>
87 // production for alternates in alternate
89 struct compiler
<bitor_tag
, xpressive::detail::alt_tag
, void>
90 : fold_compiler
<bitor_tag
, xpressive::detail::alt_tag
>