1 /*=============================================================================
2 Boost.Wave: A Standard compliant C++ preprocessor library
3
4 Copyright (c) 2001 Daniel C. Nuffer
5 Copyright (c) 2001-2012 Hartmut Kaiser.
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8
9 TODO:
10 It also may be necessary to add $ to identifiers, for asm.
11 handle errors better.
12 have some easier way to parse strings instead of files (done)
13 =============================================================================*/
14
15 #define BOOST_WAVE_SOURCE 1
16
17 // disable stupid compiler warnings
18 #include <boost/config/warning_disable.hpp>
19
20 #include <cstddef>
21
22 #include <boost/wave/wave_config.hpp> // configuration data
23
24 #if defined(BOOST_HAS_UNISTD_H)
25 #include <unistd.h>
26 #else
27 #include <io.h>
28 #endif
29
30 #include <boost/detail/workaround.hpp>
31
32 #include <boost/wave/token_ids.hpp>
33 #include <boost/wave/cpplexer/re2clex/scanner.hpp>
34 #include <boost/wave/cpplexer/re2clex/cpp_re.hpp>
35
36 // this must occur after all of the includes and before any code appears
37 #ifdef BOOST_HAS_ABI_HEADERS
38 #include BOOST_ABI_PREFIX
39 #endif
40
41 ///////////////////////////////////////////////////////////////////////////////
42 #if defined(BOOST_MSVC)
43 #pragma warning (disable: 4101) // 'foo' : unreferenced local variable
44 #pragma warning (disable: 4102) // 'foo' : unreferenced label
45 #endif
46
47 ///////////////////////////////////////////////////////////////////////////////
48 namespace boost {
49 namespace wave {
50 namespace cpplexer {
51 namespace re2clex {
52
is_backslash(uchar * p,uchar * end,int & len)53 bool is_backslash(uchar *p, uchar *end, int &len)
54 {
55 if (*p == '\\') {
56 len = 1;
57 return true;
58 }
59 else if (*p == '?' && *(p+1) == '?' && (p+2 < end && *(p+2) == '/')) {
60 len = 3;
61 return true;
62 }
63 return false;
64 }
65
66 ///////////////////////////////////////////////////////////////////////////////
67 // Special wrapper class holding the current cursor position
uchar_wrapper(uchar * base_cursor,std::size_t column)68 uchar_wrapper::uchar_wrapper (uchar *base_cursor, std::size_t column)
69 : base_cursor(base_cursor), column(column)
70 {}
71
operator ++()72 uchar_wrapper& uchar_wrapper::operator++()
73 {
74 ++base_cursor;
75 ++column;
76 return *this;
77 }
78
operator --()79 uchar_wrapper& uchar_wrapper::operator--()
80 {
81 --base_cursor;
82 --column;
83 return *this;
84 }
85
operator *() const86 uchar uchar_wrapper::operator* () const
87 {
88 return *base_cursor;
89 }
90
operator uchar*() const91 uchar_wrapper::operator uchar *() const
92 {
93 return base_cursor;
94 }
95
96 std::ptrdiff_t
operator -(uchar_wrapper const & lhs,uchar_wrapper const & rhs)97 operator- (uchar_wrapper const& lhs, uchar_wrapper const& rhs)
98 {
99 return lhs.base_cursor - rhs.base_cursor;
100 }
101
102 } // namespace re2clex
103 } // namespace cpplexer
104 } // namespace wave
105 } // namespace boost
106
107 // the suffix header occurs after all of the code
108 #ifdef BOOST_HAS_ABI_HEADERS
109 #include BOOST_ABI_SUFFIX
110 #endif
111
112