• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Boost.Wave: A Standard compliant C++ preprocessor library
3 
4     Definition of the abstract lexer interface
5 
6     http://www.boost.org/
7 
8     Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
9     Software License, Version 1.0. (See accompanying file
10     LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 =============================================================================*/
12 
13 #if !defined(BOOST_SLEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED)
14 #define BOOST_SLEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED
15 
16 #include <boost/wave/language_support.hpp>
17 #include <boost/wave/util/file_position.hpp>
18 #include <boost/wave/cpplexer/cpp_lex_interface.hpp>
19 
20 ///////////////////////////////////////////////////////////////////////////////
21 namespace boost {
22 namespace wave {
23 namespace cpplexer {
24 namespace slex {
25 
26 #if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
27 #define BOOST_WAVE_NEW_LEXER_DECL BOOST_WAVE_DECL
28 #else
29 #define BOOST_WAVE_NEW_LEXER_DECL
30 #endif
31 
32 ///////////////////////////////////////////////////////////////////////////////
33 //
34 //  new_lexer_gen: generates a new instance of the required C++ lexer
35 //
36 ///////////////////////////////////////////////////////////////////////////////
37 template <
38     typename IteratorT,
39     typename PositionT = boost::wave::util::file_position_type
40 >
41 struct BOOST_WAVE_NEW_LEXER_DECL new_lexer_gen
42 {
43 //  The NewLexer function allows the opaque generation of a new lexer object.
44 //  It is coupled to the token type to allow to decouple the lexer/token
45 //  configurations at compile time.
46     static lex_input_interface<slex_token<PositionT> > *
47     new_lexer(IteratorT const &first, IteratorT const &last,
48         PositionT const &pos, boost::wave::language_support language);
49 };
50 
51 #undef BOOST_WAVE_NEW_LEXER_DECL
52 
53 ///////////////////////////////////////////////////////////////////////////////
54 //
55 //  The slex_input_interface helps to instantiate a concrete lexer to be used
56 //  by the Wave preprocessor module.
57 //  This is done to allow compile time reduction.
58 //
59 ///////////////////////////////////////////////////////////////////////////////
60 
61 template <typename TokenT>
62 struct slex_input_interface
63 :   lex_input_interface<TokenT>
64 {
65     typedef typename lex_input_interface<TokenT>::position_type position_type;
66 
~slex_input_interfaceboost::wave::cpplexer::slex::slex_input_interface67     ~slex_input_interface() {}
68 
69 //  The new_lexer function allows the opaque generation of a new lexer object.
70 //  It is coupled to the token type to allow to distinguish different
71 //  lexer/token configurations at compile time.
72     template <typename IteratorT>
73     static lex_input_interface<TokenT> *
new_lexerboost::wave::cpplexer::slex::slex_input_interface74     new_lexer(IteratorT const &first, IteratorT const &last,
75         position_type const &pos, boost::wave::language_support language)
76     {
77         return new_lexer_gen<IteratorT, position_type>::new_lexer (first, last,
78             pos, language);
79     }
80 };
81 
82 ///////////////////////////////////////////////////////////////////////////////
83 }   // namespace slex
84 }   // namespace cpplexer
85 }   // namespace wave
86 }   // namespace boost
87 
88 #endif // !defined(BOOST_SLEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED)
89