1 /*============================================================================= 2 Boost.Wave: A Standard compliant C++ preprocessor library 3 4 Sample: IDL lexer 5 6 http://www.boost.org/ 7 8 Copyright (c) 2001-2010 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 #include <boost/config.hpp> 14 15 #if defined(BOOST_HAS_UNISTD_H) 16 #include <unistd.h> 17 #else 18 #include <io.h> 19 #endif 20 21 #include <boost/assert.hpp> 22 #include <boost/detail/workaround.hpp> 23 24 // reuse the token ids and re2c helper functions from the default C++ lexer 25 #include <boost/wave/token_ids.hpp> 26 #include <boost/wave/cpplexer/re2clex/aq.hpp> 27 #include <boost/wave/cpplexer/re2clex/scanner.hpp> 28 #include <boost/wave/cpplexer/cpplexer_exceptions.hpp> 29 30 #include "idl_re.hpp" 31 32 #if defined(_MSC_VER) && !defined(__COMO__) 33 #pragma warning (disable: 4101) // 'foo' : unreferenced local variable 34 #pragma warning (disable: 4102) // 'foo' : unreferenced label 35 #endif 36 37 #define YYCTYPE uchar 38 #define YYCURSOR cursor 39 #define YYLIMIT s->lim 40 #define YYMARKER s->ptr 41 #define YYFILL(n) {cursor = fill(s, cursor);} 42 43 //#define BOOST_WAVE_RET(i) {s->cur = cursor; return (i);} 44 #define BOOST_WAVE_RET(i) \ 45 { \ 46 s->line += count_backslash_newlines(s, cursor); \ 47 s->cur = cursor; \ 48 return (i); \ 49 } \ 50 /**/ 51 52 /////////////////////////////////////////////////////////////////////////////// 53 namespace boost { 54 namespace wave { 55 namespace idllexer { 56 namespace re2clex { 57 is_backslash(boost::wave::cpplexer::re2clex::uchar * p,boost::wave::cpplexer::re2clex::uchar * end,int & len)58bool is_backslash( 59 boost::wave::cpplexer::re2clex::uchar *p, 60 boost::wave::cpplexer::re2clex::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 /////////////////////////////////////////////////////////////////////////////// 75 } // namespace re2clex 76 } // namespace idllexer 77 } // namespace wave 78 } // namespace boost 79