Line data Source code
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_WAVE_LEX_INTERFACE_GENERATOR_HPP_INCLUDED) 14 : #define BOOST_WAVE_LEX_INTERFACE_GENERATOR_HPP_INCLUDED 15 : 16 : #include <boost/wave/wave_config.hpp> 17 : #include <boost/wave/util/file_position.hpp> 18 : #include <boost/wave/language_support.hpp> 19 : #include <boost/wave/cpplexer/cpp_lex_interface.hpp> 20 : #include <boost/wave/cpplexer/cpp_lex_token.hpp> // lex_token 21 : 22 : // this must occur after all of the includes and before any code appears 23 : #ifdef BOOST_HAS_ABI_HEADERS 24 : #include BOOST_ABI_PREFIX 25 : #endif 26 : 27 : // suppress warnings about dependent classes not being exported from the dll 28 : #ifdef BOOST_MSVC 29 : #pragma warning(push) 30 : #pragma warning(disable : 4251 4231 4660) 31 : #endif 32 : 33 : /////////////////////////////////////////////////////////////////////////////// 34 : namespace boost { 35 : namespace wave { 36 : namespace cpplexer { 37 : 38 : #if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0 39 : #define BOOST_WAVE_NEW_LEXER_DECL BOOST_WAVE_DECL 40 : #else 41 : #define BOOST_WAVE_NEW_LEXER_DECL 42 : #endif 43 : 44 : /////////////////////////////////////////////////////////////////////////////// 45 : // 46 : // new_lexer_gen: generates a new instance of the required C++ lexer 47 : // 48 : /////////////////////////////////////////////////////////////////////////////// 49 : template < 50 : typename IteratorT, 51 : typename PositionT = boost::wave::util::file_position_type, 52 : typename TokenT = lex_token<PositionT> 53 : > 54 : struct BOOST_WAVE_NEW_LEXER_DECL new_lexer_gen 55 : { 56 : // The NewLexer function allows the opaque generation of a new lexer object. 57 : // It is coupled to the token type to allow to decouple the lexer/token 58 : // configurations at compile time. 59 : static lex_input_interface<TokenT> * 60 : new_lexer(IteratorT const &first, IteratorT const &last, 61 : PositionT const &pos, boost::wave::language_support language); 62 : }; 63 : 64 : #undef BOOST_WAVE_NEW_LEXER_DECL 65 : 66 : /////////////////////////////////////////////////////////////////////////////// 67 : // 68 : // The lex_input_interface_generator helps to instantiate a concrete lexer 69 : // to be used by the Wave preprocessor module. 70 : // This is done to allow compile time reduction. 71 : // 72 : /////////////////////////////////////////////////////////////////////////////// 73 : 74 : template <typename TokenT> 75 : struct lex_input_interface_generator 76 : : lex_input_interface<TokenT> 77 : { 78 : typedef typename lex_input_interface<TokenT>::position_type position_type; 79 : 80 : lex_input_interface_generator() {} 81 : ~lex_input_interface_generator() {} 82 : 83 : // The new_lexer function allows the opaque generation of a new lexer object. 84 : // It is coupled to the token type to allow to distinguish different 85 : // lexer/token configurations at compile time. 86 : template <typename IteratorT> 87 : static lex_input_interface<TokenT> * 88 0 : new_lexer(IteratorT const &first, IteratorT const &last, 89 : position_type const &pos, boost::wave::language_support language) 90 : { 91 0 : return new_lexer_gen<IteratorT, position_type, TokenT>::new_lexer ( 92 : first, last, pos, language); 93 : } 94 : }; 95 : 96 : /////////////////////////////////////////////////////////////////////////////// 97 : } // namespace cpplexer 98 : } // namespace wave 99 : } // namespace boost 100 : 101 : #ifdef BOOST_MSVC 102 : #pragma warning(pop) 103 : #endif 104 : 105 : // the suffix header occurs after all of the code 106 : #ifdef BOOST_HAS_ABI_HEADERS 107 : #include BOOST_ABI_SUFFIX 108 : #endif 109 : 110 : #endif // !defined(BOOST_WAVE_LEX_INTERFACE_GENERATOR_HPP_INCLUDED)