]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/wave/src/cpplexer/re2clex/cpp_re.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / wave / src / cpplexer / re2clex / cpp_re.cpp
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 <ctime>
21 #include <cstdlib>
22 #include <cstdio>
23 #include <cstring>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <fcntl.h>
27
28 #include <boost/wave/wave_config.hpp> // configuration data
29
30 #if defined(BOOST_HAS_UNISTD_H)
31 #include <unistd.h>
32 #else
33 #include <io.h>
34 #endif
35
36 #include <boost/detail/workaround.hpp>
37
38 #include <boost/wave/token_ids.hpp>
39 #include <boost/wave/cpplexer/re2clex/aq.hpp>
40 #include <boost/wave/cpplexer/re2clex/scanner.hpp>
41 #include <boost/wave/cpplexer/re2clex/cpp_re.hpp>
42
43 // this must occur after all of the includes and before any code appears
44 #ifdef BOOST_HAS_ABI_HEADERS
45 #include BOOST_ABI_PREFIX
46 #endif
47
48 ///////////////////////////////////////////////////////////////////////////////
49 #if defined(BOOST_MSVC)
50 #pragma warning (disable: 4101) // 'foo' : unreferenced local variable
51 #pragma warning (disable: 4102) // 'foo' : unreferenced label
52 #endif
53
54 ///////////////////////////////////////////////////////////////////////////////
55 namespace boost {
56 namespace wave {
57 namespace cpplexer {
58 namespace re2clex {
59
60 bool is_backslash(uchar *p, uchar *end, int &len)
61 {
62 if (*p == '\\') {
63 len = 1;
64 return true;
65 }
66 else if (*p == '?' && *(p+1) == '?' && (p+2 < end && *(p+2) == '/')) {
67 len = 3;
68 return true;
69 }
70 return false;
71 }
72
73 ///////////////////////////////////////////////////////////////////////////////
74 // Special wrapper class holding the current cursor position
75 uchar_wrapper::uchar_wrapper (uchar *base_cursor, std::size_t column)
76 : base_cursor(base_cursor), column(column)
77 {}
78
79 uchar_wrapper& uchar_wrapper::operator++()
80 {
81 ++base_cursor;
82 ++column;
83 return *this;
84 }
85
86 uchar_wrapper& uchar_wrapper::operator--()
87 {
88 --base_cursor;
89 --column;
90 return *this;
91 }
92
93 uchar uchar_wrapper::operator* () const
94 {
95 return *base_cursor;
96 }
97
98 uchar_wrapper::operator uchar *() const
99 {
100 return base_cursor;
101 }
102
103 std::ptrdiff_t
104 operator- (uchar_wrapper const& lhs, uchar_wrapper const& rhs)
105 {
106 return lhs.base_cursor - rhs.base_cursor;
107 }
108
109 } // namespace re2clex
110 } // namespace cpplexer
111 } // namespace wave
112 } // namespace boost
113
114 // the suffix header occurs after all of the code
115 #ifdef BOOST_HAS_ABI_HEADERS
116 #include BOOST_ABI_SUFFIX
117 #endif
118