Added boost header
This commit is contained in:
139
test/external/boost/wave/cpplexer/convert_trigraphs.hpp
vendored
Normal file
139
test/external/boost/wave/cpplexer/convert_trigraphs.hpp
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
Grammar for universal character validation (see C++ standard: Annex E)
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2011 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(CONVERT_TRIGRAPHS_HK050403_INCLUDED)
|
||||
#define CONVERT_TRIGRAPHS_HK050403_INCLUDED
|
||||
|
||||
#include <boost/wave/wave_config.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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost {
|
||||
namespace wave {
|
||||
namespace cpplexer {
|
||||
namespace impl {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Test, whether the given string represents a valid trigraph sequence
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename StringT>
|
||||
inline bool
|
||||
is_trigraph(StringT const& trigraph)
|
||||
{
|
||||
if (trigraph.size() < 3 || '?' != trigraph[0] || '?' != trigraph[1])
|
||||
return false;
|
||||
|
||||
switch (trigraph[2]) {
|
||||
case '\'': case '=': case '/': case '(':
|
||||
case ')': case '<': case '>': case '!':
|
||||
case '-':
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// convert_trigraph
|
||||
//
|
||||
// The function convert_trigraph() converts a single trigraph character
|
||||
// sequence into the corresponding character.
|
||||
//
|
||||
// If the given character sequence doesn't form a valid trigraph sequence
|
||||
// no conversion is performed.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename StringT>
|
||||
inline StringT
|
||||
convert_trigraph(StringT const &trigraph)
|
||||
{
|
||||
StringT result (trigraph);
|
||||
|
||||
if (is_trigraph(trigraph)) {
|
||||
switch (trigraph[2]) {
|
||||
case '\'': result = "^"; break;
|
||||
case '=': result = "#"; break;
|
||||
case '/': result = "\\"; break;
|
||||
case '(': result = "["; break;
|
||||
case ')': result = "]"; break;
|
||||
case '<': result = "{"; break;
|
||||
case '>': result = "}"; break;
|
||||
case '!': result = "|"; break;
|
||||
case '-': result = "~"; break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// convert_trigraphs
|
||||
//
|
||||
// The function convert_trigraph() converts all trigraphs in the given
|
||||
// string into the corresponding characters.
|
||||
//
|
||||
// If one of the given character sequences doesn't form a valid trigraph
|
||||
// sequence no conversion is performed.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename StringT>
|
||||
inline StringT
|
||||
convert_trigraphs(StringT const &value)
|
||||
{
|
||||
StringT result;
|
||||
typename StringT::size_type pos = 0;
|
||||
typename StringT::size_type pos1 = value.find_first_of ("?", 0);
|
||||
if (StringT::npos != pos1) {
|
||||
do {
|
||||
result += value.substr(pos, pos1-pos);
|
||||
StringT trigraph (value.substr(pos1));
|
||||
if (is_trigraph(trigraph)) {
|
||||
result += convert_trigraph(trigraph);
|
||||
pos1 = value.find_first_of ("?", pos = pos1+3);
|
||||
}
|
||||
else {
|
||||
result += value[pos1];
|
||||
pos1 = value.find_first_of ("?", pos = pos1+1);
|
||||
}
|
||||
} while (StringT::npos != pos1);
|
||||
result += value.substr(pos);
|
||||
}
|
||||
else {
|
||||
result = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // namespace impl
|
||||
} // 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(CONVERT_TRIGRAPHS_HK050403_INCLUDED)
|
||||
|
||||
|
||||
73
test/external/boost/wave/cpplexer/cpp_lex_interface.hpp
vendored
Normal file
73
test/external/boost/wave/cpplexer/cpp_lex_interface.hpp
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
Definition of the abstract lexer interface
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2011 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_LEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED)
|
||||
#define CPP_LEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
#include <boost/wave/util/file_position.hpp>
|
||||
#include <boost/wave/language_support.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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost {
|
||||
namespace wave {
|
||||
namespace cpplexer {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The lex_input_interface decouples the lex_iterator_shim from the actual
|
||||
// lexer. This is done to allow compile time reduction.
|
||||
// Thanks to JCAB for having this idea.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename TokenT>
|
||||
struct lex_input_interface
|
||||
{
|
||||
typedef typename TokenT::position_type position_type;
|
||||
|
||||
lex_input_interface() {}
|
||||
virtual ~lex_input_interface() {}
|
||||
|
||||
virtual TokenT& get(TokenT&) = 0;
|
||||
virtual void set_position(position_type const &pos) = 0;
|
||||
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
|
||||
virtual bool has_include_guards(std::string& guard_name) const = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // namespace cpplexer
|
||||
} // namespace wave
|
||||
} // namespace boost
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// the suffix header occurs after all of the code
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // !defined(CPP_LEX_INTERFACE_HPP_E83F52A4_90AC_4FBE_A9A7_B65F7F94C497_INCLUDED)
|
||||
110
test/external/boost/wave/cpplexer/cpp_lex_interface_generator.hpp
vendored
Normal file
110
test/external/boost/wave/cpplexer/cpp_lex_interface_generator.hpp
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
Definition of the abstract lexer interface
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2011 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(BOOST_WAVE_LEX_INTERFACE_GENERATOR_HPP_INCLUDED)
|
||||
#define BOOST_WAVE_LEX_INTERFACE_GENERATOR_HPP_INCLUDED
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
#include <boost/wave/util/file_position.hpp>
|
||||
#include <boost/wave/language_support.hpp>
|
||||
#include <boost/wave/cpplexer/cpp_lex_interface.hpp>
|
||||
#include <boost/wave/cpplexer/cpp_lex_token.hpp> // lex_token
|
||||
|
||||
// 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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost {
|
||||
namespace wave {
|
||||
namespace cpplexer {
|
||||
|
||||
#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0
|
||||
#define BOOST_WAVE_NEW_LEXER_DECL BOOST_WAVE_DECL
|
||||
#else
|
||||
#define BOOST_WAVE_NEW_LEXER_DECL
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// new_lexer_gen: generates a new instance of the required C++ lexer
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <
|
||||
typename IteratorT,
|
||||
typename PositionT = boost::wave::util::file_position_type,
|
||||
typename TokenT = lex_token<PositionT>
|
||||
>
|
||||
struct BOOST_WAVE_NEW_LEXER_DECL new_lexer_gen
|
||||
{
|
||||
// The NewLexer function allows the opaque generation of a new lexer object.
|
||||
// It is coupled to the token type to allow to decouple the lexer/token
|
||||
// configurations at compile time.
|
||||
static lex_input_interface<TokenT> *
|
||||
new_lexer(IteratorT const &first, IteratorT const &last,
|
||||
PositionT const &pos, boost::wave::language_support language);
|
||||
};
|
||||
|
||||
#undef BOOST_WAVE_NEW_LEXER_DECL
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The lex_input_interface_generator helps to instantiate a concrete lexer
|
||||
// to be used by the Wave preprocessor module.
|
||||
// This is done to allow compile time reduction.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename TokenT>
|
||||
struct lex_input_interface_generator
|
||||
: lex_input_interface<TokenT>
|
||||
{
|
||||
typedef typename lex_input_interface<TokenT>::position_type position_type;
|
||||
|
||||
lex_input_interface_generator() {}
|
||||
~lex_input_interface_generator() {}
|
||||
|
||||
// The new_lexer function allows the opaque generation of a new lexer object.
|
||||
// It is coupled to the token type to allow to distinguish different
|
||||
// lexer/token configurations at compile time.
|
||||
template <typename IteratorT>
|
||||
static lex_input_interface<TokenT> *
|
||||
new_lexer(IteratorT const &first, IteratorT const &last,
|
||||
position_type const &pos, boost::wave::language_support language)
|
||||
{
|
||||
return new_lexer_gen<IteratorT, position_type, TokenT>::new_lexer (
|
||||
first, last, pos, language);
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // namespace cpplexer
|
||||
} // namespace wave
|
||||
} // namespace boost
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// the suffix header occurs after all of the code
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_SUFFIX
|
||||
#endif
|
||||
|
||||
#endif // !defined(BOOST_WAVE_LEX_INTERFACE_GENERATOR_HPP_INCLUDED)
|
||||
243
test/external/boost/wave/cpplexer/cpp_lex_iterator.hpp
vendored
Normal file
243
test/external/boost/wave/cpplexer/cpp_lex_iterator.hpp
vendored
Normal file
@@ -0,0 +1,243 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
Definition of the lexer iterator
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2011 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_LEX_ITERATOR_HPP_AF0C37E3_CBD8_4F33_A225_51CF576FA61F_INCLUDED)
|
||||
#define CPP_LEX_ITERATOR_HPP_AF0C37E3_CBD8_4F33_A225_51CF576FA61F_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
#include <boost/spirit/include/support_multi_pass.hpp>
|
||||
|
||||
#include <boost/wave/util/file_position.hpp>
|
||||
#include <boost/wave/util/functor_input.hpp>
|
||||
#include <boost/wave/cpplexer/cpp_lex_interface_generator.hpp>
|
||||
|
||||
#include <boost/wave/language_support.hpp>
|
||||
|
||||
// this must occur after all of the includes and before any code appears
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
#if 0 != __COMO_VERSION__ || !BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
|
||||
#define BOOST_WAVE_EOF_PREFIX static
|
||||
#else
|
||||
#define BOOST_WAVE_EOF_PREFIX
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost {
|
||||
namespace wave {
|
||||
namespace cpplexer {
|
||||
namespace impl {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// lex_iterator_functor_shim
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename TokenT>
|
||||
class lex_iterator_functor_shim
|
||||
{
|
||||
typedef typename TokenT::position_type position_type;
|
||||
|
||||
public:
|
||||
lex_iterator_functor_shim()
|
||||
#if /*0 != __DECCXX_VER || */defined(__PGI)
|
||||
: eof()
|
||||
#endif
|
||||
{}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
|
||||
lex_iterator_functor_shim& operator= (lex_iterator_functor_shim const& rhs)
|
||||
{ return *this; } // nothing to do here
|
||||
#endif
|
||||
|
||||
// interface to the iterator_policies::split_functor_input policy
|
||||
typedef TokenT result_type;
|
||||
typedef lex_iterator_functor_shim unique;
|
||||
typedef lex_input_interface<TokenT>* shared;
|
||||
|
||||
BOOST_WAVE_EOF_PREFIX result_type const eof;
|
||||
|
||||
template <typename MultiPass>
|
||||
static result_type& get_next(MultiPass& mp, result_type& result)
|
||||
{
|
||||
return mp.shared()->ftor->get(result);
|
||||
}
|
||||
|
||||
// this will be called whenever the last reference to a multi_pass will
|
||||
// be released
|
||||
template <typename MultiPass>
|
||||
static void destroy(MultiPass& mp)
|
||||
{
|
||||
delete mp.shared()->ftor;
|
||||
}
|
||||
|
||||
template <typename MultiPass>
|
||||
static void set_position(MultiPass& mp, position_type const &pos)
|
||||
{
|
||||
mp.shared()->ftor->set_position(pos);
|
||||
}
|
||||
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
|
||||
template <typename MultiPass>
|
||||
static bool has_include_guards(MultiPass& mp, std::string& guard_name)
|
||||
{
|
||||
return mp.shared()->ftor->has_include_guards(guard_name);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// eof token
|
||||
#if 0 != __COMO_VERSION__ || !BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
|
||||
template <typename TokenT>
|
||||
typename lex_iterator_functor_shim<TokenT>::result_type const
|
||||
lex_iterator_functor_shim<TokenT>::eof;
|
||||
#endif // 0 != __COMO_VERSION__
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // namespace impl
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// lex_iterator
|
||||
//
|
||||
// A generic C++ lexer interface class, which allows to plug in different
|
||||
// lexer implementations. The interface between the lexer type used and
|
||||
// the preprocessor component depends on the token type only (template
|
||||
// parameter TokenT).
|
||||
// Additionally, the following requirements apply:
|
||||
//
|
||||
// - the lexer type should have a function implemented, which returnes
|
||||
// the next lexed token from the input stream:
|
||||
// typename TokenT get();
|
||||
// - at the end of the input stream this function should return the
|
||||
// eof token equivalent
|
||||
// - the lexer should implement a constructor taking two iterators
|
||||
// pointing to the beginning and the end of the input stream,
|
||||
// a third parameter containing the name of the parsed input file
|
||||
// and a 4th parameter of the type boost::wave::language_support
|
||||
// which specifies, which language subset should be supported (C++,
|
||||
// C99, C++0x etc.).
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Divide the given functor type into its components (unique and shared)
|
||||
// and build a std::pair from these parts
|
||||
template <typename FunctorData>
|
||||
struct make_multi_pass
|
||||
{
|
||||
typedef
|
||||
std::pair<typename FunctorData::unique, typename FunctorData::shared>
|
||||
functor_data_type;
|
||||
typedef typename FunctorData::result_type result_type;
|
||||
|
||||
typedef boost::spirit::iterator_policies::split_functor_input input_policy;
|
||||
typedef boost::spirit::iterator_policies::ref_counted ownership_policy;
|
||||
#if defined(BOOST_WAVE_DEBUG)
|
||||
typedef boost::spirit::iterator_policies::buf_id_check check_policy;
|
||||
#else
|
||||
typedef boost::spirit::iterator_policies::no_check check_policy;
|
||||
#endif
|
||||
typedef boost::spirit::iterator_policies::split_std_deque storage_policy;
|
||||
|
||||
typedef boost::spirit::iterator_policies::default_policy<
|
||||
ownership_policy, check_policy, input_policy, storage_policy>
|
||||
policy_type;
|
||||
typedef boost::spirit::multi_pass<functor_data_type, policy_type> type;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename TokenT>
|
||||
class lex_iterator
|
||||
: public make_multi_pass<impl::lex_iterator_functor_shim<TokenT> >::type
|
||||
{
|
||||
typedef impl::lex_iterator_functor_shim<TokenT> input_policy_type;
|
||||
|
||||
typedef typename make_multi_pass<input_policy_type>::type base_type;
|
||||
typedef typename make_multi_pass<input_policy_type>::functor_data_type
|
||||
functor_data_type;
|
||||
|
||||
typedef typename input_policy_type::unique unique_functor_type;
|
||||
typedef typename input_policy_type::shared shared_functor_type;
|
||||
|
||||
public:
|
||||
typedef TokenT token_type;
|
||||
|
||||
lex_iterator()
|
||||
{}
|
||||
|
||||
template <typename IteratorT>
|
||||
lex_iterator(IteratorT const &first, IteratorT const &last,
|
||||
typename TokenT::position_type const &pos,
|
||||
boost::wave::language_support language)
|
||||
: base_type(
|
||||
functor_data_type(
|
||||
unique_functor_type(),
|
||||
lex_input_interface_generator<TokenT>
|
||||
::new_lexer(first, last, pos, language)
|
||||
)
|
||||
)
|
||||
{}
|
||||
|
||||
void set_position(typename TokenT::position_type const &pos)
|
||||
{
|
||||
typedef typename TokenT::position_type position_type;
|
||||
|
||||
// set the new position in the current token
|
||||
token_type const& currtoken = this->base_type::dereference(*this);
|
||||
position_type currpos = currtoken.get_position();
|
||||
|
||||
currpos.set_file(pos.get_file());
|
||||
currpos.set_line(pos.get_line());
|
||||
const_cast<token_type&>(currtoken).set_position(currpos);
|
||||
|
||||
// set the new position for future tokens as well
|
||||
if (token_type::string_type::npos !=
|
||||
currtoken.get_value().find_first_of('\n'))
|
||||
{
|
||||
currpos.set_line(pos.get_line() + 1);
|
||||
}
|
||||
unique_functor_type::set_position(*this, currpos);
|
||||
}
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
|
||||
// return, whether the current file has include guards
|
||||
// this function returns meaningful results only if the file was scanned
|
||||
// completely
|
||||
bool has_include_guards(std::string& guard_name) const
|
||||
{
|
||||
return unique_functor_type::has_include_guards(*this, guard_name);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // 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
|
||||
|
||||
#undef BOOST_WAVE_EOF_PREFIX
|
||||
|
||||
#endif // !defined(CPP_LEX_ITERATOR_HPP_AF0C37E3_CBD8_4F33_A225_51CF576FA61F_INCLUDED)
|
||||
335
test/external/boost/wave/cpplexer/cpp_lex_token.hpp
vendored
Normal file
335
test/external/boost/wave/cpplexer/cpp_lex_token.hpp
vendored
Normal file
@@ -0,0 +1,335 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
A generic C++ lexer token definition
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2011 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_TOKEN_HPP_53A13BD2_FBAA_444B_9B8B_FCB225C2BBA8_INCLUDED)
|
||||
#define CPP_TOKEN_HPP_53A13BD2_FBAA_444B_9B8B_FCB225C2BBA8_INCLUDED
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
#if BOOST_WAVE_SERIALIZATION != 0
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#endif
|
||||
#include <boost/wave/util/file_position.hpp>
|
||||
#include <boost/wave/token_ids.hpp>
|
||||
#include <boost/wave/language_support.hpp>
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/pool/singleton_pool.hpp>
|
||||
#include <boost/detail/atomic_count.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 impl {
|
||||
|
||||
template <typename StringTypeT, typename PositionT>
|
||||
class token_data
|
||||
{
|
||||
public:
|
||||
typedef StringTypeT string_type;
|
||||
typedef PositionT position_type;
|
||||
|
||||
// default constructed tokens correspond to EOI tokens
|
||||
token_data()
|
||||
: id(T_EOI), refcnt(1)
|
||||
{}
|
||||
|
||||
// construct an invalid token
|
||||
explicit token_data(int)
|
||||
: id(T_UNKNOWN), refcnt(1)
|
||||
{}
|
||||
|
||||
token_data(token_id id_, string_type const &value_, position_type const &pos_)
|
||||
: id(id_), value(value_), pos(pos_), refcnt(1)
|
||||
{}
|
||||
|
||||
token_data(token_data const& rhs)
|
||||
: id(rhs.id), value(rhs.value), pos(rhs.pos), refcnt(1)
|
||||
{}
|
||||
|
||||
~token_data()
|
||||
{}
|
||||
|
||||
std::size_t addref() { return ++refcnt; }
|
||||
std::size_t release() { return --refcnt; }
|
||||
std::size_t get_refcnt() const { return refcnt; }
|
||||
|
||||
// accessors
|
||||
operator token_id() const { return id; }
|
||||
string_type const &get_value() const { return value; }
|
||||
position_type const &get_position() const { return pos; }
|
||||
|
||||
void set_token_id (token_id id_) { id = id_; }
|
||||
void set_value (string_type const &value_) { value = value_; }
|
||||
void set_position (position_type const &pos_) { pos = pos_; }
|
||||
|
||||
friend bool operator== (token_data const& lhs, token_data const& rhs)
|
||||
{
|
||||
// two tokens are considered equal even if they refer to different
|
||||
// positions
|
||||
return (lhs.id == rhs.id && lhs.value == rhs.value) ? true : false;
|
||||
}
|
||||
|
||||
void init(token_id id_, string_type const &value_, position_type const &pos_)
|
||||
{
|
||||
BOOST_ASSERT(refcnt == 1);
|
||||
id = id_;
|
||||
value = value_;
|
||||
pos = pos_;
|
||||
}
|
||||
|
||||
void init(token_data const& rhs)
|
||||
{
|
||||
BOOST_ASSERT(refcnt == 1);
|
||||
id = rhs.id;
|
||||
value = rhs.value;
|
||||
pos = rhs.pos;
|
||||
}
|
||||
|
||||
static void *operator new(std::size_t size);
|
||||
static void operator delete(void *p, std::size_t size);
|
||||
|
||||
#if defined(BOOST_SPIRIT_DEBUG)
|
||||
// debug support
|
||||
void print (std::ostream &stream) const
|
||||
{
|
||||
stream << get_token_name(id) << "(";
|
||||
for (std::size_t i = 0; i < value.size(); ++i) {
|
||||
switch (value[i]) {
|
||||
case '\r': stream << "\\r"; break;
|
||||
case '\n': stream << "\\n"; break;
|
||||
default:
|
||||
stream << value[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
stream << ")";
|
||||
}
|
||||
#endif // defined(BOOST_SPIRIT_DEBUG)
|
||||
|
||||
#if BOOST_WAVE_SERIALIZATION != 0
|
||||
friend class boost::serialization::access;
|
||||
template<typename Archive>
|
||||
void serialize(Archive &ar, const unsigned int version)
|
||||
{
|
||||
using namespace boost::serialization;
|
||||
ar & make_nvp("id", id);
|
||||
ar & make_nvp("value", value);
|
||||
ar & make_nvp("position", pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
token_id id; // the token id
|
||||
string_type value; // the text, which was parsed into this token
|
||||
position_type pos; // the original file position
|
||||
boost::detail::atomic_count refcnt;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
struct token_data_tag {};
|
||||
|
||||
template <typename StringTypeT, typename PositionT>
|
||||
inline void *
|
||||
token_data<StringTypeT, PositionT>::operator new(std::size_t size)
|
||||
{
|
||||
BOOST_ASSERT(sizeof(token_data<StringTypeT, PositionT>) == size);
|
||||
typedef boost::singleton_pool<
|
||||
token_data_tag, sizeof(token_data<StringTypeT, PositionT>)
|
||||
> pool_type;
|
||||
|
||||
void *ret = pool_type::malloc();
|
||||
if (0 == ret)
|
||||
boost::throw_exception(std::bad_alloc());
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename StringTypeT, typename PositionT>
|
||||
inline void
|
||||
token_data<StringTypeT, PositionT>::operator delete(void *p, std::size_t size)
|
||||
{
|
||||
BOOST_ASSERT(sizeof(token_data<StringTypeT, PositionT>) == size);
|
||||
typedef boost::singleton_pool<
|
||||
token_data_tag, sizeof(token_data<StringTypeT, PositionT>)
|
||||
> pool_type;
|
||||
|
||||
if (0 != p)
|
||||
pool_type::free(p);
|
||||
}
|
||||
|
||||
} // namespace impl
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// forward declaration of the token type
|
||||
template <typename PositionT = boost::wave::util::file_position_type>
|
||||
class lex_token;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// lex_token
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename PositionT>
|
||||
class lex_token
|
||||
{
|
||||
public:
|
||||
typedef BOOST_WAVE_STRINGTYPE string_type;
|
||||
typedef PositionT position_type;
|
||||
|
||||
private:
|
||||
typedef impl::token_data<string_type, position_type> data_type;
|
||||
|
||||
public:
|
||||
// default constructed tokens correspond to EOI tokens
|
||||
lex_token()
|
||||
: data(0)
|
||||
{}
|
||||
|
||||
// construct an invalid token
|
||||
explicit lex_token(int)
|
||||
: data(new data_type(0))
|
||||
{}
|
||||
|
||||
lex_token(lex_token const& rhs)
|
||||
: data(rhs.data)
|
||||
{
|
||||
if (0 != data)
|
||||
data->addref();
|
||||
}
|
||||
|
||||
lex_token(token_id id_, string_type const &value_, PositionT const &pos_)
|
||||
: data(new data_type(id_, value_, pos_))
|
||||
{}
|
||||
|
||||
~lex_token()
|
||||
{
|
||||
if (0 != data && 0 == data->release())
|
||||
delete data;
|
||||
data = 0;
|
||||
}
|
||||
|
||||
lex_token& operator=(lex_token const& rhs)
|
||||
{
|
||||
if (&rhs != this) {
|
||||
if (0 != data && 0 == data->release())
|
||||
delete data;
|
||||
|
||||
data = rhs.data;
|
||||
if (0 != data)
|
||||
data->addref();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// accessors
|
||||
operator token_id() const { return 0 != data ? token_id(*data) : T_EOI; }
|
||||
string_type const &get_value() const { return data->get_value(); }
|
||||
position_type const &get_position() const { return data->get_position(); }
|
||||
bool is_eoi() const { return 0 == data || token_id(*data) == T_EOI; }
|
||||
bool is_valid() const { return 0 != data && token_id(*data) != T_UNKNOWN; }
|
||||
|
||||
void set_token_id (token_id id_) { make_unique(); data->set_token_id(id_); }
|
||||
void set_value (string_type const &value_) { make_unique(); data->set_value(value_); }
|
||||
void set_position (position_type const &pos_) { make_unique(); data->set_position(pos_); }
|
||||
|
||||
friend bool operator== (lex_token const& lhs, lex_token const& rhs)
|
||||
{
|
||||
if (0 == rhs.data)
|
||||
return 0 == lhs.data;
|
||||
if (0 == lhs.data)
|
||||
return false;
|
||||
return *(lhs.data) == *(rhs.data);
|
||||
}
|
||||
|
||||
// debug support
|
||||
#if BOOST_WAVE_DUMP_PARSE_TREE != 0
|
||||
// access functions for the tree_to_xml functionality
|
||||
static int get_token_id(lex_token const &t)
|
||||
{ return token_id(t); }
|
||||
static string_type get_token_value(lex_token const &t)
|
||||
{ return t.get_value(); }
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_SPIRIT_DEBUG)
|
||||
// debug support
|
||||
void print (std::ostream &stream) const
|
||||
{
|
||||
data->print(stream);
|
||||
}
|
||||
#endif // defined(BOOST_SPIRIT_DEBUG)
|
||||
|
||||
private:
|
||||
#if BOOST_WAVE_SERIALIZATION != 0
|
||||
friend class boost::serialization::access;
|
||||
template<typename Archive>
|
||||
void serialize(Archive &ar, const unsigned int version)
|
||||
{
|
||||
data->serialize(ar, version);
|
||||
}
|
||||
#endif
|
||||
|
||||
// make a unique copy of the current object
|
||||
void make_unique()
|
||||
{
|
||||
if (1 == data->get_refcnt())
|
||||
return;
|
||||
|
||||
data_type* newdata = new data_type(*data) ;
|
||||
|
||||
data->release(); // release this reference, can't get zero
|
||||
data = newdata;
|
||||
}
|
||||
|
||||
data_type* data;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// This overload is needed by the multi_pass/functor_input_policy to
|
||||
// validate a token instance. It has to be defined in the same namespace
|
||||
// as the token class itself to allow ADL to find it.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename Position>
|
||||
inline bool
|
||||
token_is_valid(lex_token<Position> const& t)
|
||||
{
|
||||
return t.is_valid();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if defined(BOOST_SPIRIT_DEBUG)
|
||||
template <typename PositionT>
|
||||
inline std::ostream &
|
||||
operator<< (std::ostream &stream, lex_token<PositionT> const &object)
|
||||
{
|
||||
object.print(stream);
|
||||
return stream;
|
||||
}
|
||||
#endif // defined(BOOST_SPIRIT_DEBUG)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // 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_TOKEN_HPP_53A13BD2_FBAA_444B_9B8B_FCB225C2BBA8_INCLUDED)
|
||||
290
test/external/boost/wave/cpplexer/cpplexer_exceptions.hpp
vendored
Normal file
290
test/external/boost/wave/cpplexer/cpplexer_exceptions.hpp
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2011 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(CPPLEXER_EXCEPTIONS_HPP_1A09DE1A_6D1F_4091_AF7F_5F13AB0D31AB_INCLUDED)
|
||||
#define CPPLEXER_EXCEPTIONS_HPP_1A09DE1A_6D1F_4091_AF7F_5F13AB0D31AB_INCLUDED
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
|
||||
// this must occur after all of the includes and before any code appears
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
#include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// helper macro for throwing exceptions
|
||||
#if !defined(BOOST_WAVE_LEXER_THROW)
|
||||
#ifdef BOOST_NO_STRINGSTREAM
|
||||
#include <strstream>
|
||||
#define BOOST_WAVE_LEXER_THROW(cls, code, msg, line, column, name) \
|
||||
{ \
|
||||
using namespace boost::wave; \
|
||||
std::strstream stream; \
|
||||
stream << cls::severity_text(cls::code) << ": " \
|
||||
<< cls::error_text(cls::code); \
|
||||
if ((msg)[0] != 0) stream << ": " << (msg); \
|
||||
stream << std::ends; \
|
||||
std::string throwmsg = stream.str(); stream.freeze(false); \
|
||||
boost::throw_exception(cls(throwmsg.c_str(), cls::code, line, column, \
|
||||
name)); \
|
||||
} \
|
||||
/**/
|
||||
#else
|
||||
#include <sstream>
|
||||
#define BOOST_WAVE_LEXER_THROW(cls, code, msg, line, column, name) \
|
||||
{ \
|
||||
using namespace boost::wave; \
|
||||
std::stringstream stream; \
|
||||
stream << cls::severity_text(cls::code) << ": " \
|
||||
<< cls::error_text(cls::code); \
|
||||
if ((msg)[0] != 0) stream << ": " << (msg); \
|
||||
stream << std::ends; \
|
||||
boost::throw_exception(cls(stream.str().c_str(), cls::code, line, column, \
|
||||
name)); \
|
||||
} \
|
||||
/**/
|
||||
#endif // BOOST_NO_STRINGSTREAM
|
||||
#endif // BOOST_WAVE_LEXER_THROW
|
||||
|
||||
#if !defined(BOOST_WAVE_LEXER_THROW_VAR)
|
||||
#ifdef BOOST_NO_STRINGSTREAM
|
||||
#include <strstream>
|
||||
#define BOOST_WAVE_LEXER_THROW_VAR(cls, codearg, msg, line, column, name) \
|
||||
{ \
|
||||
using namespace boost::wave; \
|
||||
cls::error_code code = static_cast<cls::error_code>(codearg); \
|
||||
std::strstream stream; \
|
||||
stream << cls::severity_text(code) << ": " \
|
||||
<< cls::error_text(code); \
|
||||
if ((msg)[0] != 0) stream << ": " << (msg); \
|
||||
stream << std::ends; \
|
||||
std::string throwmsg = stream.str(); stream.freeze(false); \
|
||||
boost::throw_exception(cls(throwmsg.c_str(), code, line, column, \
|
||||
name)); \
|
||||
} \
|
||||
/**/
|
||||
#else
|
||||
#include <sstream>
|
||||
#define BOOST_WAVE_LEXER_THROW_VAR(cls, codearg, msg, line, column, name) \
|
||||
{ \
|
||||
using namespace boost::wave; \
|
||||
cls::error_code code = static_cast<cls::error_code>(codearg); \
|
||||
std::stringstream stream; \
|
||||
stream << cls::severity_text(code) << ": " \
|
||||
<< cls::error_text(code); \
|
||||
if ((msg)[0] != 0) stream << ": " << (msg); \
|
||||
stream << std::ends; \
|
||||
boost::throw_exception(cls(stream.str().c_str(), code, line, column, \
|
||||
name)); \
|
||||
} \
|
||||
/**/
|
||||
#endif // BOOST_NO_STRINGSTREAM
|
||||
#endif // BOOST_WAVE_LEXER_THROW
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost {
|
||||
namespace wave {
|
||||
namespace cpplexer {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// exception severity
|
||||
namespace util {
|
||||
|
||||
enum severity {
|
||||
severity_remark = 0,
|
||||
severity_warning,
|
||||
severity_error,
|
||||
severity_fatal
|
||||
};
|
||||
|
||||
inline char const *
|
||||
get_severity(severity level)
|
||||
{
|
||||
static char const *severity_text[] =
|
||||
{
|
||||
"remark", // severity_remark
|
||||
"warning", // severity_warning
|
||||
"error", // severity_error
|
||||
"fatal error" // severity_fatal
|
||||
};
|
||||
BOOST_ASSERT(severity_remark <= level && level <= severity_fatal);
|
||||
return severity_text[level];
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// cpplexer_exception, the base class for all specific C++ lexer exceptions
|
||||
class BOOST_SYMBOL_VISIBLE cpplexer_exception
|
||||
: public std::exception
|
||||
{
|
||||
public:
|
||||
cpplexer_exception(int line_, int column_, char const *filename_) throw()
|
||||
: line(line_), column(column_)
|
||||
{
|
||||
unsigned int off = 0;
|
||||
while (off < sizeof(filename)-1 && *filename_)
|
||||
filename[off++] = *filename_++;
|
||||
filename[off] = 0;
|
||||
}
|
||||
~cpplexer_exception() throw() {}
|
||||
|
||||
virtual char const *what() const throw() = 0; // to be overloaded
|
||||
virtual char const *description() const throw() = 0;
|
||||
virtual int get_errorcode() const throw() = 0;
|
||||
virtual int get_severity() const throw() = 0;
|
||||
virtual bool is_recoverable() const throw() = 0;
|
||||
|
||||
int line_no() const throw() { return line; }
|
||||
int column_no() const throw() { return column; }
|
||||
char const *file_name() const throw() { return filename; }
|
||||
|
||||
protected:
|
||||
char filename[512];
|
||||
int line;
|
||||
int column;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// lexing_exception error
|
||||
class BOOST_SYMBOL_VISIBLE lexing_exception :
|
||||
public cpplexer_exception
|
||||
{
|
||||
public:
|
||||
enum error_code {
|
||||
unexpected_error = 0,
|
||||
universal_char_invalid = 1,
|
||||
universal_char_base_charset = 2,
|
||||
universal_char_not_allowed = 3,
|
||||
invalid_long_long_literal = 4,
|
||||
generic_lexing_error = 5,
|
||||
generic_lexing_warning = 6
|
||||
};
|
||||
|
||||
lexing_exception(char const *what_, error_code code, int line_,
|
||||
int column_, char const *filename_) throw()
|
||||
: cpplexer_exception(line_, column_, filename_),
|
||||
level(severity_level(code)), code(code)
|
||||
{
|
||||
unsigned int off = 0;
|
||||
while (off < sizeof(buffer) && *what_)
|
||||
buffer[off++] = *what_++;
|
||||
buffer[off] = 0;
|
||||
}
|
||||
~lexing_exception() throw() {}
|
||||
|
||||
virtual char const *what() const throw()
|
||||
{
|
||||
return "boost::wave::lexing_exception";
|
||||
}
|
||||
virtual char const *description() const throw()
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
virtual int get_severity() const throw()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
virtual int get_errorcode() const throw()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
virtual bool is_recoverable() const throw()
|
||||
{
|
||||
switch (get_errorcode()) {
|
||||
case lexing_exception::universal_char_invalid:
|
||||
case lexing_exception::universal_char_base_charset:
|
||||
case lexing_exception::universal_char_not_allowed:
|
||||
case lexing_exception::invalid_long_long_literal:
|
||||
case lexing_exception::generic_lexing_warning:
|
||||
case lexing_exception::generic_lexing_error:
|
||||
return true; // for now allow all exceptions to be recoverable
|
||||
|
||||
case lexing_exception::unexpected_error:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static char const *error_text(int code)
|
||||
{
|
||||
// error texts in this array must appear in the same order as the items in
|
||||
// the error enum above
|
||||
static char const *preprocess_exception_errors[] = {
|
||||
"unexpected error (should not happen)", // unexpected_error
|
||||
"universal character name specifies an invalid character", // universal_char_invalid
|
||||
"a universal character name cannot designate a character in the "
|
||||
"basic character set", // universal_char_base_charset
|
||||
"this universal character is not allowed in an identifier", // universal_char_not_allowed
|
||||
"long long suffixes are not allowed in pure C++ mode, "
|
||||
"enable long_long mode to allow these", // invalid_long_long_literal
|
||||
"generic lexer error", // generic_lexing_error
|
||||
"generic lexer warning" // generic_lexing_warning
|
||||
};
|
||||
return preprocess_exception_errors[code];
|
||||
}
|
||||
|
||||
static util::severity severity_level(int code)
|
||||
{
|
||||
static util::severity preprocess_exception_severity[] = {
|
||||
util::severity_fatal, // unexpected_error
|
||||
util::severity_error, // universal_char_invalid
|
||||
util::severity_error, // universal_char_base_charset
|
||||
util::severity_error, // universal_char_not_allowed
|
||||
util::severity_warning, // invalid_long_long_literal
|
||||
util::severity_error, // generic_lexing_error
|
||||
util::severity_warning // invalid_long_long_literal
|
||||
};
|
||||
return preprocess_exception_severity[code];
|
||||
}
|
||||
static char const *severity_text(int code)
|
||||
{
|
||||
return util::get_severity(severity_level(code));
|
||||
}
|
||||
|
||||
private:
|
||||
char buffer[512];
|
||||
util::severity level;
|
||||
error_code code;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The is_recoverable() function allows to decide, whether it is possible
|
||||
// simply to continue after a given exception was thrown by Wave.
|
||||
//
|
||||
// This is kind of a hack to allow to recover from certain errors as long as
|
||||
// Wave doesn't provide better means of error recovery.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline bool
|
||||
is_recoverable(lexing_exception const& e)
|
||||
{
|
||||
return e.is_recoverable();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // 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(CPPLEXER_EXCEPTIONS_HPP_1A09DE1A_6D1F_4091_AF7F_5F13AB0D31AB_INCLUDED)
|
||||
263
test/external/boost/wave/cpplexer/detect_include_guards.hpp
vendored
Normal file
263
test/external/boost/wave/cpplexer/detect_include_guards.hpp
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
State machine detecting include guards in an included file.
|
||||
This detects two forms of include guards:
|
||||
|
||||
#ifndef INCLUDE_GUARD_MACRO
|
||||
#define INCLUDE_GUARD_MACRO
|
||||
...
|
||||
#endif
|
||||
|
||||
or
|
||||
|
||||
if !defined(INCLUDE_GUARD_MACRO)
|
||||
#define INCLUDE_GUARD_MACRO
|
||||
...
|
||||
#endif
|
||||
|
||||
note, that the parenthesis are optional (i.e. !defined INCLUDE_GUARD_MACRO
|
||||
will work as well). The code allows for any whitespace, newline and single
|
||||
'#' tokens before the #if/#ifndef and after the final #endif.
|
||||
|
||||
Copyright (c) 2001-2011 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(DETECT_INCLUDE_GUARDS_HK060304_INCLUDED)
|
||||
#define DETECT_INCLUDE_GUARDS_HK060304_INCLUDED
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
#include <boost/wave/token_ids.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 {
|
||||
|
||||
template <typename Token>
|
||||
class include_guards
|
||||
{
|
||||
public:
|
||||
include_guards()
|
||||
: state(&include_guards::state_0), detected_guards(false),
|
||||
current_state(true), if_depth(0)
|
||||
{}
|
||||
|
||||
Token& detect_guard(Token& t)
|
||||
{ return current_state ? (this->*state)(t) : t; }
|
||||
bool detected(std::string& guard_name_) const
|
||||
{
|
||||
if (detected_guards) {
|
||||
guard_name_ = guard_name.c_str();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef Token& state_type(Token& t);
|
||||
state_type include_guards::* state;
|
||||
|
||||
bool detected_guards;
|
||||
bool current_state;
|
||||
typename Token::string_type guard_name;
|
||||
int if_depth;
|
||||
|
||||
state_type state_0, state_1, state_2, state_3, state_4, state_5;
|
||||
state_type state_1a, state_1b, state_1c, state_1d, state_1e;
|
||||
|
||||
bool is_skippable(token_id id) const
|
||||
{
|
||||
return (T_POUND == BASE_TOKEN(id) ||
|
||||
IS_CATEGORY(id, WhiteSpaceTokenType) ||
|
||||
IS_CATEGORY(id, EOLTokenType));
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// state 0: beginning of a file, tries to recognize #ifndef or #if tokens
|
||||
template <typename Token>
|
||||
inline Token&
|
||||
include_guards<Token>::state_0(Token& t)
|
||||
{
|
||||
token_id id = token_id(t);
|
||||
if (T_PP_IFNDEF == id)
|
||||
state = &include_guards::state_1;
|
||||
else if (T_PP_IF == id)
|
||||
state = &include_guards::state_1a;
|
||||
else if (!is_skippable(id))
|
||||
current_state = false;
|
||||
return t;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// state 1: found #ifndef, looking for T_IDENTIFIER
|
||||
template <typename Token>
|
||||
inline Token&
|
||||
include_guards<Token>::state_1(Token& t)
|
||||
{
|
||||
token_id id = token_id(t);
|
||||
if (T_IDENTIFIER == id) {
|
||||
guard_name = t.get_value();
|
||||
state = &include_guards::state_2;
|
||||
}
|
||||
else if (!is_skippable(id))
|
||||
current_state = false;
|
||||
return t;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// state 1a: found T_PP_IF, looking for T_NOT ("!")
|
||||
template <typename Token>
|
||||
inline Token&
|
||||
include_guards<Token>::state_1a(Token& t)
|
||||
{
|
||||
token_id id = token_id(t);
|
||||
if (T_NOT == BASE_TOKEN(id))
|
||||
state = &include_guards::state_1b;
|
||||
else if (!is_skippable(id))
|
||||
current_state = false;
|
||||
return t;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// state 1b: found T_NOT, looking for 'defined'
|
||||
template <typename Token>
|
||||
inline Token&
|
||||
include_guards<Token>::state_1b(Token& t)
|
||||
{
|
||||
token_id id = token_id(t);
|
||||
if (T_IDENTIFIER == id && t.get_value() == "defined")
|
||||
state = &include_guards::state_1c;
|
||||
else if (!is_skippable(id))
|
||||
current_state = false;
|
||||
return t;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// state 1c: found 'defined', looking for (optional) T_LEFTPAREN
|
||||
template <typename Token>
|
||||
inline Token&
|
||||
include_guards<Token>::state_1c(Token& t)
|
||||
{
|
||||
token_id id = token_id(t);
|
||||
if (T_LEFTPAREN == id)
|
||||
state = &include_guards::state_1d;
|
||||
else if (T_IDENTIFIER == id) {
|
||||
guard_name = t.get_value();
|
||||
state = &include_guards::state_2;
|
||||
}
|
||||
else if (!is_skippable(id))
|
||||
current_state = false;
|
||||
return t;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// state 1d: found T_LEFTPAREN, looking for T_IDENTIFIER guard
|
||||
template <typename Token>
|
||||
inline Token&
|
||||
include_guards<Token>::state_1d(Token& t)
|
||||
{
|
||||
token_id id = token_id(t);
|
||||
if (T_IDENTIFIER == id) {
|
||||
guard_name = t.get_value();
|
||||
state = &include_guards::state_1e;
|
||||
}
|
||||
else if (!is_skippable(id))
|
||||
current_state = false;
|
||||
return t;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// state 1e: found T_IDENTIFIER guard, looking for T_RIGHTPAREN
|
||||
template <typename Token>
|
||||
inline Token&
|
||||
include_guards<Token>::state_1e(Token& t)
|
||||
{
|
||||
token_id id = token_id(t);
|
||||
if (T_RIGHTPAREN == id)
|
||||
state = &include_guards::state_2;
|
||||
else if (!is_skippable(id))
|
||||
current_state = false;
|
||||
return t;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// state 2: found T_IDENTIFIER, looking for #define
|
||||
template <typename Token>
|
||||
inline Token&
|
||||
include_guards<Token>::state_2(Token& t)
|
||||
{
|
||||
token_id id = token_id(t);
|
||||
if (T_PP_DEFINE == id)
|
||||
state = &include_guards::state_3;
|
||||
else if (!is_skippable(id))
|
||||
current_state = false;
|
||||
return t;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// state 3: found #define, looking for T_IDENTIFIER as recognized by state 1
|
||||
template <typename Token>
|
||||
inline Token&
|
||||
include_guards<Token>::state_3(Token& t)
|
||||
{
|
||||
token_id id = token_id(t);
|
||||
if (T_IDENTIFIER == id && t.get_value() == guard_name)
|
||||
state = &include_guards::state_4;
|
||||
else if (!is_skippable(id))
|
||||
current_state = false;
|
||||
return t;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// state 4: found guard T_IDENTIFIER, looking for #endif
|
||||
template <typename Token>
|
||||
inline Token&
|
||||
include_guards<Token>::state_4(Token& t)
|
||||
{
|
||||
token_id id = token_id(t);
|
||||
if (T_PP_IF == id || T_PP_IFDEF == id || T_PP_IFNDEF == id)
|
||||
++if_depth;
|
||||
else if (T_PP_ENDIF == id) {
|
||||
if (if_depth > 0)
|
||||
--if_depth;
|
||||
else
|
||||
state = &include_guards::state_5;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// state 5: found final #endif, looking for T_EOF
|
||||
template <typename Token>
|
||||
inline Token&
|
||||
include_guards<Token>::state_5(Token& t)
|
||||
{
|
||||
token_id id = token_id(t);
|
||||
if (T_EOF == id)
|
||||
detected_guards = current_state;
|
||||
else if (!is_skippable(id))
|
||||
current_state = false;
|
||||
return t;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // 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 // !DETECT_INCLUDE_GUARDS_HK060304_INCLUDED
|
||||
64
test/external/boost/wave/cpplexer/re2clex/aq.hpp
vendored
Normal file
64
test/external/boost/wave/cpplexer/re2clex/aq.hpp
vendored
Normal 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-2011 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;
|
||||
|
||||
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);
|
||||
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)
|
||||
57
test/external/boost/wave/cpplexer/re2clex/cpp_re.hpp
vendored
Normal file
57
test/external/boost/wave/cpplexer/re2clex/cpp_re.hpp
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
Re2C based C++ lexer
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2011 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/wave/wave_config.hpp>
|
||||
#include <boost/wave/token_ids.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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost {
|
||||
namespace wave {
|
||||
namespace cpplexer {
|
||||
namespace re2clex {
|
||||
|
||||
struct Scanner;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// The scanner function to call whenever a new token is requested
|
||||
BOOST_WAVE_DECL boost::wave::token_id scan(Scanner *s);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // namespace re2clex
|
||||
} // namespace cpplexer
|
||||
} // namespace wave
|
||||
} // namespace boost
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// 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)
|
||||
429
test/external/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp
vendored
Normal file
429
test/external/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp
vendored
Normal file
@@ -0,0 +1,429 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
Re2C based C++ lexer
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2011 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 const* s, int code, char const *, ...);
|
||||
|
||||
private:
|
||||
static char const *tok_names[];
|
||||
|
||||
Scanner 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_)
|
||||
: 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
|
||||
memset(&scanner, '\0', sizeof(Scanner));
|
||||
scanner.eol_offsets = aq_create();
|
||||
if (first != last) {
|
||||
scanner.first = scanner.act = (uchar *)&(*first);
|
||||
scanner.last = scanner.first + std::distance(first, last);
|
||||
}
|
||||
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
|
||||
aq_terminate(scanner.eol_offsets);
|
||||
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
|
||||
|
||||
unsigned int actline = scanner.line;
|
||||
token_id id = token_id(scan(&scanner));
|
||||
|
||||
switch (static_cast<unsigned int>(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++0x, 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 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 is 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)
|
||||
74
test/external/boost/wave/cpplexer/re2clex/scanner.hpp
vendored
Normal file
74
test/external/boost/wave/cpplexer/re2clex/scanner.hpp
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001 Daniel C. Nuffer.
|
||||
Copyright (c) 2001-2011 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 {
|
||||
|
||||
struct Scanner;
|
||||
typedef unsigned char uchar;
|
||||
typedef int (* ReportErrorProc)(struct Scanner const *, int errorcode,
|
||||
char const *, ...);
|
||||
|
||||
typedef struct Scanner {
|
||||
uchar* first; /* start of input buffer */
|
||||
uchar* act; /* act position of input buffer */
|
||||
uchar* 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) */
|
||||
unsigned int line; /* current line being lex'ed */
|
||||
unsigned int column; /* current token start column position */
|
||||
unsigned int 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++0x mode */
|
||||
} Scanner;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // 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)
|
||||
72
test/external/boost/wave/cpplexer/token_cache.hpp
vendored
Normal file
72
test/external/boost/wave/cpplexer/token_cache.hpp
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2011 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(TOKEN_CACHE_HPP_4D2320B7_1D56_4113_A114_397E70FA438C_INCLUDED)
|
||||
#define TOKEN_CACHE_HPP_4D2320B7_1D56_4113_A114_397E70FA438C_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
#include <boost/wave/token_ids.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 {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The token_cache template is used to cache the tokens corresponding to the
|
||||
// keywords, operators and other constant language elements.
|
||||
//
|
||||
// This avoids repeated construction of these tokens, which is especially
|
||||
// effective when used in conjunction with a copy on write string
|
||||
// implementation (COW string).
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename StringT>
|
||||
class token_cache
|
||||
{
|
||||
public:
|
||||
token_cache()
|
||||
: cache(T_LAST_TOKEN - T_FIRST_TOKEN)
|
||||
{
|
||||
typename std::vector<StringT>::iterator it = cache.begin();
|
||||
for (unsigned int i = T_FIRST_TOKEN; i < T_LAST_TOKEN; ++i, ++it)
|
||||
{
|
||||
*it = StringT(boost::wave::get_token_value(token_id(i)));
|
||||
}
|
||||
}
|
||||
|
||||
StringT const &get_token_value(token_id id) const
|
||||
{
|
||||
return cache[BASEID_FROM_TOKEN(id) - T_FIRST_TOKEN];
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<StringT> cache;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // 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(TOKEN_CACHE_HPP_4D2320B7_1D56_4113_A114_397E70FA438C_INCLUDED)
|
||||
322
test/external/boost/wave/cpplexer/validate_universal_char.hpp
vendored
Normal file
322
test/external/boost/wave/cpplexer/validate_universal_char.hpp
vendored
Normal file
@@ -0,0 +1,322 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
|
||||
Grammar for universal character validation (see C++ standard: Annex E)
|
||||
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2001-2011 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(VALIDATE_UNIVERSAL_CHAR_HPP_55F1B811_CD76_4C72_8344_CBC69CF3B339_INCLUDED)
|
||||
#define VALIDATE_UNIVERSAL_CHAR_HPP_55F1B811_CD76_4C72_8344_CBC69CF3B339_INCLUDED
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/wave/wave_config.hpp>
|
||||
#include <boost/wave/util/file_position.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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost {
|
||||
namespace wave {
|
||||
namespace cpplexer {
|
||||
namespace impl {
|
||||
|
||||
enum universal_char_type {
|
||||
universal_char_type_valid = 0,
|
||||
universal_char_type_invalid = 1,
|
||||
universal_char_type_base_charset = 2,
|
||||
universal_char_type_not_allowed_for_identifiers = 3
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// is_range is a helper function for the classification by brute force
|
||||
// below
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
inline bool
|
||||
in_range(unsigned long ch, unsigned long l, unsigned long u)
|
||||
{
|
||||
return (l <= ch && ch <= u);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// classify_universal_char
|
||||
//
|
||||
// This function classifies an universal character value into 4 subranges:
|
||||
// universal_char_type_valid
|
||||
// the universal character value is valid for identifiers
|
||||
// universal_char_type_invalid
|
||||
// the universal character value is not valid for its usage inside
|
||||
// identifiers (see C++ Standard: 2.2.2 [lex.charset])
|
||||
// universal_char_type_base_charset
|
||||
// the universal character value designates a character from the base
|
||||
// character set
|
||||
// universal_char_type_not_allowed_for_identifiers
|
||||
// the universal character value is not allowed in an identifier
|
||||
//
|
||||
// Implementation note:
|
||||
// This classification isn't implemented very effectively here. This
|
||||
// function should be rewritten with some range run matching algorithm.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline universal_char_type
|
||||
classify_universal_char (unsigned long ch)
|
||||
{
|
||||
// test for invalid characters
|
||||
if (ch <= 0x0020 || in_range(ch, 0x007f, 0x009f))
|
||||
return universal_char_type_invalid;
|
||||
|
||||
// test for characters in the range of the base character set
|
||||
if (in_range(ch, 0x0021, 0x005f) || in_range(ch, 0x0061, 0x007e))
|
||||
return universal_char_type_base_charset;
|
||||
|
||||
// test for additional valid character values (see C++ Standard: Annex E)
|
||||
if (in_range(ch, 0x00c0, 0x00d6) || in_range(ch, 0x00d8, 0x00f6) ||
|
||||
in_range(ch, 0x00f8, 0x01f5) || in_range(ch, 0x01fa, 0x0217) ||
|
||||
in_range(ch, 0x0250, 0x02a8) || in_range(ch, 0x1e00, 0x1e9a) ||
|
||||
in_range(ch, 0x1ea0, 0x1ef9))
|
||||
{
|
||||
return universal_char_type_valid; // Latin
|
||||
}
|
||||
|
||||
if (0x0384 == ch || in_range(ch, 0x0388, 0x038a) ||
|
||||
0x038c == ch || in_range(ch, 0x038e, 0x03a1) ||
|
||||
in_range(ch, 0x03a3, 0x03ce) || in_range(ch, 0x03d0, 0x03d6) ||
|
||||
0x03da == ch || 0x03dc == ch || 0x03de == ch || 0x03e0 == ch ||
|
||||
in_range(ch, 0x03e2, 0x03f3) || in_range(ch, 0x1f00, 0x1f15) ||
|
||||
in_range(ch, 0x1f18, 0x1f1d) || in_range(ch, 0x1f20, 0x1f45) ||
|
||||
in_range(ch, 0x1f48, 0x1f4d) || in_range(ch, 0x1f50, 0x1f57) ||
|
||||
0x1f59 == ch || 0x1f5b == ch || 0x1f5d == ch ||
|
||||
in_range(ch, 0x1f5f, 0x1f7d) || in_range(ch, 0x1f80, 0x1fb4) ||
|
||||
in_range(ch, 0x1fb6, 0x1fbc) || in_range(ch, 0x1fc2, 0x1fc4) ||
|
||||
in_range(ch, 0x1fc6, 0x1fcc) || in_range(ch, 0x1fd0, 0x1fd3) ||
|
||||
in_range(ch, 0x1fd6, 0x1fdb) || in_range(ch, 0x1fe0, 0x1fec) ||
|
||||
in_range(ch, 0x1ff2, 0x1ff4) || in_range(ch, 0x1ff6, 0x1ffc))
|
||||
{
|
||||
return universal_char_type_valid; // Greek
|
||||
}
|
||||
|
||||
if (in_range(ch, 0x0401, 0x040d) || in_range(ch, 0x040f, 0x044f) ||
|
||||
in_range(ch, 0x0451, 0x045c) || in_range(ch, 0x045e, 0x0481) ||
|
||||
in_range(ch, 0x0490, 0x04c4) || in_range(ch, 0x04c7, 0x04c8) ||
|
||||
in_range(ch, 0x04cb, 0x04cc) || in_range(ch, 0x04d0, 0x04eb) ||
|
||||
in_range(ch, 0x04ee, 0x04f5) || in_range(ch, 0x04f8, 0x04f9))
|
||||
{
|
||||
return universal_char_type_valid; // Cyrillic
|
||||
}
|
||||
|
||||
if (in_range(ch, 0x0531, 0x0556) || in_range(ch, 0x0561, 0x0587))
|
||||
return universal_char_type_valid; // Armenian
|
||||
|
||||
if (in_range(ch, 0x05d0, 0x05ea) || in_range(ch, 0x05f0, 0x05f4))
|
||||
return universal_char_type_valid; // Hebrew
|
||||
|
||||
if (in_range(ch, 0x0621, 0x063a) || in_range(ch, 0x0640, 0x0652) ||
|
||||
in_range(ch, 0x0670, 0x06b7) || in_range(ch, 0x06ba, 0x06be) ||
|
||||
in_range(ch, 0x06c0, 0x06ce) || in_range(ch, 0x06e5, 0x06e7))
|
||||
{
|
||||
return universal_char_type_valid; // Arabic
|
||||
}
|
||||
|
||||
if (in_range(ch, 0x0905, 0x0939) || in_range(ch, 0x0958, 0x0962))
|
||||
return universal_char_type_valid; // Devanagari
|
||||
|
||||
if (in_range(ch, 0x0985, 0x098c) || in_range(ch, 0x098f, 0x0990) ||
|
||||
in_range(ch, 0x0993, 0x09a8) || in_range(ch, 0x09aa, 0x09b0) ||
|
||||
0x09b2 == ch || in_range(ch, 0x09b6, 0x09b9) ||
|
||||
in_range(ch, 0x09dc, 0x09dd) || in_range(ch, 0x09df, 0x09e1) ||
|
||||
in_range(ch, 0x09f0, 0x09f1))
|
||||
{
|
||||
return universal_char_type_valid; // Bengali
|
||||
}
|
||||
|
||||
if (in_range(ch, 0x0a05, 0x0a0a) || in_range(ch, 0x0a0f, 0x0a10) ||
|
||||
in_range(ch, 0x0a13, 0x0a28) || in_range(ch, 0x0a2a, 0x0a30) ||
|
||||
in_range(ch, 0x0a32, 0x0a33) || in_range(ch, 0x0a35, 0x0a36) ||
|
||||
in_range(ch, 0x0a38, 0x0a39) || in_range(ch, 0x0a59, 0x0a5c) ||
|
||||
0x0a5e == ch)
|
||||
{
|
||||
return universal_char_type_valid; // Gurmukhi
|
||||
}
|
||||
|
||||
if (in_range(ch, 0x0a85, 0x0a8b) || 0x0a8d == ch ||
|
||||
in_range(ch, 0x0a8f, 0x0a91) || in_range(ch, 0x0a93, 0x0aa8) ||
|
||||
in_range(ch, 0x0aaa, 0x0ab0) || in_range(ch, 0x0ab2, 0x0ab3) ||
|
||||
in_range(ch, 0x0ab5, 0x0ab9) || 0x0ae0 == ch)
|
||||
{
|
||||
return universal_char_type_valid; // Gujarati
|
||||
}
|
||||
|
||||
if (in_range(ch, 0x0b05, 0x0b0c) || in_range(ch, 0x0b0f, 0x0b10) ||
|
||||
in_range(ch, 0x0b13, 0x0b28) || in_range(ch, 0x0b2a, 0x0b30) ||
|
||||
in_range(ch, 0x0b32, 0x0b33) || in_range(ch, 0x0b36, 0x0b39) ||
|
||||
in_range(ch, 0x0b5c, 0x0b5d) || in_range(ch, 0x0b5f, 0x0b61))
|
||||
{
|
||||
return universal_char_type_valid; // Oriya
|
||||
}
|
||||
|
||||
if (in_range(ch, 0x0b85, 0x0b8a) || in_range(ch, 0x0b8e, 0x0b90) ||
|
||||
in_range(ch, 0x0b92, 0x0b95) || in_range(ch, 0x0b99, 0x0b9a) ||
|
||||
0x0b9c == ch || in_range(ch, 0x0b9e, 0x0b9f) ||
|
||||
in_range(ch, 0x0ba3, 0x0ba4) || in_range(ch, 0x0ba8, 0x0baa) ||
|
||||
in_range(ch, 0x0bae, 0x0bb5) || in_range(ch, 0x0bb7, 0x0bb9))
|
||||
{
|
||||
return universal_char_type_valid; // Tamil
|
||||
}
|
||||
|
||||
if (in_range(ch, 0x0c05, 0x0c0c) || in_range(ch, 0x0c0e, 0x0c10) ||
|
||||
in_range(ch, 0x0c12, 0x0c28) || in_range(ch, 0x0c2a, 0x0c33) ||
|
||||
in_range(ch, 0x0c35, 0x0c39) || in_range(ch, 0x0c60, 0x0c61))
|
||||
{
|
||||
return universal_char_type_valid; // Telugu
|
||||
}
|
||||
|
||||
if (in_range(ch, 0x0c85, 0x0c8c) || in_range(ch, 0x0c8e, 0x0c90) ||
|
||||
in_range(ch, 0x0c92, 0x0ca8) || in_range(ch, 0x0caa, 0x0cb3) ||
|
||||
in_range(ch, 0x0cb5, 0x0cb9) || in_range(ch, 0x0ce0, 0x0ce1))
|
||||
{
|
||||
return universal_char_type_valid; // Kannada
|
||||
}
|
||||
|
||||
if (in_range(ch, 0x0d05, 0x0d0c) || in_range(ch, 0x0d0e, 0x0d10) ||
|
||||
in_range(ch, 0x0d12, 0x0d28) || in_range(ch, 0x0d2a, 0x0d39) ||
|
||||
in_range(ch, 0x0d60, 0x0d61))
|
||||
{
|
||||
return universal_char_type_valid; // Malayalam
|
||||
}
|
||||
|
||||
if (in_range(ch, 0x0e01, 0x0e30) || in_range(ch, 0x0e32, 0x0e33) ||
|
||||
in_range(ch, 0x0e40, 0x0e46) || in_range(ch, 0x0e4f, 0x0e5b))
|
||||
{
|
||||
return universal_char_type_valid; // Thai
|
||||
}
|
||||
|
||||
return universal_char_type_not_allowed_for_identifiers;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// validate_identifier_name
|
||||
//
|
||||
// The validate_identifier_name function tests a given identifier name for
|
||||
// its validity with regard to eventually contained universal characters.
|
||||
// These should be in valid ranges (see the function
|
||||
// classify_universal_char above).
|
||||
//
|
||||
// If the identifier name contains invalid or not allowed universal
|
||||
// characters a corresponding lexing_exception is thrown.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename StringT>
|
||||
inline void
|
||||
validate_identifier_name (StringT const &name, int line, int column,
|
||||
StringT const &file_name)
|
||||
{
|
||||
using namespace std; // some systems have strtoul in namespace std::
|
||||
|
||||
typename StringT::size_type pos = name.find_first_of('\\');
|
||||
|
||||
while (StringT::npos != pos) {
|
||||
// the identifier name contains a backslash (must be universal char)
|
||||
BOOST_ASSERT('u' == name[pos+1] || 'U' == name[pos+1]);
|
||||
|
||||
StringT uchar_val(name.substr(pos+2, ('u' == name[pos+1]) ? 4 : 8));
|
||||
universal_char_type type =
|
||||
classify_universal_char(strtoul(uchar_val.c_str(), 0, 16));
|
||||
|
||||
if (universal_char_type_valid != type) {
|
||||
// an invalid char was found, so throw an exception
|
||||
StringT error_uchar(name.substr(pos, ('u' == name[pos+1]) ? 6 : 10));
|
||||
|
||||
if (universal_char_type_invalid == type) {
|
||||
BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_invalid,
|
||||
error_uchar, line, column, file_name.c_str());
|
||||
}
|
||||
else if (universal_char_type_base_charset == type) {
|
||||
BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_base_charset,
|
||||
error_uchar, line, column, file_name.c_str());
|
||||
}
|
||||
else {
|
||||
BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_not_allowed,
|
||||
error_uchar, line, column, file_name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// find next universal char (if appropriate)
|
||||
pos = name.find_first_of('\\', pos+2);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// validate_literal
|
||||
//
|
||||
// The validate_literal function tests a given string or character literal
|
||||
// for its validity with regard to eventually contained universal
|
||||
// characters. These should be in valid ranges (see the function
|
||||
// classify_universal_char above).
|
||||
//
|
||||
// If the string or character literal contains invalid or not allowed
|
||||
// universal characters a corresponding lexing_exception is thrown.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename StringT>
|
||||
inline void
|
||||
validate_literal (StringT const &name, int line, int column,
|
||||
StringT const &file_name)
|
||||
{
|
||||
using namespace std; // some systems have strtoul in namespace std::
|
||||
|
||||
typename StringT::size_type pos = name.find_first_of('\\');
|
||||
|
||||
while (StringT::npos != pos) {
|
||||
// the literal contains a backslash (may be universal char)
|
||||
if ('u' == name[pos+1] || 'U' == name[pos+1]) {
|
||||
StringT uchar_val(name.substr(pos+2, ('u' == name[pos+1]) ? 4 : 8));
|
||||
universal_char_type type =
|
||||
classify_universal_char(strtoul(uchar_val.c_str(), 0, 16));
|
||||
|
||||
if (universal_char_type_valid != type &&
|
||||
universal_char_type_not_allowed_for_identifiers != type)
|
||||
{
|
||||
// an invalid char was found, so throw an exception
|
||||
StringT error_uchar(name.substr(pos, ('u' == name[pos+1]) ? 6 : 10));
|
||||
|
||||
if (universal_char_type_invalid == type) {
|
||||
BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_invalid,
|
||||
error_uchar, line, column, file_name.c_str());
|
||||
}
|
||||
else {
|
||||
BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_base_charset,
|
||||
error_uchar, line, column, file_name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// find next universal char (if appropriate)
|
||||
pos = name.find_first_of('\\', pos+2);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
} // namespace impl
|
||||
} // 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(VALIDATE_UNIVERSAL_CHAR_HPP_55F1B811_CD76_4C72_8344_CBC69CF3B339_INCLUDED)
|
||||
Reference in New Issue
Block a user