1 //  Copyright (c) 2001-2011 Hartmut Kaiser
2 //  Copyright (c) 2001-2011 Joel de Guzman
3 //
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(BOOST_SPIRIT_LEXER_TYPE_APR_20_2009_0759PM)
8 #define BOOST_SPIRIT_LEXER_TYPE_APR_20_2009_0759PM
9 
10 #if defined(_MSC_VER)
11 #pragma once
12 #endif
13 
14 #include <boost/mpl/has_xxx.hpp>
15 #include <boost/spirit/home/lex/domain.hpp>
16 
17 namespace boost { namespace spirit { namespace lex
18 {
19     template <typename Derived>
20     struct lexer_type
21     {
22         struct lexer_id;
23         typedef Derived derived_type;
24         typedef lex::domain domain;
25 
26         // Requirement: l.collect(def, state, targetstate) -> void
27         //
28         //  l:           a lexer component
29         //  def:         token definition container
30         //  state:       lexer state this token definition needs to be added to
31         //  targetstate: an optional lexer state the lexer should be switched
32         //               into after matching this token
33 
derivedboost::spirit::lex::lexer_type34         Derived const& derived() const
35         {
36             return *static_cast<Derived const*>(this);
37         }
38     };
39 
40     template <typename Derived>
41     struct primitive_lexer : lexer_type<Derived>
42     {
43         struct primitive_lexer_id;
44     };
45 
46     template <typename Derived>
47     struct unary_lexer : lexer_type<Derived>
48     {
49         struct unary_lexer_id;
50 
51         // Requirement: l.subject -> subject lexer component
52         //
53         // l:   a unary lexer component
54 
55         // Requirement: L::subject_type -> subject lexer component type
56         //
57         // L:   a unary lexer component type
58     };
59 
60     template <typename Derived>
61     struct nary_lexer : lexer_type<Derived>
62     {
63         struct nary_lexer_id;
64 
65         // Requirement: l.elements -> fusion sequence
66         //
67         // l:   a composite lexer component
68 
69         // Requirement: L::elements_type -> fusion sequence
70         //
71         // L:   a composite lexer component type
72     };
73 
74 }}}
75 
76 namespace boost { namespace spirit { namespace traits // classification
77 {
78     namespace detail
79     {
80         BOOST_MPL_HAS_XXX_TRAIT_DEF(lexer_id)
81         BOOST_MPL_HAS_XXX_TRAIT_DEF(primitive_lexer_id)
82         BOOST_MPL_HAS_XXX_TRAIT_DEF(unary_lexer_id)
83         BOOST_MPL_HAS_XXX_TRAIT_DEF(nary_lexer_id)
84     }
85 
86     template <typename T>
87     struct is_lexer : detail::has_lexer_id<T> {};
88 
89     template <typename T>
90     struct is_primitive_lexer : detail::has_primitive_lexer_id<T> {};
91 
92     template <typename T>
93     struct is_unary_lexer : detail::has_unary_lexer_id<T> {};
94 
95     template <typename T>
96     struct is_nary_lexer : detail::has_nary_lexer_id<T> {};
97 
98 }}}
99 
100 #endif
101