lexertl_interface.hpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*=============================================================================
  2. Boost.Wave: A Standard compliant C++ preprocessor library
  3. Definition of the abstract lexer interface for the lexertl based C++ lexer
  4. http://www.boost.org/
  5. Copyright (c) 2001-2010 Hartmut Kaiser. Distributed under the Boost
  6. Software License, Version 1.0. (See accompanying file
  7. LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. =============================================================================*/
  9. #if !defined(BOOST_WAVE_LEXERTL_INTERFACE_HPP_INCLUDED)
  10. #define BOOST_WAVE_LEXERTL_INTERFACE_HPP_INCLUDED
  11. #include <boost/wave/language_support.hpp>
  12. #include <boost/wave/util/file_position.hpp>
  13. #include <boost/wave/cpplexer/cpp_lex_interface.hpp>
  14. ///////////////////////////////////////////////////////////////////////////////
  15. namespace boost { namespace wave { namespace cpplexer { namespace lexertl
  16. {
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //
  19. // new_lexer_gen: generates a new instance of the required C++ lexer
  20. //
  21. ///////////////////////////////////////////////////////////////////////////////
  22. template <
  23. typename IteratorT,
  24. typename PositionT = wave::util::file_position_type
  25. >
  26. struct new_lexer_gen
  27. {
  28. // The NewLexer function allows the opaque generation of a new lexer object.
  29. // It is coupled to the token type to allow to decouple the lexer/token
  30. // configurations at compile time.
  31. static wave::cpplexer::lex_input_interface<
  32. wave::cpplexer::lex_token<PositionT>
  33. > *
  34. new_lexer(IteratorT const &first, IteratorT const &last,
  35. PositionT const &pos, wave::language_support language);
  36. };
  37. ///////////////////////////////////////////////////////////////////////////////
  38. //
  39. // The lexertl_input_interface helps to instantiate a concrete lexer
  40. // to be used by the Wave preprocessor module.
  41. // This is done to allow compile time reduction by separation of the lexer
  42. // iterator exposed to the Wave library and the lexer implementation.
  43. //
  44. ///////////////////////////////////////////////////////////////////////////////
  45. template <typename TokenT>
  46. struct lexertl_input_interface
  47. : wave::cpplexer::lex_input_interface<TokenT>
  48. {
  49. typedef typename wave::cpplexer::lex_input_interface<TokenT>::position_type
  50. position_type;
  51. // The new_lexer function allows the opaque generation of a new lexer object.
  52. // It is coupled to the token type to allow to distinguish different
  53. // lexer/token configurations at compile time.
  54. template <typename IteratorT>
  55. static wave::cpplexer::lex_input_interface<TokenT> *
  56. new_lexer(IteratorT const &first, IteratorT const &last,
  57. position_type const &pos, wave::language_support language)
  58. {
  59. return new_lexer_gen<IteratorT, position_type>::new_lexer (first, last,
  60. pos, language);
  61. }
  62. };
  63. ///////////////////////////////////////////////////////////////////////////////
  64. }}}} // namespace boost::wave::cpplexer::lexertl
  65. #endif // !defined(BOOST_WAVE_LEXERTL_INTERFACE_HPP_INCLUDED)