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/
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
14 #include <boost/spirit/home/classic/core/composite/operators.hpp>
16 ///////////////////////////////////////////////////////////////////////////////
17 namespace boost { namespace spirit {
19 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
25 ///////////////////////////////////////////////////////////////////////////
26 struct parser_type_traits_base {
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);
39 template <typename ParserT>
40 struct parser_type_traits : public parser_type_traits_base {
42 // no definition here, fallback for all not explicitly mentioned parser
46 template <typename A, typename B>
47 struct parser_type_traits<alternative<A, B> >
48 : public parser_type_traits_base {
50 BOOST_STATIC_CONSTANT(bool, is_alternative = true);
53 template <typename A, typename B>
54 struct parser_type_traits<sequence<A, B> >
55 : public parser_type_traits_base {
57 BOOST_STATIC_CONSTANT(bool, is_sequence = true);
60 template <typename A, typename B>
61 struct parser_type_traits<sequential_or<A, B> >
62 : public parser_type_traits_base {
64 BOOST_STATIC_CONSTANT(bool, is_sequential_or = true);
67 template <typename A, typename B>
68 struct parser_type_traits<intersection<A, B> >
69 : public parser_type_traits_base {
71 BOOST_STATIC_CONSTANT(bool, is_intersection = true);
74 template <typename A, typename B>
75 struct parser_type_traits<difference<A, B> >
76 : public parser_type_traits_base {
78 BOOST_STATIC_CONSTANT(bool, is_difference = true);
81 template <typename A, typename B>
82 struct parser_type_traits<exclusive_or<A, B> >
83 : public parser_type_traits_base {
85 BOOST_STATIC_CONSTANT(bool, is_exclusive_or = true);
89 struct parser_type_traits<optional<S> >
90 : public parser_type_traits_base {
92 BOOST_STATIC_CONSTANT(bool, is_optional = true);
96 struct parser_type_traits<kleene_star<S> >
97 : public parser_type_traits_base {
99 BOOST_STATIC_CONSTANT(bool, is_kleene_star = true);
102 template <typename S>
103 struct parser_type_traits<positive<S> >
104 : public parser_type_traits_base {
106 BOOST_STATIC_CONSTANT(bool, is_positive = true);
111 ///////////////////////////////////////////////////////////////////////////////
112 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
114 }} // namespace boost::spirit
116 #endif // !defined(BOOST_SPIRIT_PARSER_TRAITS_IPP)