1 // Copyright (c) 2001-2011 Hartmut Kaiser
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #if !defined(BOOST_SPIRIT_QI_AUTO_NOV_29_2009_0336PM)
7 #define BOOST_SPIRIT_QI_AUTO_NOV_29_2009_0336PM
13 #include <boost/spirit/home/support/common_terminals.hpp>
14 #include <boost/spirit/home/support/info.hpp>
15 #include <boost/spirit/home/support/container.hpp>
16 #include <boost/spirit/home/support/detail/hold_any.hpp>
17 #include <boost/spirit/home/qi/domain.hpp>
18 #include <boost/spirit/home/qi/meta_compiler.hpp>
19 #include <boost/spirit/home/qi/skip_over.hpp>
20 #include <boost/spirit/home/qi/parser.hpp>
21 #include <boost/spirit/home/qi/auto/create_parser.hpp>
22 #include <boost/mpl/bool.hpp>
24 ///////////////////////////////////////////////////////////////////////////////
25 namespace boost { namespace spirit
27 ///////////////////////////////////////////////////////////////////////////
29 ///////////////////////////////////////////////////////////////////////////
31 struct use_terminal<qi::domain, tag::auto_> // enables auto_
35 ///////////////////////////////////////////////////////////////////////////////
36 namespace boost { namespace spirit { namespace qi
38 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
41 using spirit::auto_type;
43 ///////////////////////////////////////////////////////////////////////////
44 template <typename Modifiers>
46 : parser<auto_parser<Modifiers> >
48 template <typename Context, typename Iterator>
51 typedef spirit::hold_any type;
54 auto_parser(Modifiers const& modifiers)
55 : modifiers_(modifiers) {}
57 template <typename Iterator, typename Context, typename Skipper
59 bool parse(Iterator& first, Iterator const& last
60 , Context& context, Skipper const& skipper, Attribute& attr) const
62 return compile<qi::domain>(create_parser<Attribute>(), modifiers_)
63 .parse(first, last, context, skipper, attr);
66 template <typename Context>
67 info what(Context& /*context*/) const
75 ///////////////////////////////////////////////////////////////////////////
76 // Generator generators: make_xxx function (objects)
77 ///////////////////////////////////////////////////////////////////////////
78 template <typename Modifiers>
79 struct make_primitive<tag::auto_, Modifiers>
81 typedef auto_parser<Modifiers> result_type;
83 result_type operator()(unused_type, Modifiers const& modifiers) const
85 return result_type(modifiers);