1 /*=============================================================================
2 Boost.Wave: A Standard compliant C++ preprocessor library
4 Definition of the abstract lexer interface
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 =============================================================================*/
13 #if !defined(IDL_LEX_INTERFACE_HPP_INCLUDED)
14 #define IDL_LEX_INTERFACE_HPP_INCLUDED
16 #include <boost/wave/util/file_position.hpp>
17 #include <boost/wave/language_support.hpp>
18 #include <boost/wave/cpplexer/cpp_lex_interface_generator.hpp>
20 ///////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////
27 // new_lexer_gen: generates a new instance of the required C++ lexer
29 ///////////////////////////////////////////////////////////////////////////////
32 typename PositionT = boost::wave::util::file_position_type
36 // The NewLexer function allows the opaque generation of a new lexer object.
37 // It is coupled to the token type to allow to decouple the lexer/token
38 // configurations at compile time.
39 static cpplexer::lex_input_interface<
40 cpplexer::lex_token<PositionT>
42 new_lexer(IteratorT const &first, IteratorT const &last,
43 PositionT const &pos, boost::wave::language_support language);
46 ///////////////////////////////////////////////////////////////////////////////
48 // The lex_input_interface decouples the lex_iterator_shim from the actual
49 // lexer. This is done to allow compile time reduction.
50 // Thanks to JCAB for having this idea.
52 ///////////////////////////////////////////////////////////////////////////////
54 template <typename TokenT>
55 struct lex_input_interface_generator
56 : cpplexer::lex_input_interface<TokenT>
58 typedef typename cpplexer::lex_input_interface<TokenT>::position_type position_type;
60 // The new_lexer function allows the opaque generation of a new lexer object.
61 // It is coupled to the token type to allow to distinguish different
62 // lexer/token configurations at compile time.
63 template <typename IteratorT>
64 static cpplexer::lex_input_interface<TokenT> *
65 new_lexer(IteratorT const &first, IteratorT const &last,
66 position_type const &pos, boost::wave::language_support language)
68 return new_lexer_gen<IteratorT, position_type>::new_lexer (first, last,
73 ///////////////////////////////////////////////////////////////////////////////
74 } // namespace cpplexer
78 #endif // !defined(IDL_LEX_INTERFACE_HPP_INCLUDED)