• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*=============================================================================
2    Copyright (c) 2002-2003 Joel de Guzman
3    Copyright (c) 2002-2003 Hartmut Kaiser
4    Copyright (c) 2003 Martin Wille
5    http://spirit.sourceforge.net/
6
7    Use, modification and distribution is subject to the Boost Software
8    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9    http://www.boost.org/LICENSE_1_0.txt)
10=============================================================================*/
11#if !defined(BOOST_SPIRIT_PARSER_TRAITS_IPP)
12#define BOOST_SPIRIT_PARSER_TRAITS_IPP
13
14#include <boost/spirit/home/classic/core/composite/operators.hpp>
15
16///////////////////////////////////////////////////////////////////////////////
17namespace boost { namespace spirit {
18
19BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
20
21namespace impl
22{
23
24
25    ///////////////////////////////////////////////////////////////////////////
26    struct parser_type_traits_base {
27
28        BOOST_STATIC_CONSTANT(bool, is_alternative = false);
29        BOOST_STATIC_CONSTANT(bool, is_sequence = false);
30        BOOST_STATIC_CONSTANT(bool, is_sequential_or = false);
31        BOOST_STATIC_CONSTANT(bool, is_intersection = false);
32        BOOST_STATIC_CONSTANT(bool, is_difference = false);
33        BOOST_STATIC_CONSTANT(bool, is_exclusive_or = false);
34        BOOST_STATIC_CONSTANT(bool, is_optional = false);
35        BOOST_STATIC_CONSTANT(bool, is_kleene_star = false);
36        BOOST_STATIC_CONSTANT(bool, is_positive = false);
37    };
38
39    template <typename ParserT>
40    struct parser_type_traits : public parser_type_traits_base {
41
42    //  no definition here, fallback for all not explicitly mentioned parser
43    //  types
44    };
45
46    template <typename A, typename B>
47    struct parser_type_traits<alternative<A, B> >
48    :   public parser_type_traits_base {
49
50        BOOST_STATIC_CONSTANT(bool, is_alternative = true);
51    };
52
53    template <typename A, typename B>
54    struct parser_type_traits<sequence<A, B> >
55    :   public parser_type_traits_base {
56
57        BOOST_STATIC_CONSTANT(bool, is_sequence = true);
58    };
59
60    template <typename A, typename B>
61    struct parser_type_traits<sequential_or<A, B> >
62    :   public parser_type_traits_base {
63
64        BOOST_STATIC_CONSTANT(bool, is_sequential_or = true);
65    };
66
67    template <typename A, typename B>
68    struct parser_type_traits<intersection<A, B> >
69    :   public parser_type_traits_base {
70
71        BOOST_STATIC_CONSTANT(bool, is_intersection = true);
72    };
73
74    template <typename A, typename B>
75    struct parser_type_traits<difference<A, B> >
76    :   public parser_type_traits_base {
77
78        BOOST_STATIC_CONSTANT(bool, is_difference = true);
79    };
80
81    template <typename A, typename B>
82    struct parser_type_traits<exclusive_or<A, B> >
83    :   public parser_type_traits_base {
84
85        BOOST_STATIC_CONSTANT(bool, is_exclusive_or = true);
86    };
87
88    template <typename S>
89    struct parser_type_traits<optional<S> >
90    :   public parser_type_traits_base {
91
92        BOOST_STATIC_CONSTANT(bool, is_optional = true);
93    };
94
95    template <typename S>
96    struct parser_type_traits<kleene_star<S> >
97    :   public parser_type_traits_base {
98
99        BOOST_STATIC_CONSTANT(bool, is_kleene_star = true);
100    };
101
102    template <typename S>
103    struct parser_type_traits<positive<S> >
104    :   public parser_type_traits_base {
105
106        BOOST_STATIC_CONSTANT(bool, is_positive = true);
107    };
108
109}   // namespace impl
110
111///////////////////////////////////////////////////////////////////////////////
112BOOST_SPIRIT_CLASSIC_NAMESPACE_END
113
114}} // namespace boost::spirit
115
116#endif // !defined(BOOST_SPIRIT_PARSER_TRAITS_IPP)
117