Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2001-2011 Hartmut Kaiser
|
Chris@16
|
3
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 =============================================================================*/
|
Chris@16
|
7 #if !defined(BOOST_SPIRIT_DETAIL_PARSE_DEC_02_2009_0411PM)
|
Chris@16
|
8 #define BOOST_SPIRIT_DETAIL_PARSE_DEC_02_2009_0411PM
|
Chris@16
|
9
|
Chris@16
|
10 #if defined(_MSC_VER)
|
Chris@16
|
11 #pragma once
|
Chris@16
|
12 #endif
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/spirit/home/qi/meta_compiler.hpp>
|
Chris@16
|
15 #include <boost/spirit/home/qi/skip_flag.hpp>
|
Chris@16
|
16 #include <boost/spirit/home/qi/skip_over.hpp>
|
Chris@16
|
17 #include <boost/spirit/home/support/unused.hpp>
|
Chris@16
|
18 #include <boost/mpl/assert.hpp>
|
Chris@16
|
19 #include <boost/mpl/bool.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 namespace boost { namespace spirit { namespace qi { namespace detail
|
Chris@16
|
22 {
|
Chris@16
|
23 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
24 template <typename Expr, typename Enable = void>
|
Chris@16
|
25 struct parse_impl
|
Chris@16
|
26 {
|
Chris@16
|
27 // Report invalid expression error as early as possible.
|
Chris@16
|
28 // If you got an error_invalid_expression error message here,
|
Chris@16
|
29 // then the expression (expr) is not a valid spirit qi expression.
|
Chris@16
|
30 // Did you intend to use the auto_ facilities while forgetting to
|
Chris@16
|
31 // #include <boost/spirit/include/qi_auto.hpp>?
|
Chris@16
|
32 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
|
Chris@16
|
33 };
|
Chris@16
|
34
|
Chris@16
|
35 template <typename Expr>
|
Chris@16
|
36 struct parse_impl<Expr
|
Chris@16
|
37 , typename enable_if<traits::matches<qi::domain, Expr> >::type>
|
Chris@16
|
38 {
|
Chris@16
|
39 template <typename Iterator>
|
Chris@16
|
40 static bool call(
|
Chris@16
|
41 Iterator& first
|
Chris@16
|
42 , Iterator last
|
Chris@16
|
43 , Expr const& expr)
|
Chris@16
|
44 {
|
Chris@16
|
45 return compile<qi::domain>(expr).parse(
|
Chris@16
|
46 first, last, unused, unused, unused);
|
Chris@16
|
47 }
|
Chris@16
|
48 };
|
Chris@16
|
49
|
Chris@16
|
50 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
51 template <typename Expr, typename Enable = void>
|
Chris@16
|
52 struct phrase_parse_impl
|
Chris@16
|
53 {
|
Chris@16
|
54 // Report invalid expression error as early as possible.
|
Chris@16
|
55 // If you got an error_invalid_expression error message here,
|
Chris@16
|
56 // then the expression (expr) is not a valid spirit qi expression.
|
Chris@16
|
57 // Did you intend to use the auto_ facilities while forgetting to
|
Chris@16
|
58 // #include <boost/spirit/include/qi_auto.hpp>?
|
Chris@16
|
59 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
|
Chris@16
|
60 };
|
Chris@16
|
61
|
Chris@16
|
62 template <typename Expr>
|
Chris@16
|
63 struct phrase_parse_impl<Expr
|
Chris@16
|
64 , typename enable_if<traits::matches<qi::domain, Expr> >::type>
|
Chris@16
|
65 {
|
Chris@16
|
66 template <typename Iterator, typename Skipper>
|
Chris@16
|
67 static bool call(
|
Chris@16
|
68 Iterator& first
|
Chris@16
|
69 , Iterator last
|
Chris@16
|
70 , Expr const& expr
|
Chris@16
|
71 , Skipper const& skipper
|
Chris@16
|
72 , BOOST_SCOPED_ENUM(skip_flag) post_skip)
|
Chris@16
|
73 {
|
Chris@16
|
74 // Report invalid expression error as early as possible.
|
Chris@16
|
75 // If you got an error_invalid_expression error message here,
|
Chris@16
|
76 // then the skipper is not a valid spirit qi expression.
|
Chris@16
|
77 BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper);
|
Chris@16
|
78
|
Chris@16
|
79 typedef
|
Chris@16
|
80 typename result_of::compile<qi::domain, Skipper>::type
|
Chris@16
|
81 skipper_type;
|
Chris@16
|
82 skipper_type const skipper_ = compile<qi::domain>(skipper);
|
Chris@16
|
83
|
Chris@16
|
84 if (!compile<qi::domain>(expr).parse(
|
Chris@16
|
85 first, last, unused, skipper_, unused))
|
Chris@16
|
86 return false;
|
Chris@16
|
87
|
Chris@16
|
88 if (post_skip == skip_flag::postskip)
|
Chris@16
|
89 qi::skip_over(first, last, skipper_);
|
Chris@16
|
90 return true;
|
Chris@16
|
91 }
|
Chris@16
|
92 };
|
Chris@16
|
93
|
Chris@16
|
94 }}}}
|
Chris@16
|
95
|
Chris@16
|
96 #endif
|
Chris@16
|
97
|