1 /*============================================================================= 2 Boost.Wave: A Standard compliant C++ preprocessor library 3 4 Definition of the abstract lexer interface for the lexertl based C++ 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_WAVE_LEXERTL_INTERFACE_HPP_INCLUDED) 14 #define BOOST_WAVE_LEXERTL_INTERFACE_HPP_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 { namespace wave { namespace cpplexer { namespace lexertl 22 { 23 24 /////////////////////////////////////////////////////////////////////////////// 25 // 26 // new_lexer_gen: generates a new instance of the required C++ lexer 27 // 28 /////////////////////////////////////////////////////////////////////////////// 29 template < 30 typename IteratorT, 31 typename PositionT = wave::util::file_position_type 32 > 33 struct new_lexer_gen 34 { 35 // The NewLexer function allows the opaque generation of a new lexer object. 36 // It is coupled to the token type to allow to decouple the lexer/token 37 // configurations at compile time. 38 static wave::cpplexer::lex_input_interface< 39 wave::cpplexer::lex_token<PositionT> 40 > * 41 new_lexer(IteratorT const &first, IteratorT const &last, 42 PositionT const &pos, wave::language_support language); 43 }; 44 45 /////////////////////////////////////////////////////////////////////////////// 46 // 47 // The lexertl_input_interface helps to instantiate a concrete lexer 48 // to be used by the Wave preprocessor module. 49 // This is done to allow compile time reduction by separation of the lexer 50 // iterator exposed to the Wave library and the lexer implementation. 51 // 52 /////////////////////////////////////////////////////////////////////////////// 53 54 template <typename TokenT> 55 struct lexertl_input_interface 56 : wave::cpplexer::lex_input_interface<TokenT> 57 { 58 typedef typename wave::cpplexer::lex_input_interface<TokenT>::position_type 59 position_type; 60 61 // The new_lexer function allows the opaque generation of a new lexer object. 62 // It is coupled to the token type to allow to distinguish different 63 // lexer/token configurations at compile time. 64 template <typename IteratorT> 65 static wave::cpplexer::lex_input_interface<TokenT> * new_lexerboost::wave::cpplexer::lexertl::lexertl_input_interface66 new_lexer(IteratorT const &first, IteratorT const &last, 67 position_type const &pos, wave::language_support language) 68 { 69 return new_lexer_gen<IteratorT, position_type>::new_lexer (first, last, 70 pos, language); 71 } 72 }; 73 74 /////////////////////////////////////////////////////////////////////////////// 75 }}}} // namespace boost::wave::cpplexer::lexertl 76 77 #endif // !defined(BOOST_WAVE_LEXERTL_INTERFACE_HPP_INCLUDED) 78