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_RAW_APRIL_9_2007_0912AM)
8 #define SPIRIT_RAW_APRIL_9_2007_0912AM
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/qi/detail/assign_to.hpp>
18 #include <boost/spirit/home/support/unused.hpp>
19 #include <boost/spirit/home/support/info.hpp>
20 #include <boost/spirit/home/support/common_terminals.hpp>
21 #include <boost/spirit/home/support/unused.hpp>
22 #include <boost/spirit/home/support/has_semantic_action.hpp>
23 #include <boost/spirit/home/support/handles_container.hpp>
24 #include <boost/range/iterator_range.hpp>
26 namespace boost { namespace spirit
28 ///////////////////////////////////////////////////////////////////////////
30 ///////////////////////////////////////////////////////////////////////////
32 struct use_directive<qi::domain, tag::raw> // enables raw
36 namespace boost { namespace spirit { namespace qi
38 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
41 using spirit::raw_type;
43 template <typename Subject>
44 struct raw_directive : unary_parser<raw_directive<Subject> >
46 typedef Subject subject_type;
47 raw_directive(Subject const& subject_)
48 : subject(subject_) {}
50 template <typename Context, typename Iterator>
53 typedef iterator_range<Iterator> type;
56 template <typename Iterator, typename Context
57 , typename Skipper, typename Attribute>
58 bool parse(Iterator& first, Iterator const& last
59 , Context& context, Skipper const& skipper, Attribute& attr_) const
61 qi::skip_over(first, last, skipper);
63 if (subject.parse(i, last, context, skipper, unused))
65 spirit::traits::assign_to(first, i, attr_);
72 template <typename Context>
73 info what(Context& context) const
75 return info("raw", subject.what(context));
82 ///////////////////////////////////////////////////////////////////////////
83 // Parser generators: make_xxx function (objects)
84 ///////////////////////////////////////////////////////////////////////////
85 template <typename Subject, typename Modifiers>
86 struct make_directive<tag::raw, Subject, Modifiers>
88 typedef raw_directive<Subject> result_type;
89 result_type operator()(unused_type, Subject const& subject, unused_type) const
91 return result_type(subject);
96 namespace boost { namespace spirit { namespace traits
98 ///////////////////////////////////////////////////////////////////////////
99 template <typename Subject>
100 struct has_semantic_action<qi::raw_directive<Subject> >
101 : unary_has_semantic_action<Subject> {};
103 ///////////////////////////////////////////////////////////////////////////
104 template <typename Subject, typename Attribute, typename Context
106 struct handles_container<qi::raw_directive<Subject>, Attribute
108 : unary_handles_container<Subject, Attribute, Context, Iterator> {};