9
3

slex_interface.hpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*=============================================================================
  2. Boost.Wave: A Standard compliant C++ preprocessor library
  3. Definition of the abstract lexer interface
  4. http://www.boost.org/
  5. Copyright (c) 2001-2012 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(SLEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED)
  10. #define SLEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_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 {
  16. namespace wave {
  17. namespace cpplexer {
  18. namespace slex {
  19. #if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
  20. #define BOOST_WAVE_NEW_LEXER_DECL BOOST_WAVE_DECL
  21. #else
  22. #define BOOST_WAVE_NEW_LEXER_DECL
  23. #endif
  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 = boost::wave::util::file_position_type
  32. >
  33. struct BOOST_WAVE_NEW_LEXER_DECL 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 lex_input_interface<slex_token<PositionT> > *
  39. new_lexer(IteratorT const &first, IteratorT const &last,
  40. PositionT const &pos, boost::wave::language_support language);
  41. };
  42. #undef BOOST_WAVE_NEW_LEXER_DECL
  43. ///////////////////////////////////////////////////////////////////////////////
  44. //
  45. // The slex_input_interface helps to instantiate a concrete lexer to be used
  46. // by the Wave preprocessor module.
  47. // This is done to allow compile time reduction.
  48. //
  49. ///////////////////////////////////////////////////////////////////////////////
  50. template <typename TokenT>
  51. struct slex_input_interface
  52. : lex_input_interface<TokenT>
  53. {
  54. typedef typename lex_input_interface<TokenT>::position_type position_type;
  55. ~slex_input_interface() {}
  56. // The new_lexer function allows the opaque generation of a new lexer object.
  57. // It is coupled to the token type to allow to distinguish different
  58. // lexer/token configurations at compile time.
  59. template <typename IteratorT>
  60. static lex_input_interface<TokenT> *
  61. new_lexer(IteratorT const &first, IteratorT const &last,
  62. position_type const &pos, boost::wave::language_support language)
  63. {
  64. return new_lexer_gen<IteratorT, position_type>::new_lexer (first, last,
  65. pos, language);
  66. }
  67. };
  68. ///////////////////////////////////////////////////////////////////////////////
  69. } // namespace slex
  70. } // namespace cpplexer
  71. } // namespace wave
  72. } // namespace boost
  73. #endif // !defined(SLEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED)