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 #if !defined(SPIRIT_EXPECT_APRIL_29_2007_0445PM) 9 #define SPIRIT_EXPECT_APRIL_29_2007_0445PM 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/expect_function.hpp> 17 #include <boost/spirit/home/qi/detail/expectation_failure.hpp> 18 #include <boost/spirit/home/qi/meta_compiler.hpp> 19 #include <boost/spirit/home/support/has_semantic_action.hpp> 20 #include <boost/spirit/home/support/handles_container.hpp> 21 #include <boost/spirit/home/support/info.hpp> 22 23 namespace boost { namespace spirit 24 { 25 /////////////////////////////////////////////////////////////////////////// 26 // Enablers 27 /////////////////////////////////////////////////////////////////////////// 28 template <> 29 struct use_operator<qi::domain, proto::tag::greater> // enables > 30 : mpl::true_ {}; 31 32 template <> 33 struct flatten_tree<qi::domain, proto::tag::greater> // flattens > 34 : mpl::true_ {}; 35 }} 36 37 namespace boost { namespace spirit { namespace qi 38 { 39 template <typename Elements> 40 struct expect_operator : sequence_base<expect_operator<Elements>, Elements> 41 { 42 friend struct sequence_base<expect_operator<Elements>, Elements>; 43 expect_operatorboost::spirit::qi::expect_operator44 expect_operator(Elements const& elements) 45 : sequence_base<expect_operator<Elements>, Elements>(elements) {} 46 47 private: 48 49 template <typename Iterator, typename Context, typename Skipper> 50 static detail::expect_function< 51 Iterator, Context, Skipper 52 , expectation_failure<Iterator> > fail_functionboost::spirit::qi::expect_operator53 fail_function( 54 Iterator& first, Iterator const& last 55 , Context& context, Skipper const& skipper) 56 { 57 return detail::expect_function< 58 Iterator, Context, Skipper, expectation_failure<Iterator> > 59 (first, last, context, skipper); 60 } 61 idboost::spirit::qi::expect_operator62 std::string id() const { return "expect_operator"; } 63 }; 64 65 /////////////////////////////////////////////////////////////////////////// 66 // Parser generators: make_xxx function (objects) 67 /////////////////////////////////////////////////////////////////////////// 68 template <typename Elements, typename Modifiers> 69 struct make_composite<proto::tag::greater, Elements, Modifiers> 70 : make_nary_composite<Elements, expect_operator> 71 {}; 72 }}} 73 74 namespace boost { namespace spirit { namespace traits 75 { 76 /////////////////////////////////////////////////////////////////////////// 77 template <typename Elements> 78 struct has_semantic_action<qi::expect_operator<Elements> > 79 : nary_has_semantic_action<Elements> {}; 80 81 /////////////////////////////////////////////////////////////////////////// 82 template <typename Elements, typename Attribute, typename Context 83 , typename Iterator> 84 struct handles_container<qi::expect_operator<Elements>, Attribute, Context 85 , Iterator> 86 : mpl::true_ {}; 87 }}} 88 89 #endif 90