]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_NO_SKIP_JAN_16_2010_0802PM) | |
9 | #define SPIRIT_NO_SKIP_JAN_16_2010_0802PM | |
10 | ||
11 | #if defined(_MSC_VER) | |
12 | #pragma once | |
13 | #endif | |
14 | ||
15 | #include <boost/spirit/home/qi/meta_compiler.hpp> | |
16 | #include <boost/spirit/home/qi/skip_over.hpp> | |
17 | #include <boost/spirit/home/qi/parser.hpp> | |
18 | #include <boost/spirit/home/qi/detail/unused_skipper.hpp> | |
19 | #include <boost/spirit/home/support/unused.hpp> | |
20 | #include <boost/spirit/home/support/common_terminals.hpp> | |
21 | #include <boost/spirit/home/support/attributes.hpp> | |
22 | #include <boost/spirit/home/support/info.hpp> | |
23 | #include <boost/spirit/home/support/has_semantic_action.hpp> | |
24 | #include <boost/spirit/home/support/handles_container.hpp> | |
25 | #include <boost/utility/enable_if.hpp> | |
26 | ||
27 | namespace boost { namespace spirit | |
28 | { | |
29 | /////////////////////////////////////////////////////////////////////////// | |
30 | // Enablers | |
31 | /////////////////////////////////////////////////////////////////////////// | |
32 | template <> | |
33 | struct use_directive<qi::domain, tag::no_skip> // enables no_skip | |
34 | : mpl::true_ {}; | |
35 | }} | |
36 | ||
37 | namespace boost { namespace spirit { namespace qi | |
38 | { | |
39 | #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS | |
40 | using spirit::no_skip; | |
41 | #endif | |
42 | using spirit::no_skip_type; | |
43 | ||
44 | // same as lexeme[], but does not pre-skip | |
45 | template <typename Subject> | |
46 | struct no_skip_directive : unary_parser<no_skip_directive<Subject> > | |
47 | { | |
48 | typedef Subject subject_type; | |
49 | no_skip_directive(Subject const& subject_) | |
50 | : subject(subject_) {} | |
51 | ||
52 | template <typename Context, typename Iterator> | |
53 | struct attribute | |
54 | { | |
55 | typedef typename | |
56 | traits::attribute_of<subject_type, Context, Iterator>::type | |
57 | type; | |
58 | }; | |
59 | ||
60 | template <typename Iterator, typename Context | |
61 | , typename Skipper, typename Attribute> | |
62 | typename disable_if<detail::is_unused_skipper<Skipper>, bool>::type | |
63 | parse(Iterator& first, Iterator const& last | |
64 | , Context& context, Skipper const& skipper | |
65 | , Attribute& attr_) const | |
66 | { | |
67 | return subject.parse(first, last, context | |
68 | , detail::unused_skipper<Skipper>(skipper), attr_); | |
69 | } | |
70 | template <typename Iterator, typename Context | |
71 | , typename Skipper, typename Attribute> | |
72 | typename enable_if<detail::is_unused_skipper<Skipper>, bool>::type | |
73 | parse(Iterator& first, Iterator const& last | |
74 | , Context& context, Skipper const& skipper | |
75 | , Attribute& attr_) const | |
76 | { | |
77 | return subject.parse(first, last, context | |
78 | , skipper, attr_); | |
79 | } | |
80 | ||
81 | template <typename Context> | |
82 | info what(Context& context) const | |
83 | { | |
84 | return info("no_skip", subject.what(context)); | |
85 | ||
86 | } | |
87 | ||
88 | Subject subject; | |
89 | }; | |
90 | ||
91 | /////////////////////////////////////////////////////////////////////////// | |
92 | // Parser generators: make_xxx function (objects) | |
93 | /////////////////////////////////////////////////////////////////////////// | |
94 | template <typename Subject, typename Modifiers> | |
95 | struct make_directive<tag::no_skip, Subject, Modifiers> | |
96 | { | |
97 | typedef no_skip_directive<Subject> result_type; | |
98 | result_type operator()(unused_type, Subject const& subject, unused_type) const | |
99 | { | |
100 | return result_type(subject); | |
101 | } | |
102 | }; | |
103 | }}} | |
104 | ||
105 | namespace boost { namespace spirit { namespace traits | |
106 | { | |
107 | /////////////////////////////////////////////////////////////////////////// | |
108 | template <typename Subject> | |
109 | struct has_semantic_action<qi::no_skip_directive<Subject> > | |
110 | : unary_has_semantic_action<Subject> {}; | |
111 | ||
112 | /////////////////////////////////////////////////////////////////////////// | |
113 | template <typename Subject, typename Attribute, typename Context | |
114 | , typename Iterator> | |
115 | struct handles_container<qi::no_skip_directive<Subject>, Attribute | |
116 | , Context, Iterator> | |
117 | : unary_handles_container<Subject, Attribute, Context, Iterator> {}; | |
118 | }}} | |
119 | ||
120 | #endif |