Chris@16
|
1 // Copyright (c) 2001-2011 Hartmut Kaiser
|
Chris@16
|
2 //
|
Chris@16
|
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5
|
Chris@16
|
6 #if !defined(BOOST_SPIRIT_QI_AUTO_NOV_29_2009_0336PM)
|
Chris@16
|
7 #define BOOST_SPIRIT_QI_AUTO_NOV_29_2009_0336PM
|
Chris@16
|
8
|
Chris@16
|
9 #if defined(_MSC_VER)
|
Chris@16
|
10 #pragma once
|
Chris@16
|
11 #endif
|
Chris@16
|
12
|
Chris@16
|
13 #include <boost/spirit/home/support/common_terminals.hpp>
|
Chris@16
|
14 #include <boost/spirit/home/support/info.hpp>
|
Chris@16
|
15 #include <boost/spirit/home/support/container.hpp>
|
Chris@16
|
16 #include <boost/spirit/home/support/detail/hold_any.hpp>
|
Chris@16
|
17 #include <boost/spirit/home/qi/domain.hpp>
|
Chris@16
|
18 #include <boost/spirit/home/qi/meta_compiler.hpp>
|
Chris@16
|
19 #include <boost/spirit/home/qi/skip_over.hpp>
|
Chris@16
|
20 #include <boost/spirit/home/qi/parser.hpp>
|
Chris@16
|
21 #include <boost/spirit/home/qi/auto/create_parser.hpp>
|
Chris@16
|
22 #include <boost/mpl/bool.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
25 namespace boost { namespace spirit
|
Chris@16
|
26 {
|
Chris@16
|
27 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
28 // Enablers
|
Chris@16
|
29 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
30 template <>
|
Chris@16
|
31 struct use_terminal<qi::domain, tag::auto_> // enables auto_
|
Chris@16
|
32 : mpl::true_ {};
|
Chris@16
|
33 }}
|
Chris@16
|
34
|
Chris@16
|
35 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
36 namespace boost { namespace spirit { namespace qi
|
Chris@16
|
37 {
|
Chris@16
|
38 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
Chris@16
|
39 using spirit::auto_;
|
Chris@16
|
40 #endif
|
Chris@16
|
41 using spirit::auto_type;
|
Chris@16
|
42
|
Chris@16
|
43 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
44 template <typename Modifiers>
|
Chris@16
|
45 struct auto_parser
|
Chris@16
|
46 : parser<auto_parser<Modifiers> >
|
Chris@16
|
47 {
|
Chris@16
|
48 template <typename Context, typename Iterator>
|
Chris@16
|
49 struct attribute
|
Chris@16
|
50 {
|
Chris@16
|
51 typedef spirit::hold_any type;
|
Chris@16
|
52 };
|
Chris@16
|
53
|
Chris@16
|
54 auto_parser(Modifiers const& modifiers)
|
Chris@16
|
55 : modifiers_(modifiers) {}
|
Chris@16
|
56
|
Chris@16
|
57 template <typename Iterator, typename Context, typename Skipper
|
Chris@16
|
58 , typename Attribute>
|
Chris@16
|
59 bool parse(Iterator& first, Iterator const& last
|
Chris@16
|
60 , Context& context, Skipper const& skipper, Attribute& attr) const
|
Chris@16
|
61 {
|
Chris@16
|
62 return compile<qi::domain>(create_parser<Attribute>(), modifiers_)
|
Chris@16
|
63 .parse(first, last, context, skipper, attr);
|
Chris@16
|
64 }
|
Chris@16
|
65
|
Chris@16
|
66 template <typename Context>
|
Chris@16
|
67 info what(Context& /*context*/) const
|
Chris@16
|
68 {
|
Chris@16
|
69 return info("auto_");
|
Chris@16
|
70 }
|
Chris@16
|
71
|
Chris@16
|
72 Modifiers modifiers_;
|
Chris@16
|
73 };
|
Chris@16
|
74
|
Chris@16
|
75 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
76 // Generator generators: make_xxx function (objects)
|
Chris@16
|
77 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
78 template <typename Modifiers>
|
Chris@16
|
79 struct make_primitive<tag::auto_, Modifiers>
|
Chris@16
|
80 {
|
Chris@16
|
81 typedef auto_parser<Modifiers> result_type;
|
Chris@16
|
82
|
Chris@16
|
83 result_type operator()(unused_type, Modifiers const& modifiers) const
|
Chris@16
|
84 {
|
Chris@16
|
85 return result_type(modifiers);
|
Chris@16
|
86 }
|
Chris@16
|
87 };
|
Chris@16
|
88 }}}
|
Chris@16
|
89
|
Chris@16
|
90 #endif
|