1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
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_OMIT_MARCH_24_2007_0802AM)
8 #define SPIRIT_OMIT_MARCH_24_2007_0802AM
14 #include <boost/spirit/home/qi/meta_compiler.hpp>
15 #include <boost/spirit/home/qi/skip_over.hpp>
16 #include <boost/spirit/home/qi/parser.hpp>
17 #include <boost/spirit/home/support/unused.hpp>
18 #include <boost/spirit/home/support/info.hpp>
19 #include <boost/spirit/home/support/common_terminals.hpp>
20 #include <boost/spirit/home/support/has_semantic_action.hpp>
21 #include <boost/spirit/home/support/handles_container.hpp>
23 namespace boost { namespace spirit
25 ///////////////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////////////
29 struct use_directive<qi::domain, tag::omit> // enables omit
33 namespace boost { namespace spirit { namespace qi
35 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
38 using spirit::omit_type;
40 ///////////////////////////////////////////////////////////////////////////
41 // omit_directive forces the attribute of subject parser
43 ///////////////////////////////////////////////////////////////////////////
44 template <typename Subject>
45 struct omit_directive : unary_parser<omit_directive<Subject> >
47 typedef Subject subject_type;
48 omit_directive(Subject const& subject_)
49 : subject(subject_) {}
51 template <typename Context, typename Iterator>
54 typedef unused_type type;
57 template <typename Iterator, typename Context
58 , typename Skipper, typename Attribute>
59 bool parse(Iterator& first, Iterator const& last
60 , Context& context, Skipper const& skipper, Attribute& attr_) const
62 return subject.parse(first, last, context, skipper, attr_);
65 template <typename Context>
66 info what(Context& context) const
68 return info("omit", subject.what(context));
74 // silence MSVC warning C4512: assignment operator could not be generated
75 omit_directive& operator= (omit_directive const&);
78 ///////////////////////////////////////////////////////////////////////////
79 // Parser generators: make_xxx function (objects)
80 ///////////////////////////////////////////////////////////////////////////
81 template <typename Subject, typename Modifiers>
82 struct make_directive<tag::omit, Subject, Modifiers>
84 typedef omit_directive<Subject> result_type;
85 result_type operator()(unused_type, Subject const& subject, unused_type) const
87 return result_type(subject);
92 namespace boost { namespace spirit { namespace traits
94 ///////////////////////////////////////////////////////////////////////////
95 template <typename Subject>
96 struct has_semantic_action<qi::omit_directive<Subject> >
99 ///////////////////////////////////////////////////////////////////////////
100 template <typename Subject, typename Attribute, typename Context
102 struct handles_container<qi::omit_directive<Subject>, Attribute
104 : unary_handles_container<Subject, Attribute, Context, Iterator> {};