PageRenderTime 21ms CodeModel.GetById 11ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/src/contrib/boost/spirit/home/qi/operator/expect.hpp

http://pythonocc.googlecode.com/
C++ Header | 92 lines | 66 code | 14 blank | 12 comment | 0 complexity | a56f49b466d9f270fe88ea88eb214b30 MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2001-2010 Joel de Guzman
 3
 4    Distributed under the Boost Software License, Version 1.0. (See accompanying
 5    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 6=============================================================================*/
 7#if !defined(SPIRIT_EXPECT_APRIL_29_2007_0445PM)
 8#define SPIRIT_EXPECT_APRIL_29_2007_0445PM
 9
10#if defined(_MSC_VER)
11#pragma once
12#endif
13
14#include <boost/spirit/home/qi/operator/sequence_base.hpp>
15#include <boost/spirit/home/qi/detail/expect_function.hpp>
16#include <boost/spirit/home/qi/meta_compiler.hpp>
17#include <boost/spirit/home/support/info.hpp>
18#include <stdexcept>
19
20namespace boost { namespace spirit
21{
22    ///////////////////////////////////////////////////////////////////////////
23    // Enablers
24    ///////////////////////////////////////////////////////////////////////////
25    template <>
26    struct use_operator<qi::domain, proto::tag::greater> // enables >
27      : mpl::true_ {};
28
29    template <>
30    struct flatten_tree<qi::domain, proto::tag::greater> // flattens >
31      : mpl::true_ {};
32}}
33
34namespace boost { namespace spirit { namespace qi
35{
36    template <typename Iterator>
37    struct expectation_failure : std::runtime_error
38    {
39        expectation_failure(Iterator first, Iterator last, info const& what)
40          : std::runtime_error("boost::spirit::qi::expectation_failure")
41          , first(first), last(last), what_(what)
42        {}
43        ~expectation_failure() throw() {}
44
45        Iterator first;
46        Iterator last;
47        info what_;
48    };
49
50    template <typename Elements>
51    struct expect : sequence_base<expect<Elements>, Elements>
52    {
53        friend struct sequence_base<expect<Elements>, Elements>;
54
55        expect(Elements const& elements)
56          : sequence_base<expect<Elements>, Elements>(elements) {}
57
58    private:
59
60        template <typename Iterator, typename Context, typename Skipper>
61        static detail::expect_function<
62            Iterator, Context, Skipper
63          , expectation_failure<Iterator> >
64        fail_function(
65            Iterator& first, Iterator const& last
66          , Context& context, Skipper const& skipper)
67        {
68            return detail::expect_function<
69                Iterator, Context, Skipper, expectation_failure<Iterator> >
70                (first, last, context, skipper);
71        }
72
73        std::string id() const { return "expect"; }
74    };
75
76    ///////////////////////////////////////////////////////////////////////////
77    // Parser generators: make_xxx function (objects)
78    ///////////////////////////////////////////////////////////////////////////
79    template <typename Elements, typename Modifiers>
80    struct make_composite<proto::tag::greater, Elements, Modifiers>
81      : make_nary_composite<Elements, expect>
82    {};
83}}}
84
85namespace boost { namespace spirit { namespace traits
86{
87    template <typename Elements>
88    struct has_semantic_action<qi::expect<Elements> >
89      : nary_has_semantic_action<Elements> {};
90}}}
91
92#endif