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