add boost on mac

This commit is contained in:
Bassem Girgis
2019-08-10 16:38:17 -05:00
parent 861b918727
commit be945cb63b
14105 changed files with 2714968 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001 Daniel C. Nuffer.
Copyright (c) 2001-2012 Hartmut Kaiser.
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(AQ_HPP_A21D9145_B643_44C0_81E7_DB346DD67EE1_INCLUDED)
#define AQ_HPP_A21D9145_B643_44C0_81E7_DB346DD67EE1_INCLUDED
#include <boost/wave/wave_config.hpp>
#include <cstdlib>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace cpplexer {
namespace re2clex {
typedef std::size_t aq_stdelement;
typedef struct tag_aq_queuetype
{
std::size_t head;
std::size_t tail;
std::size_t size;
std::size_t max_size;
aq_stdelement* queue;
} aq_queuetype;
typedef aq_queuetype* aq_queue;
BOOST_WAVE_DECL int aq_enqueue(aq_queue q, aq_stdelement e);
int aq_enqueue_front(aq_queue q, aq_stdelement e);
int aq_serve(aq_queue q, aq_stdelement *e);
BOOST_WAVE_DECL int aq_pop(aq_queue q);
#define AQ_EMPTY(q) (q->size == 0)
#define AQ_FULL(q) (q->size == q->max_size)
int aq_grow(aq_queue q);
BOOST_WAVE_DECL aq_queue aq_create(void);
BOOST_WAVE_DECL void aq_terminate(aq_queue q);
///////////////////////////////////////////////////////////////////////////////
} // namespace re2clex
} // namespace cpplexer
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(AQ_HPP_A21D9145_B643_44C0_81E7_DB346DD67EE1_INCLUDED)

View File

@@ -0,0 +1,410 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Re2C based C++ lexer
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(CPP_RE_HPP_B76C4F5E_63E9_4B8A_9975_EC32FA6BF027_INCLUDED)
#define CPP_RE_HPP_B76C4F5E_63E9_4B8A_9975_EC32FA6BF027_INCLUDED
#include <boost/assert.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpplexer/cpplexer_exceptions.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
// suppress warnings about dependent classes not being exported from the dll
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable : 4251 4231 4660)
#endif
///////////////////////////////////////////////////////////////////////////////
#define YYCTYPE uchar
#define YYCURSOR cursor
#define YYLIMIT limit
#define YYMARKER marker
#define YYFILL(n) \
{ \
cursor = uchar_wrapper(fill(s, cursor), cursor.column); \
limit = uchar_wrapper (s->lim); \
} \
/**/
#include <iostream>
///////////////////////////////////////////////////////////////////////////////
#define BOOST_WAVE_UPDATE_CURSOR() \
{ \
s->line += count_backslash_newlines(s, cursor); \
s->curr_column = cursor.column; \
s->cur = cursor; \
s->lim = limit; \
s->ptr = marker; \
} \
/**/
///////////////////////////////////////////////////////////////////////////////
#define BOOST_WAVE_RET(i) \
{ \
BOOST_WAVE_UPDATE_CURSOR() \
if (s->cur > s->lim) \
return T_EOF; /* may happen for empty files */ \
return (i); \
} \
/**/
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace cpplexer {
namespace re2clex {
template<typename Iterator>
struct Scanner;
///////////////////////////////////////////////////////////////////////////////
// The scanner function to call whenever a new token is requested
template<typename Iterator>
BOOST_WAVE_DECL boost::wave::token_id scan(Scanner<Iterator> *s);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Utility functions
#define RE2C_ASSERT BOOST_ASSERT
template<typename Iterator>
int get_one_char(Scanner<Iterator> *s)
{
RE2C_ASSERT(s->first <= s->act && s->act <= s->last);
if (s->act < s->last)
return *(s->act)++;
return -1;
}
template<typename Iterator>
std::ptrdiff_t rewind_stream (Scanner<Iterator> *s, int cnt)
{
std::advance(s->act, cnt);
RE2C_ASSERT(s->first <= s->act && s->act <= s->last);
return std::distance(s->first, s->act);
}
template<typename Iterator>
std::size_t get_first_eol_offset(Scanner<Iterator>* s)
{
if (!AQ_EMPTY(s->eol_offsets))
{
return s->eol_offsets->queue[s->eol_offsets->head];
}
else
{
return (unsigned int)-1;
}
}
template<typename Iterator>
void adjust_eol_offsets(Scanner<Iterator>* s, std::size_t adjustment)
{
aq_queue q;
std::size_t i;
if (!s->eol_offsets)
s->eol_offsets = aq_create();
q = s->eol_offsets;
if (AQ_EMPTY(q))
return;
i = q->head;
while (i != q->tail)
{
if (adjustment > q->queue[i])
q->queue[i] = 0;
else
q->queue[i] -= adjustment;
++i;
if (i == q->max_size)
i = 0;
}
if (adjustment > q->queue[i])
q->queue[i] = 0;
else
q->queue[i] -= adjustment;
}
template<typename Iterator>
int count_backslash_newlines(Scanner<Iterator> *s, uchar *cursor)
{
std::size_t diff, offset;
int skipped = 0;
/* figure out how many backslash-newlines skipped over unknowingly. */
diff = cursor - s->bot;
offset = get_first_eol_offset(s);
while (offset <= diff && offset != (unsigned int)-1)
{
skipped++;
aq_pop(s->eol_offsets);
offset = get_first_eol_offset(s);
}
return skipped;
}
BOOST_WAVE_DECL bool is_backslash(uchar *p, uchar *end, int &len);
#define BOOST_WAVE_BSIZE 196608
template<typename Iterator>
uchar *fill(Scanner<Iterator> *s, uchar *cursor)
{
using namespace std; // some systems have memcpy etc. in namespace std
if(!s->eof)
{
uchar* p;
std::ptrdiff_t cnt = s->tok - s->bot;
if(cnt)
{
if (NULL == s->lim)
s->lim = s->top;
memmove(s->bot, s->tok, s->lim - s->tok);
s->tok = s->cur = s->bot;
s->ptr -= cnt;
cursor -= cnt;
s->lim -= cnt;
adjust_eol_offsets(s, cnt);
}
if((s->top - s->lim) < BOOST_WAVE_BSIZE)
{
uchar *buf = (uchar*) malloc(((s->lim - s->bot) + BOOST_WAVE_BSIZE)*sizeof(uchar));
if (buf == 0)
{
(*s->error_proc)(s, lexing_exception::unexpected_error,
"Out of memory!");
/* get the scanner to stop */
*cursor = 0;
return cursor;
}
memmove(buf, s->tok, s->lim - s->tok);
s->tok = s->cur = buf;
s->ptr = &buf[s->ptr - s->bot];
cursor = &buf[cursor - s->bot];
s->lim = &buf[s->lim - s->bot];
s->top = &s->lim[BOOST_WAVE_BSIZE];
free(s->bot);
s->bot = buf;
}
cnt = std::distance(s->act, s->last);
if (cnt > BOOST_WAVE_BSIZE)
cnt = BOOST_WAVE_BSIZE;
uchar * dst = s->lim;
for (std::ptrdiff_t idx = 0; idx < cnt; ++idx)
{
*dst++ = *s->act++;
}
if (cnt != BOOST_WAVE_BSIZE)
{
s->eof = &s->lim[cnt]; *(s->eof)++ = '\0';
}
/* backslash-newline erasing time */
/* first scan for backslash-newline and erase them */
for (p = s->lim; p < s->lim + cnt - 2; ++p)
{
int len = 0;
if (is_backslash(p, s->lim + cnt, len))
{
if (*(p+len) == '\n')
{
int offset = len + 1;
memmove(p, p + offset, s->lim + cnt - p - offset);
cnt -= offset;
--p;
aq_enqueue(s->eol_offsets, p - s->bot + 1);
}
else if (*(p+len) == '\r')
{
if (*(p+len+1) == '\n')
{
int offset = len + 2;
memmove(p, p + offset, s->lim + cnt - p - offset);
cnt -= offset;
--p;
}
else
{
int offset = len + 1;
memmove(p, p + offset, s->lim + cnt - p - offset);
cnt -= offset;
--p;
}
aq_enqueue(s->eol_offsets, p - s->bot + 1);
}
}
}
/* FIXME: the following code should be fixed to recognize correctly the
trigraph backslash token */
/* check to see if what we just read ends in a backslash */
if (cnt >= 2)
{
uchar last = s->lim[cnt-1];
uchar last2 = s->lim[cnt-2];
/* check \ EOB */
if (last == '\\')
{
int next = get_one_char(s);
/* check for \ \n or \ \r or \ \r \n straddling the border */
if (next == '\n')
{
--cnt; /* chop the final \, we've already read the \n. */
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
}
else if (next == '\r')
{
int next2 = get_one_char(s);
if (next2 == '\n')
{
--cnt; /* skip the backslash */
}
else
{
/* rewind one, and skip one char */
rewind_stream(s, -1);
--cnt;
}
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
}
else if (next != -1) /* -1 means end of file */
{
/* next was something else, so rewind the stream */
rewind_stream(s, -1);
}
}
/* check \ \r EOB */
else if (last == '\r' && last2 == '\\')
{
int next = get_one_char(s);
if (next == '\n')
{
cnt -= 2; /* skip the \ \r */
}
else
{
/* rewind one, and skip two chars */
rewind_stream(s, -1);
cnt -= 2;
}
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
}
/* check \ \n EOB */
else if (last == '\n' && last2 == '\\')
{
cnt -= 2;
aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot));
}
}
s->lim += cnt;
if (s->eof) /* eof needs adjusting if we erased backslash-newlines */
{
s->eof = s->lim;
*(s->eof)++ = '\0';
}
}
return cursor;
}
#undef BOOST_WAVE_BSIZE
///////////////////////////////////////////////////////////////////////////////
// Special wrapper class holding the current cursor position
struct BOOST_WAVE_DECL uchar_wrapper
{
uchar_wrapper (uchar *base_cursor, std::size_t column = 1);
uchar_wrapper& operator++();
uchar_wrapper& operator--();
uchar operator* () const;
operator uchar *() const;
friend BOOST_WAVE_DECL std::ptrdiff_t
operator- (uchar_wrapper const& lhs, uchar_wrapper const& rhs);
uchar *base_cursor;
std::size_t column;
};
///////////////////////////////////////////////////////////////////////////////
template<typename Iterator>
boost::wave::token_id scan(Scanner<Iterator> *s)
{
BOOST_ASSERT(0 != s->error_proc); // error handler must be given
uchar_wrapper cursor (s->tok = s->cur, s->column = s->curr_column);
uchar_wrapper marker (s->ptr);
uchar_wrapper limit (s->lim);
typedef BOOST_WAVE_STRINGTYPE string_type;
string_type rawstringdelim; // for use with C++11 raw string literals
// include the correct Re2C token definition rules
#if (defined (__FreeBSD__) || defined (__DragonFly__) || defined (__OpenBSD__)) && defined (T_DIVIDE)
#undef T_DIVIDE
#endif
#if BOOST_WAVE_USE_STRICT_LEXER != 0
#include "strict_cpp_re.inc"
#else
#include "cpp_re.inc"
#endif
} /* end of scan */
///////////////////////////////////////////////////////////////////////////////
} // namespace re2clex
} // namespace cpplexer
} // namespace wave
} // namespace boost
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#undef BOOST_WAVE_RET
#undef YYCTYPE
#undef YYCURSOR
#undef YYLIMIT
#undef YYMARKER
#undef YYFILL
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(CPP_RE_HPP_B76C4F5E_63E9_4B8A_9975_EC32FA6BF027_INCLUDED)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,423 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Re2C based C++ lexer
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(CPP_RE2C_LEXER_HPP_B81A2629_D5B1_4944_A97D_60254182B9A8_INCLUDED)
#define CPP_RE2C_LEXER_HPP_B81A2629_D5B1_4944_A97D_60254182B9A8_INCLUDED
#include <string>
#include <cstdio>
#include <cstdarg>
#if defined(BOOST_SPIRIT_DEBUG)
#include <iostream>
#endif // defined(BOOST_SPIRIT_DEBUG)
#include <boost/concept_check.hpp>
#include <boost/assert.hpp>
#include <boost/spirit/include/classic_core.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/language_support.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/util/file_position.hpp>
#include <boost/wave/cpplexer/validate_universal_char.hpp>
#include <boost/wave/cpplexer/cpplexer_exceptions.hpp>
#include <boost/wave/cpplexer/token_cache.hpp>
#include <boost/wave/cpplexer/convert_trigraphs.hpp>
#include <boost/wave/cpplexer/cpp_lex_interface.hpp>
#include <boost/wave/cpplexer/re2clex/scanner.hpp>
#include <boost/wave/cpplexer/re2clex/cpp_re.hpp>
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
#include <boost/wave/cpplexer/detect_include_guards.hpp>
#endif
#include <boost/wave/cpplexer/cpp_lex_interface_generator.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace cpplexer {
namespace re2clex {
///////////////////////////////////////////////////////////////////////////////
//
// encapsulation of the re2c based cpp lexer
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT,
typename PositionT = boost::wave::util::file_position_type,
typename TokenT = lex_token<PositionT> >
class lexer
{
public:
typedef TokenT token_type;
typedef typename token_type::string_type string_type;
lexer(IteratorT const &first, IteratorT const &last,
PositionT const &pos, boost::wave::language_support language_);
~lexer();
token_type& get(token_type&);
void set_position(PositionT const &pos)
{
// set position has to change the file name and line number only
filename = pos.get_file();
scanner.line = pos.get_line();
// scanner.column = scanner.curr_column = pos.get_column();
scanner.file_name = filename.c_str();
}
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
bool has_include_guards(std::string& guard_name) const
{
return guards.detected(guard_name);
}
#endif
// error reporting from the re2c generated lexer
static int report_error(Scanner<IteratorT> const* s, int code, char const *, ...);
private:
static char const *tok_names[];
Scanner<IteratorT> scanner;
string_type filename;
string_type value;
bool at_eof;
boost::wave::language_support language;
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
include_guards<token_type> guards;
#endif
#if BOOST_WAVE_SUPPORT_THREADING == 0
static token_cache<string_type> const cache;
#else
token_cache<string_type> const cache;
#endif
};
///////////////////////////////////////////////////////////////////////////////
// initialize cpp lexer
template <typename IteratorT, typename PositionT, typename TokenT>
inline
lexer<IteratorT, PositionT, TokenT>::lexer(IteratorT const &first,
IteratorT const &last, PositionT const &pos,
boost::wave::language_support language_)
: scanner(first, last),
filename(pos.get_file()), at_eof(false), language(language_)
#if BOOST_WAVE_SUPPORT_THREADING != 0
, cache()
#endif
{
using namespace std; // some systems have memset in std
scanner.line = pos.get_line();
scanner.column = scanner.curr_column = pos.get_column();
scanner.error_proc = report_error;
scanner.file_name = filename.c_str();
#if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
scanner.enable_ms_extensions = true;
#else
scanner.enable_ms_extensions = false;
#endif
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
scanner.act_in_c99_mode = boost::wave::need_c99(language_);
#endif
#if BOOST_WAVE_SUPPORT_IMPORT_KEYWORD != 0
scanner.enable_import_keyword = !boost::wave::need_c99(language_);
#else
scanner.enable_import_keyword = false;
#endif
scanner.detect_pp_numbers = boost::wave::need_prefer_pp_numbers(language_);
scanner.single_line_only = boost::wave::need_single_line(language_);
#if BOOST_WAVE_SUPPORT_CPP0X != 0
scanner.act_in_cpp0x_mode = boost::wave::need_cpp0x(language_);
#else
scanner.act_in_cpp0x_mode = false;
#endif
}
template <typename IteratorT, typename PositionT, typename TokenT>
inline
lexer<IteratorT, PositionT, TokenT>::~lexer()
{
using namespace std; // some systems have free in std
free(scanner.bot);
}
///////////////////////////////////////////////////////////////////////////////
// get the next token from the input stream
template <typename IteratorT, typename PositionT, typename TokenT>
inline TokenT&
lexer<IteratorT, PositionT, TokenT>::get(TokenT& result)
{
if (at_eof)
return result = token_type(); // return T_EOI
std::size_t actline = scanner.line;
token_id id = token_id(scan(&scanner));
switch (id) {
case T_IDENTIFIER:
// test identifier characters for validity (throws if invalid chars found)
value = string_type((char const *)scanner.tok,
scanner.cur-scanner.tok);
if (!boost::wave::need_no_character_validation(language))
impl::validate_identifier_name(value, actline, scanner.column, filename);
break;
case T_STRINGLIT:
case T_CHARLIT:
case T_RAWSTRINGLIT:
// test literal characters for validity (throws if invalid chars found)
value = string_type((char const *)scanner.tok,
scanner.cur-scanner.tok);
if (boost::wave::need_convert_trigraphs(language))
value = impl::convert_trigraphs(value);
if (!boost::wave::need_no_character_validation(language))
impl::validate_literal(value, actline, scanner.column, filename);
break;
#if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
case T_PP_HHEADER:
case T_PP_QHEADER:
case T_PP_INCLUDE:
// convert to the corresponding ..._next token, if appropriate
{
value = string_type((char const *)scanner.tok,
scanner.cur-scanner.tok);
// Skip '#' and whitespace and see whether we find an 'include_next' here.
typename string_type::size_type start = value.find("include");
if (value.compare(start, 12, "include_next", 12) == 0)
id = token_id(id | AltTokenType);
break;
}
#endif
case T_LONGINTLIT: // supported in C++11, C99 and long_long mode
value = string_type((char const *)scanner.tok,
scanner.cur-scanner.tok);
if (!boost::wave::need_long_long(language)) {
// syntax error: not allowed in C++ mode
BOOST_WAVE_LEXER_THROW(lexing_exception, invalid_long_long_literal,
value.c_str(), actline, scanner.column, filename.c_str());
}
break;
case T_OCTALINT:
case T_DECIMALINT:
case T_HEXAINT:
case T_INTLIT:
case T_FLOATLIT:
case T_FIXEDPOINTLIT:
case T_CCOMMENT:
case T_CPPCOMMENT:
case T_SPACE:
case T_SPACE2:
case T_ANY:
case T_PP_NUMBER:
value = string_type((char const *)scanner.tok,
scanner.cur-scanner.tok);
break;
case T_EOF:
// T_EOF is returned as a valid token, the next call will return T_EOI,
// i.e. the actual end of input
at_eof = true;
value.clear();
break;
case T_OR_TRIGRAPH:
case T_XOR_TRIGRAPH:
case T_LEFTBRACE_TRIGRAPH:
case T_RIGHTBRACE_TRIGRAPH:
case T_LEFTBRACKET_TRIGRAPH:
case T_RIGHTBRACKET_TRIGRAPH:
case T_COMPL_TRIGRAPH:
case T_POUND_TRIGRAPH:
if (boost::wave::need_convert_trigraphs(language)) {
value = cache.get_token_value(BASEID_FROM_TOKEN(id));
}
else {
value = string_type((char const *)scanner.tok,
scanner.cur-scanner.tok);
}
break;
case T_ANY_TRIGRAPH:
if (boost::wave::need_convert_trigraphs(language)) {
value = impl::convert_trigraph(
string_type((char const *)scanner.tok));
}
else {
value = string_type((char const *)scanner.tok,
scanner.cur-scanner.tok);
}
break;
default:
if (CATEGORY_FROM_TOKEN(id) != EXTCATEGORY_FROM_TOKEN(id) ||
IS_CATEGORY(id, UnknownTokenType))
{
value = string_type((char const *)scanner.tok,
scanner.cur-scanner.tok);
}
else {
value = cache.get_token_value(id);
}
break;
}
// std::cerr << boost::wave::get_token_name(id) << ": " << value << std::endl;
// the re2c lexer reports the new line number for newline tokens
result = token_type(id, value, PositionT(filename, actline, scanner.column));
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
return guards.detect_guard(result);
#else
return result;
#endif
}
template <typename IteratorT, typename PositionT, typename TokenT>
inline int
lexer<IteratorT, PositionT, TokenT>::report_error(Scanner<IteratorT> const *s, int errcode,
char const *msg, ...)
{
BOOST_ASSERT(0 != s);
BOOST_ASSERT(0 != msg);
using namespace std; // some system have vsprintf in namespace std
char buffer[200]; // should be large enough
va_list params;
va_start(params, msg);
vsprintf(buffer, msg, params);
va_end(params);
BOOST_WAVE_LEXER_THROW_VAR(lexing_exception, errcode, buffer, s->line,
s->column, s->file_name);
// BOOST_UNREACHABLE_RETURN(0);
return 0;
}
///////////////////////////////////////////////////////////////////////////////
//
// lex_functor
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT,
typename PositionT = boost::wave::util::file_position_type,
typename TokenT = typename lexer<IteratorT, PositionT>::token_type>
class lex_functor
: public lex_input_interface_generator<TokenT>
{
public:
typedef TokenT token_type;
lex_functor(IteratorT const &first, IteratorT const &last,
PositionT const &pos, boost::wave::language_support language)
: re2c_lexer(first, last, pos, language)
{}
virtual ~lex_functor() {}
// get the next token from the input stream
token_type& get(token_type& result) { return re2c_lexer.get(result); }
void set_position(PositionT const &pos) { re2c_lexer.set_position(pos); }
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
bool has_include_guards(std::string& guard_name) const
{ return re2c_lexer.has_include_guards(guard_name); }
#endif
private:
lexer<IteratorT, PositionT, TokenT> re2c_lexer;
};
#if BOOST_WAVE_SUPPORT_THREADING == 0
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename PositionT, typename TokenT>
token_cache<typename lexer<IteratorT, PositionT, TokenT>::string_type> const
lexer<IteratorT, PositionT, TokenT>::cache =
token_cache<typename lexer<IteratorT, PositionT, TokenT>::string_type>();
#endif
} // namespace re2clex
///////////////////////////////////////////////////////////////////////////////
//
// The new_lexer_gen<>::new_lexer function (declared in cpp_lex_interface.hpp)
// should be defined inline, if the lex_functor shouldn't be instantiated
// separately from the lex_iterator.
//
// Separate (explicit) instantiation helps to reduce compilation time.
//
///////////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
#define BOOST_WAVE_RE2C_NEW_LEXER_INLINE
#else
#define BOOST_WAVE_RE2C_NEW_LEXER_INLINE inline
#endif
///////////////////////////////////////////////////////////////////////////////
//
// The 'new_lexer' function allows the opaque generation of a new lexer object.
// It is coupled to the iterator type to allow to decouple the lexer/iterator
// configurations at compile time.
//
// This function is declared inside the cpp_lex_token.hpp file, which is
// referenced by the source file calling the lexer and the source file, which
// instantiates the lex_functor. But it is defined here, so it will be
// instantiated only while compiling the source file, which instantiates the
// lex_functor. While the cpp_re2c_token.hpp file may be included everywhere,
// this file (cpp_re2c_lexer.hpp) should be included only once. This allows
// to decouple the lexer interface from the lexer implementation and reduces
// compilation time.
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename PositionT, typename TokenT>
BOOST_WAVE_RE2C_NEW_LEXER_INLINE
lex_input_interface<TokenT> *
new_lexer_gen<IteratorT, PositionT, TokenT>::new_lexer(IteratorT const &first,
IteratorT const &last, PositionT const &pos,
boost::wave::language_support language)
{
using re2clex::lex_functor;
return new lex_functor<IteratorT, PositionT, TokenT>(first, last, pos, language);
}
#undef BOOST_WAVE_RE2C_NEW_LEXER_INLINE
///////////////////////////////////////////////////////////////////////////////
} // namespace cpplexer
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(CPP_RE2C_LEXER_HPP_B81A2629_D5B1_4944_A97D_60254182B9A8_INCLUDED)

View File

@@ -0,0 +1,90 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001 Daniel C. Nuffer.
Copyright (c) 2001-2012 Hartmut Kaiser.
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(SCANNER_HPP_F4FB01EB_E75C_4537_A146_D34B9895EF37_INCLUDED)
#define SCANNER_HPP_F4FB01EB_E75C_4537_A146_D34B9895EF37_INCLUDED
#include <boost/wave/wave_config.hpp>
#include <boost/wave/cpplexer/re2clex/aq.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace cpplexer {
namespace re2clex {
template<typename Iterator>
struct Scanner;
typedef unsigned char uchar;
template<typename Iterator>
struct Scanner {
typedef int (* ReportErrorProc)(struct Scanner const *, int errorcode,
char const *, ...);
Scanner(Iterator const & f, Iterator const & l)
: first(f), act(f), last(l),
bot(0), top(0), eof(0), tok(0), ptr(0), cur(0), lim(0),
eol_offsets(aq_create())
// remaining data members externally initialized
{}
~Scanner()
{
aq_terminate(eol_offsets);
}
Iterator first; /* start of input buffer */
Iterator act; /* act position of input buffer */
Iterator last; /* end (one past last char) of input buffer */
uchar* bot; /* beginning of the current buffer */
uchar* top; /* top of the current buffer */
uchar* eof; /* when we read in the last buffer, will point 1 past the
end of the file, otherwise 0 */
uchar* tok; /* points to the beginning of the current token */
uchar* ptr; /* used for YYMARKER - saves backtracking info */
uchar* cur; /* saves the cursor (maybe is redundant with tok?) */
uchar* lim; /* used for YYLIMIT - points to the end of the buffer */
/* (lim == top) except for the last buffer, it points to
the end of the input (lim == eof - 1) */
std::size_t line; /* current line being lex'ed */
std::size_t column; /* current token start column position */
std::size_t curr_column; /* current column position */
ReportErrorProc error_proc; /* must be != 0, this function is called to
report an error */
char const *file_name; /* name of the lex'ed file */
aq_queue eol_offsets;
bool enable_ms_extensions; /* enable MS extensions */
bool act_in_c99_mode; /* lexer works in C99 mode */
bool detect_pp_numbers; /* lexer should prefer to detect pp-numbers */
bool enable_import_keyword; /* recognize import as a keyword */
bool single_line_only; /* don't report missing eol's in C++ comments */
bool act_in_cpp0x_mode; /* lexer works in C++11 mode */
};
///////////////////////////////////////////////////////////////////////////////
} // namespace re2clex
} // namespace cpplexer
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(SCANNER_HPP_F4FB01EB_E75C_4537_A146_D34B9895EF37_INCLUDED)

File diff suppressed because it is too large Load Diff