• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Boost.Wave: A Standard compliant C++ preprocessor library
3 
4     Definition of the abstract lexer interface for the xpressive lexer
5 
6     http://www.boost.org/
7 
8     Copyright (c) 2001-2010 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_XLEX_INTERFACE_HPP)
14 #define BOOST_XLEX_INTERFACE_HPP
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 xlex {
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 = 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 wave::cpplexer::lex_input_interface<wave::cpplexer::lex_token<PositionT> > *
47     new_lexer(IteratorT const &first, IteratorT const &last,
48         PositionT const &pos, wave::language_support language);
49 };
50 
51 #undef BOOST_WAVE_NEW_LEXER_DECL
52 
53 ///////////////////////////////////////////////////////////////////////////////
54 //
55 //  The xlex_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 xlex_input_interface
63 :   lex_input_interface<TokenT>
64 {
65     typedef typename wave::cpplexer::lex_input_interface<TokenT>::position_type
66         position_type;
67 
~xlex_input_interfaceboost::wave::cpplexer::xlex::xlex_input_interface68     ~xlex_input_interface() {}
69 
70 //  The new_lexer function allows the opaque generation of a new lexer object.
71 //  It is coupled to the token type to allow to distinguish different
72 //  lexer/token configurations at compile time.
73     template <typename IteratorT>
74     static wave::cpplexer::lex_input_interface<TokenT> *
new_lexerboost::wave::cpplexer::xlex::xlex_input_interface75     new_lexer(IteratorT const &first, IteratorT const &last,
76         position_type const &pos, wave::language_support language)
77     {
78         return new_lexer_gen<IteratorT, position_type>::new_lexer (first, last,
79             pos, language);
80     }
81 };
82 
83 ///////////////////////////////////////////////////////////////////////////////
84 }   // namespace xlex
85 }   // namespace cpplexer
86 }   // namespace wave
87 }   // namespace boost
88 
89 #endif // !defined(BOOST_XLEX_INTERFACE_HPP)
90