1 /*=============================================================================
2     Copyright (c) 2001-2011 Joel de Guzman
3     Copyright (c) 2001-2011 Hartmut Kaiser
4 
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8 #ifndef BOOST_SPIRIT_QI_OPERATOR_SEQUENCE_HPP
9 #define BOOST_SPIRIT_QI_OPERATOR_SEQUENCE_HPP
10 
11 #if defined(_MSC_VER)
12 #pragma once
13 #endif
14 
15 #include <boost/spirit/home/qi/operator/sequence_base.hpp>
16 #include <boost/spirit/home/qi/detail/fail_function.hpp>
17 #include <boost/spirit/home/qi/meta_compiler.hpp>
18 #include <boost/proto/operators.hpp>
19 #include <boost/proto/tags.hpp>
20 
21 namespace boost { namespace spirit
22 {
23     ///////////////////////////////////////////////////////////////////////////
24     // Enablers
25     ///////////////////////////////////////////////////////////////////////////
26     template <>
27     struct use_operator<qi::domain, proto::tag::shift_right> // enables >>
28       : mpl::true_ {};
29 
30     template <>
31     struct flatten_tree<qi::domain, proto::tag::shift_right> // flattens >>
32       : mpl::true_ {};
33 }}
34 
35 namespace boost { namespace spirit { namespace qi
36 {
37     template <typename Elements>
38     struct sequence : sequence_base<sequence<Elements>, Elements>
39     {
40         friend struct sequence_base<sequence<Elements>, Elements>;
41 
sequenceboost::spirit::qi::sequence42         sequence(Elements const& elements)
43           : sequence_base<sequence<Elements>, Elements>(elements) {}
44 
45     private:
46 
47         template <typename Iterator, typename Context, typename Skipper>
48         static detail::fail_function<Iterator, Context, Skipper>
fail_functionboost::spirit::qi::sequence49         fail_function(
50             Iterator& first, Iterator const& last
51           , Context& context, Skipper const& skipper)
52         {
53             return detail::fail_function<Iterator, Context, Skipper>
54                 (first, last, context, skipper);
55         }
56 
idboost::spirit::qi::sequence57         std::string id() const { return "sequence"; }
58     };
59 
60     ///////////////////////////////////////////////////////////////////////////
61     // Parser generators: make_xxx function (objects)
62     ///////////////////////////////////////////////////////////////////////////
63     template <typename Elements, typename Modifiers>
64     struct make_composite<proto::tag::shift_right, Elements, Modifiers>
65       : make_nary_composite<Elements, sequence>
66     {};
67 
68 //     ///////////////////////////////////////////////////////////////////////////
69 //     // Define what attributes are compatible with a sequence
70 //     template <typename Attribute, typename Elements, typename Context, typename Iterator>
71 //     struct is_attribute_compatible<Attribute, sequence<Elements>, Context, Iterator>
72 //       : mpl::or_<
73 //             is_convertible<Attribute
74 //               , typename traits::attribute_of<sequence<Elements>, Context, Iterator>::type>
75 //           , traits::is_fusion_sequence_compatible<qi::domain, Attribute
76 //               , sequence<Elements>, Context, Iterator>
77 //           , traits::is_container_compatible<qi::domain, Attribute
78 //               , sequence<Elements>, Context, Iterator>
79 //         >
80 //     {};
81 }}}
82 
83 namespace boost { namespace spirit { namespace traits
84 {
85     ///////////////////////////////////////////////////////////////////////////
86     template <typename Elements>
87     struct has_semantic_action<qi::sequence<Elements> >
88       : nary_has_semantic_action<Elements> {};
89 
90     ///////////////////////////////////////////////////////////////////////////
91     template <typename Elements, typename Attribute, typename Context
92       , typename Iterator>
93     struct handles_container<qi::sequence<Elements>, Attribute, Context
94           , Iterator>
95       : mpl::true_ {};
96 }}}
97 
98 #endif
99