updated boost on windows

This commit is contained in:
Bassem Girgis
2019-08-13 21:48:48 -05:00
parent 7d77d485fd
commit b40a3bee82
5162 changed files with 473027 additions and 116452 deletions

View File

@@ -1,7 +1,7 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the preprocessor context
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -52,10 +52,10 @@ namespace boost {
namespace wave {
///////////////////////////////////////////////////////////////////////////////
//
//
// The C/C++ preprocessor context template class
//
// The boost::wave::context template is the main interface class to
// The boost::wave::context template is the main interface class to
// control the behavior of the preprocessing engine.
//
// The following template parameters has to be supplied:
@@ -63,18 +63,18 @@ namespace wave {
// IteratorT The iterator type of the underlying input stream
// LexIteratorT The lexer iterator type to use as the token factory
// InputPolicyT The input policy type to use for loading the files
// to be included. This template parameter is optional and
// defaults to the
// to be included. This template parameter is optional and
// defaults to the
// iteration_context_policies::load_file_to_string
// type.
// HooksT The hooks policy to use for different notification
// HooksT The hooks policy to use for different notification
// callbacks. This template parameter is optional and
// defaults to the
// context_policies::default_preprocessing_hooks
// type.
// DerivedT The type of the type being derived from the context
// type (if any). This template parameter is optional and
// defaults to 'this_type', which means that the context
// defaults to 'this_type', which means that the context
// type will be used assuming no derived type exists.
//
///////////////////////////////////////////////////////////////////////////////
@@ -83,7 +83,7 @@ struct this_type {};
template <
typename IteratorT,
typename LexIteratorT,
typename LexIteratorT,
typename InputPolicyT = iteration_context_policies::load_file_to_string,
typename HooksT = context_policies::eat_whitespace<typename LexIteratorT::token_type>,
typename DerivedT = this_type
@@ -113,35 +113,35 @@ public:
typedef typename token_type::position_type position_type;
// type of a token sequence
typedef std::list<token_type, boost::fast_pool_allocator<token_type> >
typedef std::list<token_type, boost::fast_pool_allocator<token_type> >
token_sequence_type;
// type of the policies
typedef HooksT hook_policy_type;
private:
// stack of shared_ptr's to the pending iteration contexts
typedef boost::shared_ptr<base_iteration_context<context, lexer_type> >
// stack of shared_ptr's to the pending iteration contexts
typedef boost::shared_ptr<base_iteration_context<context, lexer_type> >
iteration_ptr_type;
typedef boost::wave::util::iteration_context_stack<iteration_ptr_type>
typedef boost::wave::util::iteration_context_stack<iteration_ptr_type>
iteration_context_stack_type;
typedef typename iteration_context_stack_type::size_type iter_size_type;
context *this_() { return this; } // avoid warning in constructor
public:
context(target_iterator_type const &first_, target_iterator_type const &last_,
context(target_iterator_type const &first_, target_iterator_type const &last_,
char const *fname = "<Unknown>", HooksT const &hooks_ = HooksT())
: first(first_), last(last_), filename(fname)
, has_been_initialized(false)
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
, current_filename(fname)
#endif
#endif
, current_relative_filename(fname)
, macros(*this_())
, language(language_support(
support_cpp
| support_option_convert_trigraphs
| support_option_emit_line_directives
support_cpp
| support_option_convert_trigraphs
| support_option_emit_line_directives
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
| support_option_include_guard_detection
#endif
@@ -160,29 +160,29 @@ public:
// default destructor
// iterator interface
iterator_type begin()
{
iterator_type begin()
{
std::string fname(filename);
if (filename != "<Unknown>" && filename != "<stdin>") {
using namespace boost::filesystem;
path fpath(util::complete_path(path(filename)));
fname = fpath.string();
}
return iterator_type(*this, first, last, position_type(fname.c_str()));
return iterator_type(*this, first, last, position_type(fname.c_str()));
}
iterator_type begin(
target_iterator_type const &first_,
target_iterator_type const &last_)
{
target_iterator_type const &first_,
target_iterator_type const &last_)
{
std::string fname(filename);
if (filename != "<Unknown>" && filename != "<stdin>") {
using namespace boost::filesystem;
path fpath(util::complete_path(path(filename)));
fname = fpath.string();
}
return iterator_type(*this, first_, last_, position_type(fname.c_str()));
return iterator_type(*this, first_, last_, position_type(fname.c_str()));
}
iterator_type end() const
iterator_type end() const
{ return iterator_type(); }
// maintain include paths
@@ -191,46 +191,46 @@ public:
bool add_sysinclude_path(char const *path_)
{ return includes.add_include_path(path_, true);}
void set_sysinclude_delimiter() { includes.set_sys_include_delimiter(); }
typename iteration_context_stack_type::size_type get_iteration_depth() const
typename iteration_context_stack_type::size_type get_iteration_depth() const
{ return iter_ctxs.size(); }
// maintain defined macros
#if BOOST_WAVE_ENABLE_COMMANDLINE_MACROS != 0
template <typename StringT>
bool add_macro_definition(StringT macrostring, bool is_predefined = false)
{
return boost::wave::util::add_macro_definition(*this,
util::to_string<std::string>(macrostring), is_predefined,
get_language());
{
return boost::wave::util::add_macro_definition(*this,
util::to_string<std::string>(macrostring), is_predefined,
get_language());
}
#endif
#endif
// Define and undefine macros, macro introspection
template <typename StringT>
bool add_macro_definition(StringT const &name, position_type const& pos,
bool has_params, std::vector<token_type> &parameters,
bool add_macro_definition(StringT const &name, position_type const& pos,
bool has_params, std::vector<token_type> &parameters,
token_sequence_type &definition, bool is_predefined = false)
{
{
return macros.add_macro(
token_type(T_IDENTIFIER, util::to_string<string_type>(name), pos),
has_params, parameters, definition, is_predefined);
token_type(T_IDENTIFIER, util::to_string<string_type>(name), pos),
has_params, parameters, definition, is_predefined);
}
template <typename StringT>
bool is_defined_macro(StringT const &str) const
{
return macros.is_defined(util::to_string<string_type>(str));
{
return macros.is_defined(util::to_string<string_type>(str));
}
template <typename StringT>
bool get_macro_definition(StringT const &name,
bool get_macro_definition(StringT const &name,
bool &has_params, bool &is_predefined, position_type &pos,
std::vector<token_type> &parameters,
std::vector<token_type> &parameters,
token_sequence_type &definition) const
{
return macros.get_macro(util::to_string<string_type>(name),
has_params, is_predefined, pos, parameters, definition);
{
return macros.get_macro(util::to_string<string_type>(name),
has_params, is_predefined, pos, parameters, definition);
}
template <typename StringT>
bool remove_macro_definition(StringT const& undefname, bool even_predefined = false)
{
{
// strip leading and trailing whitespace
string_type name = util::to_string<string_type>(undefname);
typename string_type::size_type pos = name.find_first_not_of(" \t");
@@ -244,9 +244,9 @@ public:
includes.remove_pragma_once_header(
util::to_string<std::string>(name));
#endif
return macros.remove_macro(name, macros.get_main_pos(), even_predefined);
return macros.remove_macro(name, macros.get_main_pos(), even_predefined);
}
void reset_macro_definitions()
void reset_macro_definitions()
{ macros.reset_macromap(); macros.init_predefined_macros(); }
// Iterate over names of defined macros
@@ -264,28 +264,28 @@ public:
bool add_macro_definition(token_type const &name, bool has_params,
std::vector<token_type> &parameters, token_sequence_type &definition,
bool is_predefined = false)
{
return macros.add_macro(name, has_params, parameters, definition,
is_predefined);
{
return macros.add_macro(name, has_params, parameters, definition,
is_predefined);
}
// get the Wave version information
static std::string get_version()
{
boost::wave::util::predefined_macros p;
return util::to_string<std::string>(p.get_fullversion());
}
static std::string get_version_string()
// get the Wave version information
static std::string get_version()
{
boost::wave::util::predefined_macros p;
return util::to_string<std::string>(p.get_versionstr());
return util::to_string<std::string>(p.get_fullversion());
}
static std::string get_version_string()
{
boost::wave::util::predefined_macros p;
return util::to_string<std::string>(p.get_versionstr());
}
// access current language options
void set_language(boost::wave::language_support language_,
bool reset_macros = true)
{
language = language_;
bool reset_macros = true)
{
language = language_;
if (reset_macros)
reset_macro_definitions();
}
@@ -305,10 +305,10 @@ public:
hook_policy_type const &get_hooks() const { return hooks; }
// return type of actually used context type (might be the derived type)
actual_context_type& derived()
{ return *static_cast<actual_context_type*>(this); }
actual_context_type& derived()
{ return *static_cast<actual_context_type*>(this); }
actual_context_type const& derived() const
{ return *static_cast<actual_context_type const*>(this); }
{ return *static_cast<actual_context_type const*>(this); }
// return the directory of the currently preprocessed file
boost::filesystem::path get_current_directory() const
@@ -320,7 +320,7 @@ protected:
friend class boost::wave::impl::pp_iterator_functor<context>;
#endif
// make sure the context has been initialized
// make sure the context has been initialized
void init_context()
{
if (!has_been_initialized) {
@@ -340,22 +340,22 @@ protected:
{ return macros.is_defined(begin, end); }
// maintain include paths (helper functions)
void set_current_directory(char const *path_)
void set_current_directory(char const *path_)
{ includes.set_current_directory(path_); }
// conditional compilation contexts
bool get_if_block_status() const { return ifblocks.get_status(); }
bool get_if_block_some_part_status() const
{ return ifblocks.get_some_part_status(); }
bool get_if_block_some_part_status() const
{ return ifblocks.get_some_part_status(); }
bool get_enclosing_if_block_status() const
{ return ifblocks.get_enclosing_status(); }
void enter_if_block(bool new_status)
void enter_if_block(bool new_status)
{ ifblocks.enter_if_block(new_status); }
bool enter_elif_block(bool new_status)
bool enter_elif_block(bool new_status)
{ return ifblocks.enter_elif_block(new_status); }
bool enter_else_block() { return ifblocks.enter_else_block(); }
bool exit_if_block() { return ifblocks.exit_if_block(); }
typename boost::wave::util::if_block_stack::size_type get_if_block_depth() const
typename boost::wave::util::if_block_stack::size_type get_if_block_depth() const
{ return ifblocks.get_if_block_depth(); }
// stack of iteration contexts
@@ -366,29 +366,29 @@ protected:
///////////////////////////////////////////////////////////////////////////////
//
// expand_tokensequence():
// expands all macros contained in a given token sequence, handles '##'
// and '#' pp operators and re-scans the resulting sequence
// expand_tokensequence():
// expands all macros contained in a given token sequence, handles '##'
// and '#' pp operators and re-scans the resulting sequence
// (essentially pre-processes the token sequence).
//
// The expand_undefined parameter is true during macro expansion inside
// a C++ expression given for a #if or #elif statement.
// a C++ expression given for a #if or #elif statement.
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT2>
token_type expand_tokensequence(IteratorT2 &first_, IteratorT2 const &last_,
token_sequence_type &pending, token_sequence_type &expanded,
token_type expand_tokensequence(IteratorT2 &first_, IteratorT2 const &last_,
token_sequence_type &pending, token_sequence_type &expanded,
bool& seen_newline, bool expand_undefined = false)
{
return macros.expand_tokensequence(first_, last_, pending, expanded,
return macros.expand_tokensequence(first_, last_, pending, expanded,
seen_newline, expand_undefined);
}
template <typename IteratorT2>
void expand_whole_tokensequence(IteratorT2 &first_, IteratorT2 const &last_,
void expand_whole_tokensequence(IteratorT2 &first_, IteratorT2 const &last_,
token_sequence_type &expanded, bool expand_undefined = true)
{
macros.expand_whole_tokensequence(expanded, first_, last_,
macros.expand_whole_tokensequence(expanded, first_, last_,
expand_undefined);
// remove any contained placeholder
@@ -401,33 +401,33 @@ public:
// maintain the real name of the current preprocessed file
void set_current_filename(char const *real_name)
{ current_filename = real_name; }
std::string const &get_current_filename() const
std::string const &get_current_filename() const
{ return current_filename; }
// maintain the list of known headers containing #pragma once
// maintain the list of known headers containing #pragma once
bool has_pragma_once(std::string const &filename_)
{ return includes.has_pragma_once(filename_); }
bool add_pragma_once_header(std::string const &filename_,
std::string const& guard_name)
{
{
get_hooks().detected_include_guard(derived(), filename_, guard_name);
return includes.add_pragma_once_header(filename_, guard_name);
return includes.add_pragma_once_header(filename_, guard_name);
}
bool add_pragma_once_header(token_type const &pragma_,
bool add_pragma_once_header(token_type const &pragma_,
std::string const &filename_)
{
{
get_hooks().detected_pragma_once(derived(), pragma_, filename_);
return includes.add_pragma_once_header(filename_,
"__BOOST_WAVE_PRAGMA_ONCE__");
return includes.add_pragma_once_header(filename_,
"__BOOST_WAVE_PRAGMA_ONCE__");
}
#endif
#endif
void set_current_relative_filename(char const *real_name)
{ current_relative_filename = real_name; }
std::string const &get_current_relative_filename() const
std::string const &get_current_relative_filename() const
{ return current_relative_filename; }
bool find_include_file (std::string &s, std::string &d, bool is_system,
bool find_include_file (std::string &s, std::string &d, bool is_system,
char const *current_file) const
{ return includes.find_include_file(s, d, is_system, current_file); }
@@ -459,8 +459,8 @@ private:
{
using namespace boost::serialization;
if (version != (loaded_version & ~version_mask)) {
BOOST_WAVE_THROW_CTX((*this), preprocess_exception,
incompatible_config, "cpp_context state version",
BOOST_WAVE_THROW_CTX((*this), preprocess_exception,
incompatible_config, "cpp_context state version",
get_main_pos());
return;
}
@@ -471,7 +471,7 @@ private:
// BOOST_PP_STRINGIZE(BOOST_WAVE_CONFIG)
ar & make_nvp("config", config);
if (config != BOOST_PP_STRINGIZE(BOOST_WAVE_CONFIG)) {
BOOST_WAVE_THROW_CTX((*this), preprocess_exception,
BOOST_WAVE_THROW_CTX((*this), preprocess_exception,
incompatible_config, "BOOST_WAVE_CONFIG", get_main_pos());
return;
}
@@ -479,8 +479,8 @@ private:
// BOOST_WAVE_PRAGMA_KEYWORD
ar & make_nvp("pragma_keyword", pragma_keyword);
if (pragma_keyword != BOOST_WAVE_PRAGMA_KEYWORD) {
BOOST_WAVE_THROW_CTX((*this), preprocess_exception,
incompatible_config, "BOOST_WAVE_PRAGMA_KEYWORD",
BOOST_WAVE_THROW_CTX((*this), preprocess_exception,
incompatible_config, "BOOST_WAVE_PRAGMA_KEYWORD",
get_main_pos());
return;
}
@@ -488,7 +488,7 @@ private:
// BOOST_PP_STRINGIZE((BOOST_WAVE_STRINGTYPE))
ar & make_nvp("string_type", string_type_str);
if (string_type_str != BOOST_PP_STRINGIZE((BOOST_WAVE_STRINGTYPE))) {
BOOST_WAVE_THROW_CTX((*this), preprocess_exception,
BOOST_WAVE_THROW_CTX((*this), preprocess_exception,
incompatible_config, "BOOST_WAVE_STRINGTYPE", get_main_pos());
return;
}
@@ -501,7 +501,7 @@ private:
}
catch (boost::wave::preprocess_exception const& e) {
// catch version mismatch exceptions and call error handler
get_hooks().throw_exception(derived(), e);
get_hooks().throw_exception(derived(), e);
}
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
@@ -515,7 +515,7 @@ private:
bool has_been_initialized; // set cwd once
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
std::string current_filename; // real name of current preprocessed file
#endif
#endif
std::string current_relative_filename; // real relative name of current preprocessed file
boost::wave::util::if_block_stack ifblocks; // conditional compilation contexts
@@ -534,7 +534,7 @@ private:
namespace boost { namespace serialization {
template<
typename Iterator, typename LexIterator,
typename Iterator, typename LexIterator,
typename InputPolicy, typename Hooks
>
struct tracking_level<boost::wave::context<Iterator, LexIterator, InputPolicy, Hooks> >
@@ -548,7 +548,7 @@ struct tracking_level<boost::wave::context<Iterator, LexIterator, InputPolicy, H
};
template<
typename Iterator, typename LexIterator,
typename Iterator, typename LexIterator,
typename InputPolicy, typename Hooks
>
struct version<boost::wave::context<Iterator, LexIterator, InputPolicy, Hooks> >

View File

@@ -13,7 +13,7 @@
#define CPP_ITERATION_CONTEXT_HPP_00312288_9DDB_4668_AFE5_25D3994FD095_INCLUDED
#include <iterator>
#include <fstream>
#include <boost/filesystem/fstream.hpp>
#if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
#include <sstream>
#endif
@@ -64,7 +64,7 @@ namespace iteration_context_policies {
typedef typename IterContextT::iterator_type iterator_type;
// read in the file
std::ifstream instream(iter_ctx.filename.c_str());
boost::filesystem::ifstream instream(iter_ctx.filename.c_str());
if (!instream.is_open()) {
BOOST_WAVE_THROW_CTX(iter_ctx.ctx, preprocess_exception,
bad_include_file, iter_ctx.filename.c_str(), act_pos);

View File

@@ -29,7 +29,7 @@ namespace boost { namespace wave { namespace util
std::strstream stream;
stream << Exception::severity_text(code) << ": "
<< Exception::error_text(code);
if (msg[0] != 0)
if (msg[0] != 0)
stream << ": " << msg;
stream << std::ends;
std::string throwmsg = stream.str(); stream.freeze(false);
@@ -38,29 +38,29 @@ namespace boost { namespace wave { namespace util
}
template <typename Exception, typename Context, typename S1, typename Pos>
void throw_(Context& ctx, typename Exception::error_code code,
void throw_(Context& ctx, typename Exception::error_code code,
S1 msg, Pos const& pos)
{
std::strstream stream;
stream << Exception::severity_text(code) << ": "
<< Exception::error_text(code);
if (msg[0] != 0)
if (msg[0] != 0)
stream << ": " << msg;
stream << std::ends;
std::string throwmsg = stream.str(); stream.freeze(false);
ctx.get_hooks().throw_exception(ctx.derived(),
Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
ctx.get_hooks().throw_exception(ctx.derived(),
Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
pos.get_file().c_str()));
}
template <typename Exception, typename S1, typename Pos, typename S2>
void throw_(typename Exception::error_code code, S1 msg, Pos const& pos,
void throw_(typename Exception::error_code code, S1 msg, Pos const& pos,
S2 name)
{
std::strstream stream;
stream << Exception::severity_text(code) << ": "
<< Exception::error_text(code);
if (msg[0] != 0)
if (msg[0] != 0)
stream << ": " << msg;
stream << std::ends;
std::string throwmsg = stream.str(); stream.freeze(false);
@@ -68,20 +68,20 @@ namespace boost { namespace wave { namespace util
pos.get_line(), pos.get_column(), pos.get_file().c_str(), name));
}
template <typename Exception, typename Context, typename S1, typename Pos,
template <typename Exception, typename Context, typename S1, typename Pos,
typename S2>
void throw_(Context& ctx, typename Exception::error_code code,
void throw_(Context& ctx, typename Exception::error_code code,
S1 msg, Pos const& pos, S2 name)
{
std::strstream stream;
stream << Exception::severity_text(code) << ": "
<< Exception::error_text(code);
if (msg[0] != 0)
if (msg[0] != 0)
stream << ": " << msg;
stream << std::ends;
std::string throwmsg = stream.str(); stream.freeze(false);
ctx.get_hooks().throw_exception(ctx.derived(),
Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
ctx.get_hooks().throw_exception(ctx.derived(),
Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
pos.get_file().c_str(), name));
}
#else
@@ -91,59 +91,59 @@ namespace boost { namespace wave { namespace util
std::stringstream stream;
stream << Exception::severity_text(code) << ": "
<< Exception::error_text(code);
if (msg[0] != 0)
if (msg[0] != 0)
stream << ": " << msg;
stream << std::ends;
std::string throwmsg = stream.str();
std::string throwmsg = stream.str();
boost::throw_exception(Exception(throwmsg.c_str(), code,
pos.get_line(), pos.get_column(), pos.get_file().c_str()));
}
template <typename Exception, typename Context, typename S1, typename Pos>
void throw_(Context& ctx, typename Exception::error_code code,
void throw_(Context& ctx, typename Exception::error_code code,
S1 msg, Pos const& pos)
{
std::stringstream stream;
stream << Exception::severity_text(code) << ": "
<< Exception::error_text(code);
if (msg[0] != 0)
if (msg[0] != 0)
stream << ": " << msg;
stream << std::ends;
std::string throwmsg = stream.str();
ctx.get_hooks().throw_exception(ctx.derived(),
Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
std::string throwmsg = stream.str();
ctx.get_hooks().throw_exception(ctx.derived(),
Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
pos.get_file().c_str()));
}
template <typename Exception, typename S1, typename Pos, typename S2>
void throw_(typename Exception::error_code code, S1 msg, Pos const& pos,
void throw_(typename Exception::error_code code, S1 msg, Pos const& pos,
S2 name)
{
std::stringstream stream;
stream << Exception::severity_text(code) << ": "
<< Exception::error_text(code);
if (msg[0] != 0)
if (msg[0] != 0)
stream << ": " << msg;
stream << std::ends;
std::string throwmsg = stream.str();
std::string throwmsg = stream.str();
boost::throw_exception(Exception(throwmsg.c_str(), code,
pos.get_line(), pos.get_column(), pos.get_file().c_str(), name));
}
template <typename Exception, typename Context, typename S1, typename Pos1,
template <typename Exception, typename Context, typename S1, typename Pos1,
typename S2>
void throw_(Context& ctx, typename Exception::error_code code,
void throw_(Context& ctx, typename Exception::error_code code,
S1 msg, Pos1 const& pos, S2 name)
{
std::stringstream stream;
stream << Exception::severity_text(code) << ": "
<< Exception::error_text(code);
if (msg[0] != 0)
if (msg[0] != 0)
stream << ": " << msg;
stream << std::ends;
std::string throwmsg = stream.str();
ctx.get_hooks().throw_exception(ctx.derived(),
Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
std::string throwmsg = stream.str();
ctx.get_hooks().throw_exception(ctx.derived(),
Exception(throwmsg.c_str(), code, pos.get_line(), pos.get_column(),
pos.get_file().c_str(), name));
}
#endif

View File

@@ -2,7 +2,7 @@
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-2012 Hartmut Kaiser. Distributed under the Boost
@@ -32,12 +32,12 @@ namespace impl {
//
///////////////////////////////////////////////////////////////////////////////
template <typename StringT>
inline bool
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 '!':
@@ -55,11 +55,11 @@ is_trigraph(StringT const& trigraph)
//
// convert_trigraph
//
// The function convert_trigraph() converts a single trigraph character
// 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.
// no conversion is performed.
//
///////////////////////////////////////////////////////////////////////////////
template <typename StringT>
@@ -88,11 +88,11 @@ StringT result (trigraph);
//
// convert_trigraphs
//
// The function convert_trigraph() converts all trigraphs in the given
// 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.
// If one of the given character sequences doesn't form a valid trigraph
// sequence no conversion is performed.
//
///////////////////////////////////////////////////////////////////////////////
template <typename StringT>
@@ -105,7 +105,7 @@ convert_trigraphs(StringT const &value)
if (StringT::npos != pos1) {
do {
result += value.substr(pos, pos1-pos);
StringT trigraph (value.substr(pos1));
StringT trigraph (value.substr(pos1));
if (is_trigraph(trigraph)) {
result += convert_trigraph(trigraph);
pos1 = value.find_first_of ("?", pos = pos1+3);
@@ -124,7 +124,7 @@ convert_trigraphs(StringT const &value)
}
///////////////////////////////////////////////////////////////////////////////
} // namespace impl
} // namespace impl
} // namespace cpplexer
} // namespace wave
} // namespace boost

View File

@@ -2,7 +2,7 @@
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the abstract lexer interface
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -35,14 +35,14 @@ namespace cpplexer {
///////////////////////////////////////////////////////////////////////////////
//
// The lex_input_interface decouples the lex_iterator_shim from the actual
// 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
struct lex_input_interface
{
typedef typename TokenT::position_type position_type;
@@ -59,7 +59,7 @@ struct lex_input_interface
///////////////////////////////////////////////////////////////////////////////
} // namespace cpplexer
} // namespace wave
} // namespace boost
} // namespace boost
#ifdef BOOST_MSVC
#pragma warning(pop)

View File

@@ -2,7 +2,7 @@
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the abstract lexer interface
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -17,7 +17,7 @@
#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
#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
@@ -39,25 +39,25 @@ namespace cpplexer {
#define BOOST_WAVE_NEW_LEXER_DECL BOOST_WAVE_DECL
#else
#define BOOST_WAVE_NEW_LEXER_DECL
#endif
#endif
///////////////////////////////////////////////////////////////////////////////
//
//
// new_lexer_gen: generates a new instance of the required C++ lexer
//
///////////////////////////////////////////////////////////////////////////////
template <
typename IteratorT,
typename IteratorT,
typename PositionT = boost::wave::util::file_position_type,
typename TokenT = lex_token<PositionT>
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
// 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,
new_lexer(IteratorT const &first, IteratorT const &last,
PositionT const &pos, boost::wave::language_support language);
};
@@ -81,22 +81,22 @@ struct 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
// 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,
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);
first, last, pos, language);
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace cpplexer
} // namespace wave
} // namespace boost
} // namespace boost
#ifdef BOOST_MSVC
#pragma warning(pop)

View File

@@ -1,8 +1,8 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the lexer iterator
Definition of the lexer iterator
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -35,7 +35,7 @@
#if 0 != __COMO_VERSION__ || !BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
#define BOOST_WAVE_EOF_PREFIX static
#else
#define BOOST_WAVE_EOF_PREFIX
#define BOOST_WAVE_EOF_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
@@ -45,18 +45,18 @@ namespace cpplexer {
namespace impl {
///////////////////////////////////////////////////////////////////////////////
//
//
// lex_iterator_functor_shim
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
class lex_iterator_functor_shim
template <typename TokenT>
class lex_iterator_functor_shim
{
typedef typename TokenT::position_type position_type;
public:
lex_iterator_functor_shim()
lex_iterator_functor_shim()
#if /*0 != __DECCXX_VER || */defined(__PGI)
: eof()
#endif
@@ -76,16 +76,16 @@ public:
template <typename MultiPass>
static result_type& get_next(MultiPass& mp, result_type& result)
{
return mp.shared()->ftor->get(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;
{
delete mp.shared()->ftor;
}
template <typename MultiPass>
@@ -95,7 +95,7 @@ public:
}
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
template <typename MultiPass>
static bool has_include_guards(MultiPass& mp, std::string& guard_name)
static bool has_include_guards(MultiPass& mp, std::string& guard_name)
{
return mp.shared()->ftor->has_include_guards(guard_name);
}
@@ -114,12 +114,12 @@ typename lex_iterator_functor_shim<TokenT>::result_type const
} // 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
// 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:
//
@@ -130,7 +130,7 @@ typename lex_iterator_functor_shim<TokenT>::result_type const
// 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
// 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++11 etc.).
@@ -138,13 +138,13 @@ typename lex_iterator_functor_shim<TokenT>::result_type const
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Divide the given functor type into its components (unique and shared)
// 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>
typedef
std::pair<typename FunctorData::unique, typename FunctorData::shared>
functor_data_type;
typedef typename FunctorData::result_type result_type;
@@ -165,13 +165,13 @@ struct make_multi_pass
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
class lex_iterator
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
typedef typename make_multi_pass<input_policy_type>::functor_data_type
functor_data_type;
typedef typename input_policy_type::unique unique_functor_type;
@@ -184,8 +184,8 @@ public:
{}
template <typename IteratorT>
lex_iterator(IteratorT const &first, IteratorT const &last,
typename TokenT::position_type const &pos,
lex_iterator(IteratorT const &first, IteratorT const &last,
typename TokenT::position_type const &pos,
boost::wave::language_support language)
: base_type(
functor_data_type(
@@ -209,7 +209,7 @@ public:
const_cast<token_type&>(currtoken).set_position(currpos);
// set the new position for future tokens as well
if (token_type::string_type::npos !=
if (token_type::string_type::npos !=
currtoken.get_value().find_first_of('\n'))
{
currpos.set_line(pos.get_line() + 1);
@@ -219,7 +219,7 @@ public:
#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
// this function returns meaningful results only if the file was scanned
// completely
bool has_include_guards(std::string& guard_name) const
{

View File

@@ -2,7 +2,7 @@
Boost.Wave: A Standard compliant C++ preprocessor library
A generic C++ lexer token definition
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -18,7 +18,7 @@
#include <boost/serialization/serialization.hpp>
#endif
#include <boost/wave/util/file_position.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/language_support.hpp>
#include <boost/throw_exception.hpp>
@@ -80,7 +80,7 @@ public:
friend bool operator== (token_data const& lhs, token_data const& rhs)
{
// two tokens are considered equal even if they refer to different
// two tokens are considered equal even if they refer to different
// positions
return (lhs.id == rhs.id && lhs.value == rhs.value) ? true : false;
}
@@ -89,7 +89,7 @@ public:
{
BOOST_ASSERT(refcnt == 1);
id = id_;
value = value_;
value = value_;
pos = pos_;
}
@@ -97,7 +97,7 @@ public:
{
BOOST_ASSERT(refcnt == 1);
id = rhs.id;
value = rhs.value;
value = rhs.value;
pos = rhs.pos;
}
@@ -114,7 +114,7 @@ public:
case '\r': stream << "\\r"; break;
case '\n': stream << "\\n"; break;
default:
stream << value[i];
stream << value[i];
break;
}
}
@@ -160,7 +160,7 @@ token_data<StringTypeT, PositionT>::operator new(std::size_t size)
}
template <typename StringTypeT, typename PositionT>
inline void
inline void
token_data<StringTypeT, PositionT>::operator delete(void *p, std::size_t size)
{
BOOST_ASSERT(sizeof(token_data<StringTypeT, PositionT>) == size);
@@ -168,7 +168,7 @@ token_data<StringTypeT, PositionT>::operator delete(void *p, std::size_t size)
token_data_tag, sizeof(token_data<StringTypeT, PositionT>)
> pool_type;
if (0 != p)
if (0 != p)
pool_type::free(p);
}
@@ -180,13 +180,13 @@ template <typename PositionT = boost::wave::util::file_position_type>
class lex_token;
///////////////////////////////////////////////////////////////////////////////
//
//
// lex_token
//
///////////////////////////////////////////////////////////////////////////////
template <typename PositionT>
class lex_token
class lex_token
{
public:
typedef BOOST_WAVE_STRINGTYPE string_type;
@@ -194,7 +194,7 @@ public:
private:
typedef impl::token_data<string_type, position_type> data_type;
public:
// default constructed tokens correspond to EOI tokens
lex_token()
@@ -209,7 +209,7 @@ public:
lex_token(lex_token const& rhs)
: data(rhs.data)
{
if (0 != data)
if (0 != data)
data->addref();
}
@@ -219,7 +219,7 @@ public:
~lex_token()
{
if (0 != data && 0 == data->release())
if (0 != data && 0 == data->release())
delete data;
data = 0;
}
@@ -227,11 +227,11 @@ public:
lex_token& operator=(lex_token const& rhs)
{
if (&rhs != this) {
if (0 != data && 0 == data->release())
if (0 != data && 0 == data->release())
delete data;
data = rhs.data;
if (0 != data)
if (0 != data)
data->addref();
}
return *this;
@@ -260,11 +260,11 @@ public:
// 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)
static int get_token_id(lex_token const &t)
{ return token_id(t); }
static string_type get_token_value(lex_token const &t)
static string_type get_token_value(lex_token const &t)
{ return t.get_value(); }
#endif
#endif
#if defined(BOOST_SPIRIT_DEBUG)
// debug support
@@ -292,7 +292,7 @@ private:
data_type* newdata = new data_type(*data) ;
data->release(); // release this reference, can't get zero
data->release(); // release this reference, can't get zero
data = newdata;
}
@@ -300,12 +300,12 @@ private:
};
///////////////////////////////////////////////////////////////////////////////
// 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
// 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
inline bool
token_is_valid(lex_token<Position> const& t)
{
return t.is_valid();

View File

@@ -3,7 +3,7 @@
http://www.boost.org/
State machine detecting include guards in an included file.
State machine detecting include guards in an included file.
This detects two forms of include guards:
#ifndef INCLUDE_GUARD_MACRO
@@ -19,7 +19,7 @@
#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
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-2012 Hartmut Kaiser. Distributed under the Boost
@@ -47,19 +47,19 @@ class include_guards
{
public:
include_guards()
: state(&include_guards::state_0), detected_guards(false),
: state(&include_guards::state_0), detected_guards(false),
current_state(true), if_depth(0)
{}
Token& detect_guard(Token& t)
Token& detect_guard(Token& t)
{ return current_state ? (this->*state)(t) : t; }
bool detected(std::string& guard_name_) const
bool detected(std::string& guard_name_) const
{
if (detected_guards) {
guard_name_ = guard_name.c_str();
return true;
}
return false;
return false;
}
private:
@@ -76,7 +76,7 @@ private:
bool is_skippable(token_id id) const
{
return (T_POUND == BASE_TOKEN(id) ||
return (T_POUND == BASE_TOKEN(id) ||
IS_CATEGORY(id, WhiteSpaceTokenType) ||
IS_CATEGORY(id, EOLTokenType));
}
@@ -85,7 +85,7 @@ private:
///////////////////////////////////////////////////////////////////////////////
// state 0: beginning of a file, tries to recognize #ifndef or #if tokens
template <typename Token>
inline Token&
inline Token&
include_guards<Token>::state_0(Token& t)
{
token_id id = token_id(t);
@@ -101,7 +101,7 @@ include_guards<Token>::state_0(Token& t)
///////////////////////////////////////////////////////////////////////////////
// state 1: found #ifndef, looking for T_IDENTIFIER
template <typename Token>
inline Token&
inline Token&
include_guards<Token>::state_1(Token& t)
{
token_id id = token_id(t);
@@ -117,11 +117,11 @@ include_guards<Token>::state_1(Token& t)
///////////////////////////////////////////////////////////////////////////////
// state 1a: found T_PP_IF, looking for T_NOT ("!")
template <typename Token>
inline Token&
inline Token&
include_guards<Token>::state_1a(Token& t)
{
token_id id = token_id(t);
if (T_NOT == BASE_TOKEN(id))
if (T_NOT == BASE_TOKEN(id))
state = &include_guards::state_1b;
else if (!is_skippable(id))
current_state = false;
@@ -131,11 +131,11 @@ include_guards<Token>::state_1a(Token& t)
///////////////////////////////////////////////////////////////////////////////
// state 1b: found T_NOT, looking for 'defined'
template <typename Token>
inline Token&
inline Token&
include_guards<Token>::state_1b(Token& t)
{
token_id id = token_id(t);
if (T_IDENTIFIER == id && t.get_value() == "defined")
if (T_IDENTIFIER == id && t.get_value() == "defined")
state = &include_guards::state_1c;
else if (!is_skippable(id))
current_state = false;
@@ -145,11 +145,11 @@ include_guards<Token>::state_1b(Token& t)
///////////////////////////////////////////////////////////////////////////////
// state 1c: found 'defined', looking for (optional) T_LEFTPAREN
template <typename Token>
inline Token&
inline Token&
include_guards<Token>::state_1c(Token& t)
{
token_id id = token_id(t);
if (T_LEFTPAREN == id)
if (T_LEFTPAREN == id)
state = &include_guards::state_1d;
else if (T_IDENTIFIER == id) {
guard_name = t.get_value();
@@ -163,7 +163,7 @@ include_guards<Token>::state_1c(Token& t)
///////////////////////////////////////////////////////////////////////////////
// state 1d: found T_LEFTPAREN, looking for T_IDENTIFIER guard
template <typename Token>
inline Token&
inline Token&
include_guards<Token>::state_1d(Token& t)
{
token_id id = token_id(t);
@@ -179,11 +179,11 @@ include_guards<Token>::state_1d(Token& t)
///////////////////////////////////////////////////////////////////////////////
// state 1e: found T_IDENTIFIER guard, looking for T_RIGHTPAREN
template <typename Token>
inline Token&
inline Token&
include_guards<Token>::state_1e(Token& t)
{
token_id id = token_id(t);
if (T_RIGHTPAREN == id)
if (T_RIGHTPAREN == id)
state = &include_guards::state_2;
else if (!is_skippable(id))
current_state = false;
@@ -193,11 +193,11 @@ include_guards<Token>::state_1e(Token& t)
///////////////////////////////////////////////////////////////////////////////
// state 2: found T_IDENTIFIER, looking for #define
template <typename Token>
inline Token&
inline Token&
include_guards<Token>::state_2(Token& t)
{
token_id id = token_id(t);
if (T_PP_DEFINE == id)
if (T_PP_DEFINE == id)
state = &include_guards::state_3;
else if (!is_skippable(id))
current_state = false;
@@ -207,7 +207,7 @@ include_guards<Token>::state_2(Token& t)
///////////////////////////////////////////////////////////////////////////////
// state 3: found #define, looking for T_IDENTIFIER as recognized by state 1
template <typename Token>
inline Token&
inline Token&
include_guards<Token>::state_3(Token& t)
{
token_id id = token_id(t);
@@ -221,7 +221,7 @@ include_guards<Token>::state_3(Token& t)
///////////////////////////////////////////////////////////////////////////////
// state 4: found guard T_IDENTIFIER, looking for #endif
template <typename Token>
inline Token&
inline Token&
include_guards<Token>::state_4(Token& t)
{
token_id id = token_id(t);
@@ -239,11 +239,11 @@ include_guards<Token>::state_4(Token& t)
///////////////////////////////////////////////////////////////////////////////
// state 5: found final #endif, looking for T_EOF
template <typename Token>
inline Token&
inline Token&
include_guards<Token>::state_5(Token& t)
{
token_id id = token_id(t);
if (T_EOF == id)
if (T_EOF == id)
detected_guards = current_state;
else if (!is_skippable(id))
current_state = false;

View File

@@ -2,10 +2,10 @@
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001 Daniel C. Nuffer.
Copyright (c) 2001-2012 Hartmut Kaiser.
Distributed under the Boost Software License, Version 1.0. (See accompanying
Copyright (c) 2001-2012 Hartmut Kaiser.
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
@@ -39,10 +39,10 @@ typedef struct tag_aq_queuetype
typedef aq_queuetype* aq_queue;
int aq_enqueue(aq_queue q, aq_stdelement e);
BOOST_WAVE_DECL int aq_enqueue(aq_queue q, aq_stdelement e);
int aq_enqueue_front(aq_queue q, aq_stdelement e);
int aq_serve(aq_queue q, aq_stdelement *e);
int aq_pop(aq_queue q);
BOOST_WAVE_DECL int aq_pop(aq_queue q);
#define AQ_EMPTY(q) (q->size == 0)
#define AQ_FULL(q) (q->size == q->max_size)
int aq_grow(aq_queue q);
@@ -54,7 +54,7 @@ BOOST_WAVE_DECL void aq_terminate(aq_queue q);
} // namespace re2clex
} // namespace cpplexer
} // namespace wave
} // namespace boost
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -89,12 +89,12 @@ public:
#endif
// error reporting from the re2c generated lexer
static int report_error(Scanner const* s, int code, char const *, ...);
static int report_error(Scanner<IteratorT> const* s, int code, char const *, ...);
private:
static char const *tok_names[];
Scanner scanner;
Scanner<IteratorT> scanner;
string_type filename;
string_type value;
bool at_eof;
@@ -117,18 +117,13 @@ 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_)
: scanner(first, last),
filename(pos.get_file()), at_eof(false), language(language_)
#if BOOST_WAVE_SUPPORT_THREADING != 0
, cache()
#endif
{
using namespace std; // some systems have memset in std
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;
@@ -165,7 +160,6 @@ inline
lexer<IteratorT, PositionT, TokenT>::~lexer()
{
using namespace std; // some systems have free in std
aq_terminate(scanner.eol_offsets);
free(scanner.bot);
}
@@ -181,7 +175,7 @@ lexer<IteratorT, PositionT, TokenT>::get(TokenT& result)
std::size_t actline = scanner.line;
token_id id = token_id(scan(&scanner));
switch (static_cast<unsigned int>(id)) {
switch (id) {
case T_IDENTIFIER:
// test identifier characters for validity (throws if invalid chars found)
value = string_type((char const *)scanner.tok,
@@ -307,7 +301,7 @@ lexer<IteratorT, PositionT, TokenT>::get(TokenT& result)
template <typename IteratorT, typename PositionT, typename TokenT>
inline int
lexer<IteratorT, PositionT, TokenT>::report_error(Scanner const *s, int errcode,
lexer<IteratorT, PositionT, TokenT>::report_error(Scanner<IteratorT> const *s, int errcode,
char const *msg, ...)
{
BOOST_ASSERT(0 != s);

View File

@@ -26,15 +26,31 @@ namespace wave {
namespace cpplexer {
namespace re2clex {
template<typename Iterator>
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 */
template<typename Iterator>
struct Scanner {
typedef int (* ReportErrorProc)(struct Scanner const *, int errorcode,
char const *, ...);
Scanner(Iterator const & f, Iterator const & l)
: first(f), act(f), last(l),
bot(0), top(0), eof(0), tok(0), ptr(0), cur(0), lim(0),
eol_offsets(aq_create())
// remaining data members externally initialized
{}
~Scanner()
{
aq_terminate(eol_offsets);
}
Iterator first; /* start of input buffer */
Iterator act; /* act position of input buffer */
Iterator last; /* end (one past last char) of input buffer */
uchar* bot; /* beginning of the current buffer */
uchar* top; /* top of the current buffer */
uchar* eof; /* when we read in the last buffer, will point 1 past the
@@ -58,7 +74,7 @@ typedef struct Scanner {
bool enable_import_keyword; /* recognize import as a keyword */
bool single_line_only; /* don't report missing eol's in C++ comments */
bool act_in_cpp0x_mode; /* lexer works in C++11 mode */
} Scanner;
};
///////////////////////////////////////////////////////////////////////////////
} // namespace re2clex

File diff suppressed because it is too large Load Diff

View File

@@ -32,12 +32,12 @@ namespace cpplexer {
// 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
// effective when used in conjunction with a copy on write string
// implementation (COW string).
//
///////////////////////////////////////////////////////////////////////////////
template <typename StringT>
class token_cache
class token_cache
{
public:
token_cache()
@@ -60,7 +60,7 @@ private:
};
///////////////////////////////////////////////////////////////////////////////
} // namespace cpplexer
} // namespace cpplexer
} // namespace wave
} // namespace boost

View File

@@ -219,7 +219,7 @@ classify_universal_char (unsigned long ch)
///////////////////////////////////////////////////////////////////////////////
template <typename StringT>
inline void
validate_identifier_name (StringT const &name, std::size_t line,
validate_identifier_name (StringT const &name, std::size_t line,
std::size_t column, StringT const &file_name)
{
using namespace std; // some systems have strtoul in namespace std::

View File

@@ -14,7 +14,7 @@
#include <limits> // std::numeric_limits
#include <climits> // CHAR_BIT
#include <boost/wave/wave_config.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
@@ -30,7 +30,7 @@
#include <boost/spirit/include/phoenix1_statements.hpp>
#include <boost/spirit/include/phoenix1_functions.hpp>
#include <boost/wave/cpp_exceptions.hpp>
#include <boost/wave/cpp_exceptions.hpp>
#include <boost/wave/grammars/cpp_literal_grammar_gen.hpp>
#if !defined(spirit_append_actor)
@@ -45,17 +45,17 @@
///////////////////////////////////////////////////////////////////////////////
//
// Reusable grammar to parse a C++ style character literal
// Reusable grammar to parse a C++ style character literal
//
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace wave {
namespace grammars {
namespace closures {
struct chlit_closure
: boost::spirit::classic::closure<chlit_closure, boost::uint32_t, bool>
struct chlit_closure
: boost::spirit::classic::closure<chlit_closure, boost::uint32_t, bool>
{
member1 value;
member2 long_lit;
@@ -72,35 +72,35 @@ namespace impl {
struct compose_character_literal {
template <typename A1, typename A2, typename A3, typename A4>
struct result
{
typedef void type;
struct result
{
typedef void type;
};
void
void
operator()(boost::uint32_t& value, bool long_lit, bool& overflow,
boost::uint32_t character) const
{
{
// The following assumes that wchar_t is max. 32 Bit
BOOST_STATIC_ASSERT(sizeof(wchar_t) <= 4);
static boost::uint32_t masks[] = {
static boost::uint32_t masks[] = {
0x000000ff, 0x0000ffff, 0x00ffffff, 0xffffffff
};
static boost::uint32_t overflow_masks[] = {
static boost::uint32_t overflow_masks[] = {
0xff000000, 0xffff0000, 0xffffff00, 0xffffffff
};
if (long_lit) {
// make sure no overflow will occur below
if ((value & overflow_masks[sizeof(wchar_t)-1]) != 0) {
overflow |= true;
}
else {
// calculate the new value (avoiding a warning regarding
// calculate the new value (avoiding a warning regarding
// shifting count >= size of the type)
value <<= CHAR_BIT * (sizeof(wchar_t)-1);
value <<= CHAR_BIT;
value <<= CHAR_BIT;
value |= character & masks[sizeof(wchar_t)-1];
}
}
@@ -128,25 +128,25 @@ namespace impl {
/**/
struct chlit_grammar :
public boost::spirit::classic::grammar<chlit_grammar,
public boost::spirit::classic::grammar<chlit_grammar,
closures::chlit_closure::context_t>
{
chlit_grammar()
: overflow(false)
{
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "chlit_grammar",
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "chlit_grammar",
TRACE_CHLIT_GRAMMAR);
}
// no need for copy constructor/assignment operator
chlit_grammar(chlit_grammar const&);
chlit_grammar& operator=(chlit_grammar const&);
template <typename ScannerT>
struct definition
{
typedef boost::spirit::classic::rule<
ScannerT, closures::chlit_closure::context_t>
ScannerT, closures::chlit_closure::context_t>
rule_t;
rule_t ch_lit;
@@ -155,7 +155,7 @@ struct chlit_grammar :
{
using namespace boost::spirit::classic;
namespace phx = phoenix;
// special parsers for '\x..' and L'\x....'
typedef uint_parser<
unsigned int, 16, 1, 2 * sizeof(char)
@@ -170,68 +170,68 @@ struct chlit_grammar :
>> !ch_p('L')[self.long_lit = phx::val(true)]
>> ch_p('\'')
>> +( (
ch_p('\\')
ch_p('\\')
>> ( ch_p('a') // BEL
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::val(0x07))
]
| ch_p('b') // BS
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::val(0x08))
]
| ch_p('t') // HT
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::val(0x09))
]
| ch_p('n') // NL
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::val(0x0a))
]
| ch_p('v') // VT
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::val(0x0b))
]
| ch_p('f') // FF
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::val(0x0c))
]
| ch_p('r') // CR
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::val(0x0d))
]
| ch_p('?')
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::val('?'))
]
| ch_p('\'')
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::val('\''))
]
| ch_p('\"')
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::val('\"'))
]
| ch_p('\\')
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::val('\\'))
]
| ch_p('x')
>> if_p(self.long_lit)
| ch_p('x')
>> if_p(self.long_lit)
[
hex_wchar_parser_type()
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::arg1)
]
]
@@ -239,32 +239,32 @@ struct chlit_grammar :
[
hex_char_parser_type()
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::arg1)
]
]
| ch_p('u')
| ch_p('u')
>> uint_parser<unsigned int, 16, 4, 4>()
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::arg1)
]
| ch_p('U')
>> uint_parser<unsigned int, 16, 8, 8>()
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::arg1)
]
| uint_parser<unsigned int, 8, 1, 3>()
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::arg1)
]
)
)
| ~eps_p(ch_p('\'')) >> anychar_p
[
impl::compose(self.value, self.long_lit,
impl::compose(self.value, self.long_lit,
phx::var(self.overflow), phx::arg1)
]
)
@@ -286,25 +286,25 @@ struct chlit_grammar :
#undef TRACE_CHLIT_GRAMMAR
///////////////////////////////////////////////////////////////////////////////
//
// The following function is defined here, to allow the separation of
//
// The following function is defined here, to allow the separation of
// the compilation of the intlit_grammap from the function using it.
//
//
///////////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#define BOOST_WAVE_CHLITGRAMMAR_GEN_INLINE
#else
#define BOOST_WAVE_CHLITGRAMMAR_GEN_INLINE inline
#endif
#endif
template <typename IntegralResult, typename TokenT>
BOOST_WAVE_CHLITGRAMMAR_GEN_INLINE
BOOST_WAVE_CHLITGRAMMAR_GEN_INLINE
IntegralResult
chlit_grammar_gen<IntegralResult, TokenT>::evaluate(TokenT const &token, value_error &status)
{
using namespace boost::spirit::classic;
chlit_grammar g;
IntegralResult result = 0;
typename TokenT::string_type const &token_val = token.get_value();
@@ -312,15 +312,15 @@ parse_info<typename TokenT::string_type::const_iterator> hit =
parse(token_val.begin(), token_val.end(), g[spirit_assign_actor(result)]);
if (!hit.hit) {
BOOST_WAVE_THROW(preprocess_exception, ill_formed_character_literal,
BOOST_WAVE_THROW(preprocess_exception, ill_formed_character_literal,
token_val.c_str(), token.get_position());
}
else {
// range check
if ('L' == token_val[0]) {
// recognized wide character
if (g.overflow ||
result > (IntegralResult)(std::numeric_limits<wchar_t>::max)())
if (g.overflow ||
result > (IntegralResult)(std::numeric_limits<wchar_t>::max)())
{
// out of range
status = error_character_overflow;
@@ -328,8 +328,8 @@ parse_info<typename TokenT::string_type::const_iterator> hit =
}
else {
// recognized narrow ('normal') character
if (g.overflow ||
result > (IntegralResult)(std::numeric_limits<unsigned char>::max)())
if (g.overflow ||
result > (IntegralResult)(std::numeric_limits<unsigned char>::max)())
{
// out of range
status = error_character_overflow;

View File

@@ -35,7 +35,7 @@
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace wave {
namespace grammars {
///////////////////////////////////////////////////////////////////////////////
@@ -51,7 +51,7 @@ struct defined_grammar :
defined_grammar(ContainerT &result_seq_)
: result_seq(result_seq_)
{
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "defined_grammar",
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "defined_grammar",
TRACE_CPP_DEFINED_GRAMMAR);
}
@@ -84,20 +84,20 @@ struct defined_grammar :
= ch_p(T_IDENTIFIER)
[
spirit_append_actor(self.result_seq)
]
]
| pattern_p(KeywordTokenType, TokenTypeMask|PPTokenFlag)
[
spirit_append_actor(self.result_seq)
]
| pattern_p(OperatorTokenType|AltExtTokenType,
]
| pattern_p(OperatorTokenType|AltExtTokenType,
ExtTokenTypeMask|PPTokenFlag)
[
spirit_append_actor(self.result_seq)
]
]
| pattern_p(BoolLiteralTokenType, TokenTypeMask|PPTokenFlag)
[
spirit_append_actor(self.result_seq)
]
]
;
BOOST_SPIRIT_DEBUG_TRACE_RULE(defined_op, TRACE_CPP_DEFINED_GRAMMAR);
@@ -116,28 +116,28 @@ struct defined_grammar :
#undef TRACE_CPP_DEFINED_GRAMMAR
///////////////////////////////////////////////////////////////////////////////
//
// The following parse function is defined here, to allow the separation of
// the compilation of the defined_grammar from the function
//
// The following parse function is defined here, to allow the separation of
// the compilation of the defined_grammar from the function
// using it.
//
//
///////////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#define BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
#else
#define BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE inline
#endif
#endif
// The parse_operator_define function is instantiated manually twice to
// simplify the explicit specialization of this template. This way the user
// The parse_operator_define function is instantiated manually twice to
// simplify the explicit specialization of this template. This way the user
// has only to specify one template parameter (the lexer type) to correctly
// formulate the required explicit specialization.
// This results in no code overhead, because otherwise the function would be
// generated by the compiler twice anyway.
template <typename LexIteratorT>
BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
boost::spirit::classic::parse_info<
typename defined_grammar_gen<LexIteratorT>::iterator1_type
>
@@ -147,14 +147,14 @@ defined_grammar_gen<LexIteratorT>::parse_operator_defined (
{
using namespace boost::spirit::classic;
using namespace boost::wave;
defined_grammar<token_sequence_type> g(found_qualified_name);
return boost::spirit::classic::parse (
first, last, g, ch_p(T_SPACE) | ch_p(T_CCOMMENT));
}
template <typename LexIteratorT>
BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
BOOST_WAVE_DEFINED_GRAMMAR_GEN_INLINE
boost::spirit::classic::parse_info<
typename defined_grammar_gen<LexIteratorT>::iterator2_type
>
@@ -164,7 +164,7 @@ defined_grammar_gen<LexIteratorT>::parse_operator_defined (
{
using namespace boost::spirit::classic;
using namespace boost::wave;
defined_grammar<token_sequence_type> g(found_qualified_name);
return boost::spirit::classic::parse (
first, last, g, ch_p(T_SPACE) | ch_p(T_CCOMMENT));

View File

@@ -33,7 +33,7 @@
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace wave {
namespace grammars {
template <typename LexIteratorT>
@@ -43,9 +43,9 @@ struct BOOST_WAVE_DECL defined_grammar_gen
typedef std::list<token_type, boost::fast_pool_allocator<token_type> >
token_sequence_type;
// The parse_operator_defined function is instantiated manually twice to
// simplify the explicit specialization of this template. This way the user
// has only to specify one template parameter (the lexer iterator type) to
// The parse_operator_defined function is instantiated manually twice to
// simplify the explicit specialization of this template. This way the user
// has only to specify one template parameter (the lexer iterator type) to
// correctly formulate the required explicit specialization.
// This results in no code overhead, because otherwise the function would be
// generated by the compiler twice anyway.
@@ -57,14 +57,14 @@ struct BOOST_WAVE_DECL defined_grammar_gen
typedef boost::wave::util::unput_queue_iterator<
LexIteratorT, token_type, token_sequence_type>
iterator2_type;
// parse the operator defined and return the found qualified name
static boost::spirit::classic::parse_info<iterator1_type>
parse_operator_defined (iterator1_type const &first,
static boost::spirit::classic::parse_info<iterator1_type>
parse_operator_defined (iterator1_type const &first,
iterator1_type const &last, token_sequence_type &found_qualified_name);
static boost::spirit::classic::parse_info<iterator2_type>
parse_operator_defined (iterator2_type const &first,
static boost::spirit::classic::parse_info<iterator2_type>
parse_operator_defined (iterator2_type const &first,
iterator2_type const &last, token_sequence_type &found_qualified_name);
};

View File

@@ -29,8 +29,8 @@
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpp_exceptions.hpp>
#include <boost/wave/grammars/cpp_expression_grammar_gen.hpp>
#include <boost/wave/grammars/cpp_literal_grammar_gen.hpp>
#include <boost/wave/grammars/cpp_expression_grammar_gen.hpp>
#include <boost/wave/grammars/cpp_literal_grammar_gen.hpp>
#include <boost/wave/grammars/cpp_expression_value.hpp>
#include <boost/wave/util/pattern_parser.hpp>
#include <boost/wave/util/macro_helpers.hpp>
@@ -52,7 +52,7 @@
//
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace wave {
namespace grammars {
namespace closures {
@@ -60,13 +60,13 @@ namespace closures {
//
// define the closure type used throughout the C++ expression grammar
//
// Throughout this grammar all literal tokens are stored into a
// closure_value variables, which converts the types appropriately, where
// Throughout this grammar all literal tokens are stored into a
// closure_value variables, which converts the types appropriately, where
// required.
//
///////////////////////////////////////////////////////////////////////////////
struct cpp_expr_closure
: boost::spirit::classic::closure<cpp_expr_closure, closure_value>
struct cpp_expr_closure
: boost::spirit::classic::closure<cpp_expr_closure, closure_value>
{
member1 val;
};
@@ -83,21 +83,21 @@ namespace impl {
struct convert_intlit {
template <typename ArgT>
struct result {
typedef boost::wave::grammars::closures::closure_value type;
struct result {
typedef boost::wave::grammars::closures::closure_value type;
};
template <typename TokenT>
boost::wave::grammars::closures::closure_value
boost::wave::grammars::closures::closure_value
operator()(TokenT const &token) const
{
{
typedef boost::wave::grammars::closures::closure_value return_type;
bool is_unsigned = false;
uint_literal_type ul = intlit_grammar_gen<TokenT>::evaluate(token,
uint_literal_type ul = intlit_grammar_gen<TokenT>::evaluate(token,
is_unsigned);
return is_unsigned ?
return is_unsigned ?
return_type(ul) : return_type(static_cast<int_literal_type>(ul));
}
};
@@ -111,29 +111,29 @@ namespace impl {
struct convert_chlit {
template <typename ArgT>
struct result {
typedef boost::wave::grammars::closures::closure_value type;
struct result {
typedef boost::wave::grammars::closures::closure_value type;
};
template <typename TokenT>
boost::wave::grammars::closures::closure_value
boost::wave::grammars::closures::closure_value
operator()(TokenT const &token) const
{
{
typedef boost::wave::grammars::closures::closure_value return_type;
value_error status = error_noerror;
// If the literal is a wchar_t and wchar_t is represented by a
// signed integral type, then the created value will be signed as
// If the literal is a wchar_t and wchar_t is represented by a
// signed integral type, then the created value will be signed as
// well, otherwise we assume unsigned values.
#if BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_AUTOSELECT
if ('L' == token.get_value()[0] && std::numeric_limits<wchar_t>::is_signed)
if ('L' == token.get_value()[0] && std::numeric_limits<wchar_t>::is_signed)
{
int value = chlit_grammar_gen<int, TokenT>::evaluate(token, status);
return return_type(value, status);
}
#elif BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_FORCE_SIGNED
if ('L' == token.get_value()[0])
if ('L' == token.get_value()[0])
{
int value = chlit_grammar_gen<int, TokenT>::evaluate(token, status);
return return_type(value, status);
@@ -152,17 +152,17 @@ namespace impl {
//
////////////////////////////////////////////////////////////////////////////////
struct operator_questionmark {
template <typename CondT, typename Arg1T, typename Arg2T>
struct result {
typedef boost::wave::grammars::closures::closure_value type;
struct result {
typedef boost::wave::grammars::closures::closure_value type;
};
template <typename CondT, typename Arg1T, typename Arg2T>
boost::wave::grammars::closures::closure_value
boost::wave::grammars::closures::closure_value
operator()(CondT const &cond, Arg1T &val1, Arg2T const &val2) const
{
{
return val1.handle_questionmark(cond, val2);
}
};
@@ -174,46 +174,46 @@ namespace impl {
//
///////////////////////////////////////////////////////////////////////////////
struct operator_to_bool {
template <typename ArgT>
struct result {
typedef boost::wave::grammars::closures::closure_value type;
struct result {
typedef boost::wave::grammars::closures::closure_value type;
};
template <typename ArgT>
boost::wave::grammars::closures::closure_value
boost::wave::grammars::closures::closure_value
operator()(ArgT &val) const
{
{
typedef boost::wave::grammars::closures::closure_value return_type;
return return_type(
boost::wave::grammars::closures::as_bool(val), val.is_valid());
}
};
phoenix::function<operator_to_bool> const to_bool;
///////////////////////////////////////////////////////////////////////////////
//
// Handle explicit type conversion
//
///////////////////////////////////////////////////////////////////////////////
struct operator_as_bool {
template <typename ArgT>
struct result {
typedef bool type;
struct result {
typedef bool type;
};
template <typename ArgT>
bool
operator()(ArgT &val) const
{
{
return boost::wave::grammars::closures::as_bool(val);
}
};
phoenix::function<operator_as_bool> const as_bool;
///////////////////////////////////////////////////////////////////////////////
//
// Handle closure value operators with proper error propagation
@@ -240,11 +240,11 @@ namespace impl {
BOOST_WAVE_BINARYOP(and, &&);
BOOST_WAVE_BINARYOP(or, ||);
BOOST_WAVE_BINARYOP(bitand, &);
BOOST_WAVE_BINARYOP(bitor, |);
BOOST_WAVE_BINARYOP(bitxor, ^);
BOOST_WAVE_BINARYOP(lesseq, <=);
BOOST_WAVE_BINARYOP(less, <);
BOOST_WAVE_BINARYOP(greater, >);
@@ -275,7 +275,7 @@ namespace impl {
/**/
BOOST_WAVE_UNARYOP(neg, !);
#undef BOOST_WAVE_UNARYOP
} // namespace impl
@@ -288,20 +288,20 @@ namespace impl {
struct expression_grammar :
public boost::spirit::classic::grammar<
expression_grammar,
expression_grammar,
closures::cpp_expr_closure::context_t
>
{
expression_grammar()
{
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "expression_grammar",
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "expression_grammar",
TRACE_CPP_EXPR_GRAMMAR);
}
// no need for copy constructor/assignment operator
expression_grammar(expression_grammar const&);
expression_grammar& operator= (expression_grammar const&);
template <typename ScannerT>
struct definition
{
@@ -310,7 +310,7 @@ struct expression_grammar :
typedef boost::spirit::classic::rule<ScannerT> simple_rule_t;
simple_rule_t pp_expression;
rule_t const_exp;
rule_t logical_or_exp, logical_and_exp;
rule_t inclusive_or_exp, exclusive_or_exp, and_exp;
@@ -335,11 +335,11 @@ struct expression_grammar :
using namespace phoenix;
using namespace boost::wave;
using boost::wave::util::pattern_p;
pp_expression
= const_exp[self.val = arg1]
;
const_exp
= logical_or_exp[const_exp.val = arg1]
>> !(const_exp_subrule =
@@ -347,18 +347,18 @@ struct expression_grammar :
>> const_exp
[
const_exp_subrule.val = arg1
]
]
>> ch_p(T_COLON)
>> const_exp
[
const_exp_subrule.val =
impl::questionmark(const_exp.val,
const_exp_subrule.val =
impl::questionmark(const_exp.val,
const_exp_subrule.val, arg1)
]
)[const_exp.val = arg1]
;
logical_or_exp
logical_or_exp
= logical_and_exp[logical_or_exp.val = arg1]
>> *( if_p(impl::as_bool(logical_or_exp.val))
[
@@ -367,7 +367,7 @@ struct expression_grammar :
pattern_p(T_OROR, MainTokenMask)
>> logical_and_exp_nocalc
[
logical_or_exp.val =
logical_or_exp.val =
impl::to_bool(logical_or_exp.val)
]
]
@@ -376,7 +376,7 @@ struct expression_grammar :
pattern_p(T_OROR, MainTokenMask)
>> logical_and_exp
[
logical_or_exp.val =
logical_or_exp.val =
impl::binary_or(logical_or_exp.val, arg1)
]
]
@@ -390,7 +390,7 @@ struct expression_grammar :
pattern_p(T_ANDAND, MainTokenMask)
>> inclusive_or_exp
[
logical_and_exp.val =
logical_and_exp.val =
impl::binary_and(logical_and_exp.val, arg1)
]
]
@@ -413,7 +413,7 @@ struct expression_grammar :
>> *( pattern_p(T_OR, MainTokenMask)
>> exclusive_or_exp
[
inclusive_or_exp.val =
inclusive_or_exp.val =
impl::binary_bitor(inclusive_or_exp.val, arg1)
]
)
@@ -424,7 +424,7 @@ struct expression_grammar :
>> *( pattern_p(T_XOR, MainTokenMask)
>> and_exp
[
exclusive_or_exp.val =
exclusive_or_exp.val =
impl::binary_bitxor(exclusive_or_exp.val, arg1)
]
)
@@ -435,7 +435,7 @@ struct expression_grammar :
>> *( pattern_p(T_AND, MainTokenMask)
>> cmp_equality
[
and_exp.val =
and_exp.val =
impl::binary_bitand(and_exp.val, arg1)
]
)
@@ -446,13 +446,13 @@ struct expression_grammar :
>> *( ch_p(T_EQUAL)
>> cmp_relational
[
cmp_equality.val =
cmp_equality.val =
impl::binary_eq(cmp_equality.val, arg1)
]
| pattern_p(T_NOTEQUAL, MainTokenMask)
>> cmp_relational
[
cmp_equality.val =
cmp_equality.val =
impl::binary_ne(cmp_equality.val, arg1)
]
)
@@ -463,25 +463,25 @@ struct expression_grammar :
>> *( ch_p(T_LESSEQUAL)
>> shift_exp
[
cmp_relational.val =
cmp_relational.val =
impl::binary_lesseq(cmp_relational.val, arg1)
]
| ch_p(T_GREATEREQUAL)
>> shift_exp
[
cmp_relational.val =
cmp_relational.val =
impl::binary_greateq(cmp_relational.val, arg1)
]
| ch_p(T_LESS)
>> shift_exp
[
cmp_relational.val =
cmp_relational.val =
impl::binary_less(cmp_relational.val, arg1)
]
| ch_p(T_GREATER)
>> shift_exp
[
cmp_relational.val =
cmp_relational.val =
impl::binary_greater(cmp_relational.val, arg1)
]
)
@@ -559,27 +559,27 @@ struct expression_grammar :
primary_exp
= constant[primary_exp.val = arg1]
| ch_p(T_LEFTPAREN)
| ch_p(T_LEFTPAREN)
>> const_exp[primary_exp.val = arg1]
>> ch_p(T_RIGHTPAREN)
;
constant
= ch_p(T_PP_NUMBER)
= ch_p(T_PP_NUMBER)
[
constant.val = impl::as_intlit(arg1)
]
| ch_p(T_INTLIT)
| ch_p(T_INTLIT)
[
constant.val = impl::as_intlit(arg1)
]
| ch_p(T_CHARLIT)
| ch_p(T_CHARLIT)
[
constant.val = impl::as_chlit(arg1)
]
;
// here follows the same grammar, but without any embedded
// here follows the same grammar, but without any embedded
// calculations
const_exp_nocalc
= logical_or_exp_nocalc
@@ -590,7 +590,7 @@ struct expression_grammar :
)
;
logical_or_exp_nocalc
logical_or_exp_nocalc
= logical_and_exp_nocalc
>> *( pattern_p(T_OROR, MainTokenMask)
>> logical_and_exp_nocalc
@@ -686,15 +686,15 @@ struct expression_grammar :
primary_exp_nocalc
= constant_nocalc
| ch_p(T_LEFTPAREN)
| ch_p(T_LEFTPAREN)
>> const_exp_nocalc
>> ch_p(T_RIGHTPAREN)
;
constant_nocalc
= ch_p(T_PP_NUMBER)
| ch_p(T_INTLIT)
| ch_p(T_CHARLIT)
= ch_p(T_PP_NUMBER)
| ch_p(T_INTLIT)
| ch_p(T_CHARLIT)
;
BOOST_SPIRIT_DEBUG_TRACE_RULE(pp_expression, TRACE_CPP_EXPR_GRAMMAR);
@@ -740,54 +740,54 @@ struct expression_grammar :
#undef TRACE_CPP_EXPR_GRAMMAR
///////////////////////////////////////////////////////////////////////////////
//
// The following function is defined here, to allow the separation of
//
// The following function is defined here, to allow the separation of
// the compilation of the expression_grammar from the function using it.
//
//
///////////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#define BOOST_WAVE_EXPRGRAMMAR_GEN_INLINE
#else
#define BOOST_WAVE_EXPRGRAMMAR_GEN_INLINE inline
#endif
#endif
template <typename TokenT>
BOOST_WAVE_EXPRGRAMMAR_GEN_INLINE
bool
BOOST_WAVE_EXPRGRAMMAR_GEN_INLINE
bool
expression_grammar_gen<TokenT>::evaluate(
typename token_sequence_type::const_iterator const &first,
typename token_sequence_type::const_iterator const &last,
typename token_sequence_type::const_iterator const &first,
typename token_sequence_type::const_iterator const &last,
typename token_type::position_type const &act_pos,
bool if_block_status, value_error &status)
{
using namespace boost::spirit::classic;
using namespace boost::wave;
using namespace boost::wave::grammars::closures;
using boost::wave::util::impl::as_string;
typedef typename token_sequence_type::const_iterator iterator_type;
typedef typename token_sequence_type::value_type::string_type string_type;
parse_info<iterator_type> hit(first);
closure_value result; // expression result
#if !defined(BOOST_NO_EXCEPTIONS)
try
try
#endif
{
expression_grammar g; // expression grammar
hit = parse (first, last, g[spirit_assign_actor(result)],
hit = parse (first, last, g[spirit_assign_actor(result)],
ch_p(T_SPACE) | ch_p(T_CCOMMENT) | ch_p(T_CPPCOMMENT));
if (!hit.hit) {
// expression is illformed
if (if_block_status) {
string_type expression = as_string<string_type>(first, last);
if (0 == expression.size())
if (0 == expression.size())
expression = "<empty expression>";
BOOST_WAVE_THROW(preprocess_exception, ill_formed_expression,
BOOST_WAVE_THROW(preprocess_exception, ill_formed_expression,
expression.c_str(), act_pos);
return false;
}
@@ -812,13 +812,13 @@ expression_grammar_gen<TokenT>::evaluate(
#endif
if (!hit.full) {
// The token list starts with a valid expression, but there remains
// something. If the remainder consists out of whitespace only, the
// The token list starts with a valid expression, but there remains
// something. If the remainder consists out of whitespace only, the
// expression is still valid.
iterator_type next = hit.stop;
while (next != last) {
switch (static_cast<unsigned int>(token_id(*next))) {
switch (token_id(*next)) {
case T_SPACE:
case T_SPACE2:
case T_CCOMMENT:
@@ -833,9 +833,9 @@ expression_grammar_gen<TokenT>::evaluate(
// expression is illformed
if (if_block_status) {
string_type expression = as_string<string_type>(first, last);
if (0 == expression.size())
if (0 == expression.size())
expression = "<empty expression>";
BOOST_WAVE_THROW(preprocess_exception, ill_formed_expression,
BOOST_WAVE_THROW(preprocess_exception, ill_formed_expression,
expression.c_str(), act_pos);
return false;
}
@@ -850,7 +850,7 @@ expression_grammar_gen<TokenT>::evaluate(
if (error_noerror != result.is_valid()) // division or other error by zero occurred
status = result.is_valid();
// token sequence is a valid expression
return as_bool(result);
}

View File

@@ -35,11 +35,11 @@ namespace wave {
namespace grammars {
///////////////////////////////////////////////////////////////////////////////
//
//
// expression_grammar_gen template class
//
// This template helps separating the compilation of the
// expression_grammar class from the compilation of the main
// This template helps separating the compilation of the
// expression_grammar class from the compilation of the main
// pp_iterator. This is done to safe compilation time.
//
///////////////////////////////////////////////////////////////////////////////
@@ -52,15 +52,15 @@ struct BOOST_WAVE_DECL expression_grammar_gen {
token_sequence_type;
static bool evaluate(
typename token_sequence_type::const_iterator const &first,
typename token_sequence_type::const_iterator const &last,
typename token_sequence_type::const_iterator const &first,
typename token_sequence_type::const_iterator const &last,
typename token_type::position_type const &tok,
bool if_block_status, value_error &status);
};
///////////////////////////////////////////////////////////////////////////////
} // namespace grammars
} // namespace wave
} // namespace wave
} // namespace boost
#ifdef BOOST_MSVC

View File

@@ -34,10 +34,10 @@ inline bool as_bool(closure_value const& v);
///////////////////////////////////////////////////////////////////////////////
//
// The closure_value class represents the closure type, which is used for the
// expression grammar.
// The closure_value class represents the closure type, which is used for the
// expression grammar.
//
// This class was introduced to allow the expression grammar to respect
// This class was introduced to allow the expression grammar to respect
// the numeric type of a numeric literal or expression result.
//
///////////////////////////////////////////////////////////////////////////////
@@ -49,29 +49,29 @@ public:
is_uint = 2,
is_bool = 3
};
closure_value(value_error valid_ = error_noerror)
: type(is_int), valid(valid_)
closure_value(value_error valid_ = error_noerror)
: type(is_int), valid(valid_)
{ value.i = 0; }
explicit closure_value(int i, value_error valid_ = error_noerror)
: type(is_int), valid(valid_)
explicit closure_value(int i, value_error valid_ = error_noerror)
: type(is_int), valid(valid_)
{ value.i = i; }
explicit closure_value(unsigned int ui, value_error valid_ = error_noerror)
: type(is_uint), valid(valid_)
explicit closure_value(unsigned int ui, value_error valid_ = error_noerror)
: type(is_uint), valid(valid_)
{ value.ui = ui; }
explicit closure_value(int_literal_type i, value_error valid_ = error_noerror)
: type(is_int), valid(valid_)
explicit closure_value(int_literal_type i, value_error valid_ = error_noerror)
: type(is_int), valid(valid_)
{ value.i = i; }
explicit closure_value(uint_literal_type ui, value_error valid_ = error_noerror)
: type(is_uint), valid(valid_)
explicit closure_value(uint_literal_type ui, value_error valid_ = error_noerror)
: type(is_uint), valid(valid_)
{ value.ui = ui; }
explicit closure_value(bool b, value_error valid_ = error_noerror)
: type(is_bool), valid(valid_)
explicit closure_value(bool b, value_error valid_ = error_noerror)
: type(is_bool), valid(valid_)
{ value.b = b; }
value_type get_type() const { return type; }
value_error is_valid() const { return valid; }
// explicit conversion
friend int_literal_type as_int(closure_value const& v)
{
@@ -91,7 +91,7 @@ public:
}
return v.value.i;
}
friend int_literal_type as_long(closure_value const& v)
friend int_literal_type as_long(closure_value const& v)
{
switch (v.type) {
case is_uint: return v.value.ui;
@@ -119,21 +119,21 @@ public:
return v.value.i != 0.0;
}
// assignment
// assignment
closure_value &operator= (closure_value const &rhs)
{
switch (rhs.get_type()) {
case is_int:
value.i = as_long(rhs);
case is_int:
value.i = as_long(rhs);
type = is_int;
break;
case is_uint:
value.ui = as_ulong(rhs);
case is_uint:
value.ui = as_ulong(rhs);
type = is_uint;
break;
case is_bool:
case is_bool:
value.b = as_bool(rhs);
type = is_bool;
break;
@@ -181,12 +181,12 @@ public:
closure_value &operator+= (closure_value const &rhs)
{
switch (type) {
case is_int:
case is_int:
switch(rhs.type) {
case is_bool:
{
int_literal_type result = value.i + as_long(rhs);
if ((rhs.value.i > 0L && value.i > result) ||
int_literal_type result = value.i + as_long(rhs);
if ((rhs.value.i > 0L && value.i > result) ||
(rhs.value.i < 0L && value.i < result))
{
valid = error_integer_overflow;
@@ -196,11 +196,11 @@ public:
}
}
break;
case is_int:
{
int_literal_type result = value.i + rhs.value.i;
if ((rhs.value.i > 0L && value.i > result) ||
if ((rhs.value.i > 0L && value.i > result) ||
(rhs.value.i < 0L && value.i < result))
{
valid = error_integer_overflow;
@@ -210,25 +210,25 @@ public:
}
}
break;
case is_uint:
{
uint_literal_type result = value.ui + rhs.value.ui;
uint_literal_type result = value.ui + rhs.value.ui;
if (result < value.ui) {
valid = error_integer_overflow;
}
else {
value.ui = result;
type = is_uint;
type = is_uint;
}
}
break;
}
break;
case is_uint:
{
uint_literal_type result = value.ui + as_ulong(rhs);
uint_literal_type result = value.ui + as_ulong(rhs);
if (result < value.ui) {
valid = error_integer_overflow;
}
@@ -237,8 +237,8 @@ public:
}
}
break;
case is_bool:
case is_bool:
value.i = value.b + as_bool(rhs);
type = is_int;
}
@@ -252,8 +252,8 @@ public:
switch(rhs.type) {
case is_bool:
{
int_literal_type result = value.i - as_long(rhs);
if ((rhs.value.i > 0L && result > value.i) ||
int_literal_type result = value.i - as_long(rhs);
if ((rhs.value.i > 0L && result > value.i) ||
(rhs.value.i < 0L && result < value.i))
{
valid = error_integer_overflow;
@@ -267,7 +267,7 @@ public:
case is_int:
{
int_literal_type result = value.i - rhs.value.i;
if ((rhs.value.i > 0L && result > value.i) ||
if ((rhs.value.i > 0L && result > value.i) ||
(rhs.value.i < 0L && result < value.i))
{
valid = error_integer_overflow;
@@ -277,27 +277,27 @@ public:
}
}
break;
case is_uint:
{
uint_literal_type result = value.ui - rhs.value.ui;
uint_literal_type result = value.ui - rhs.value.ui;
if (result > value.ui) {
valid = error_integer_overflow;
}
else {
value.ui = result;
type = is_uint;
type = is_uint;
}
}
break;
}
break;
case is_uint:
switch(rhs.type) {
case is_bool:
{
uint_literal_type result = value.ui - as_ulong(rhs);
uint_literal_type result = value.ui - as_ulong(rhs);
if (result > value.ui)
{
valid = error_integer_overflow;
@@ -311,7 +311,7 @@ public:
case is_int:
{
uint_literal_type result = value.ui - rhs.value.i;
if ((rhs.value.i > 0L && result > value.ui) ||
if ((rhs.value.i > 0L && result > value.ui) ||
(rhs.value.i < 0L && result < value.ui))
{
valid = error_integer_overflow;
@@ -321,10 +321,10 @@ public:
}
}
break;
case is_uint:
{
uint_literal_type result = value.ui - rhs.value.ui;
uint_literal_type result = value.ui - rhs.value.ui;
if (result > value.ui) {
valid = error_integer_overflow;
}
@@ -336,7 +336,7 @@ public:
}
break;
case is_bool:
case is_bool:
value.i = value.b - as_bool(rhs);
type = is_int;
}
@@ -346,12 +346,12 @@ public:
closure_value &operator*= (closure_value const &rhs)
{
switch (type) {
case is_int:
case is_int:
switch(rhs.type) {
case is_bool: value.i *= as_long(rhs); break;
case is_int:
{
int_literal_type result = value.i * rhs.value.i;
int_literal_type result = value.i * rhs.value.i;
if (0 != value.i && 0 != rhs.value.i &&
(result / value.i != rhs.value.i ||
result / rhs.value.i != value.i)
@@ -364,10 +364,10 @@ public:
}
}
break;
case is_uint:
{
uint_literal_type result = value.ui * rhs.value.ui;
uint_literal_type result = value.ui * rhs.value.ui;
if (0 != value.ui && 0 != rhs.value.ui &&
(result / value.ui != rhs.value.ui ||
result / rhs.value.ui != value.ui)
@@ -377,17 +377,17 @@ public:
}
else {
value.ui = result;
type = is_uint;
type = is_uint;
}
}
break;
}
break;
case is_uint:
{
uint_literal_type rhs_val = as_ulong(rhs);
uint_literal_type result = value.ui * rhs_val;
uint_literal_type result = value.ui * rhs_val;
if (0 != value.ui && 0 != rhs_val &&
(result / value.ui != rhs_val ||
result / rhs_val != value.ui)
@@ -397,23 +397,23 @@ public:
}
else {
value.ui = result;
type = is_uint;
type = is_uint;
}
}
break;
case is_bool:
switch (rhs.type) {
case is_int:
value.i = (value.b ? 1 : 0) * rhs.value.i;
type = is_int;
value.i = (value.b ? 1 : 0) * rhs.value.i;
type = is_int;
break;
case is_uint:
value.ui = (value.b ? 1 : 0) * rhs.value.ui;
type = is_uint;
value.ui = (value.b ? 1 : 0) * rhs.value.ui;
type = is_uint;
break;
case is_bool:
value.b = 0 != ((value.b ? 1 : 0) * (rhs.value.b ? 1 : 0));
break;
@@ -425,9 +425,9 @@ public:
closure_value &operator/= (closure_value const &rhs)
{
switch (type) {
case is_int:
case is_int:
switch(rhs.type) {
case is_bool:
case is_bool:
case is_int:
if (as_long(rhs) != 0) {
if (value.i == -value.i && -1 == rhs.value.i) {
@@ -435,18 +435,18 @@ public:
valid = error_integer_overflow;
}
else {
value.i /= as_long(rhs);
value.i /= as_long(rhs);
}
}
else {
valid = error_division_by_zero; // division by zero
}
break;
case is_uint:
if (rhs.value.ui != 0) {
value.ui /= rhs.value.ui;
type = is_uint;
value.ui /= rhs.value.ui;
type = is_uint;
}
else {
valid = error_division_by_zero; // division by zero
@@ -454,27 +454,27 @@ public:
break;
}
break;
case is_uint:
if (as_ulong(rhs) != 0)
value.ui /= as_ulong(rhs);
case is_uint:
if (as_ulong(rhs) != 0)
value.ui /= as_ulong(rhs);
else
valid = error_division_by_zero; // division by zero
break;
case is_bool:
case is_bool:
if (as_bool(rhs)) {
switch(rhs.type) {
case is_int:
value.i = (value.b ? 1 : 0) / rhs.value.i;
type = is_int;
break;
case is_uint:
value.i = (value.b ? 1 : 0) / rhs.value.ui;
type = is_int;
break;
case is_bool:
break;
}
@@ -488,9 +488,9 @@ public:
closure_value &operator%= (closure_value const &rhs)
{
switch (type) {
case is_int:
case is_int:
switch(rhs.type) {
case is_bool:
case is_bool:
case is_int:
if (as_long(rhs) != 0) {
if (value.i == -value.i && -1 == rhs.value.i) {
@@ -498,18 +498,18 @@ public:
valid = error_integer_overflow;
}
else {
value.i %= as_long(rhs);
value.i %= as_long(rhs);
}
}
else {
valid = error_division_by_zero; // division by zero
}
break;
case is_uint:
if (rhs.value.ui != 0) {
value.ui %= rhs.value.ui;
type = is_uint;
value.ui %= rhs.value.ui;
type = is_uint;
}
else {
valid = error_division_by_zero; // division by zero
@@ -517,30 +517,30 @@ public:
break;
}
break;
case is_uint:
if (as_ulong(rhs) != 0)
value.ui %= as_ulong(rhs);
case is_uint:
if (as_ulong(rhs) != 0)
value.ui %= as_ulong(rhs);
else
valid = error_division_by_zero; // division by zero
break;
case is_bool:
case is_bool:
if (as_bool(rhs)) {
switch(rhs.type) {
case is_int:
value.i = (value.b ? 1 : 0) % rhs.value.i;
type = is_int;
break;
case is_uint:
value.i = (value.b ? 1 : 0) % rhs.value.ui;
type = is_int;
break;
case is_bool:
break;
}
}
}
else {
valid = error_division_by_zero; // division by zero
@@ -549,7 +549,7 @@ public:
return *this;
}
friend closure_value
friend closure_value
operator- (closure_value const &rhs)
{
switch (rhs.type) {
@@ -560,8 +560,8 @@ public:
return closure_value(-value, error_integer_overflow);
return closure_value(-value, rhs.valid);
}
case is_bool: return closure_value(-as_long(rhs), rhs.valid);
case is_bool: return closure_value(-as_long(rhs), rhs.valid);
case is_uint: break;
}
@@ -570,24 +570,24 @@ public:
return closure_value(-value, error_integer_overflow);
return closure_value(-value, rhs.valid);
}
friend closure_value
friend closure_value
operator~ (closure_value const &rhs)
{
return closure_value(~as_ulong(rhs), rhs.valid);
return closure_value(~as_ulong(rhs), rhs.valid);
}
friend closure_value
friend closure_value
operator! (closure_value const &rhs)
{
switch (rhs.type) {
case is_int: return closure_value(!as_long(rhs), rhs.valid);
case is_bool: return closure_value(!as_bool(rhs), rhs.valid);
case is_bool: return closure_value(!as_bool(rhs), rhs.valid);
case is_uint: break;
}
return closure_value(!as_ulong(rhs), rhs.valid);
}
// comparison
friend closure_value
friend closure_value
operator== (closure_value const &lhs, closure_value const &rhs)
{
bool cmp = false;
@@ -599,18 +599,18 @@ public:
case is_uint: cmp = lhs.value.ui == rhs.value.ui; break;
}
break;
case is_uint: cmp = lhs.value.ui == as_ulong(rhs); break;
case is_bool: cmp = lhs.value.b == as_bool(rhs); break;
}
return closure_value(cmp, (value_error)(lhs.valid | rhs.valid));
}
friend closure_value
friend closure_value
operator!= (closure_value const &lhs, closure_value const &rhs)
{
return closure_value(!as_bool(lhs == rhs), (value_error)(lhs.valid | rhs.valid));
}
friend closure_value
friend closure_value
operator> (closure_value const &lhs, closure_value const &rhs)
{
bool cmp = false;
@@ -622,13 +622,13 @@ public:
case is_uint: cmp = lhs.value.ui > rhs.value.ui; break;
}
break;
case is_uint: cmp = lhs.value.ui > as_ulong(rhs); break;
case is_bool: cmp = lhs.value.b > as_bool(rhs); break;
}
return closure_value(cmp, (value_error)(lhs.valid | rhs.valid));
}
friend closure_value
friend closure_value
operator< (closure_value const &lhs, closure_value const &rhs)
{
bool cmp = false;
@@ -640,18 +640,18 @@ public:
case is_uint: cmp = lhs.value.ui < rhs.value.ui; break;
}
break;
case is_uint: cmp = lhs.value.ui < as_ulong(rhs); break;
case is_bool: cmp = as_bool(lhs) < as_bool(rhs); break;
}
return closure_value(cmp, (value_error)(lhs.valid | rhs.valid));
}
friend closure_value
friend closure_value
operator<= (closure_value const &lhs, closure_value const &rhs)
{
return closure_value(!as_bool(lhs > rhs), (value_error)(lhs.valid | rhs.valid));
}
friend closure_value
friend closure_value
operator>= (closure_value const &lhs, closure_value const &rhs)
{
return closure_value(!as_bool(lhs < rhs), (value_error)(lhs.valid | rhs.valid));
@@ -668,24 +668,24 @@ public:
case is_int:
{
int_literal_type shift_by = as_long(rhs);
if (shift_by > 64)
if (shift_by > 64)
shift_by = 64;
else if (shift_by < -64)
shift_by = -64;
value.i <<= shift_by;
value.i <<= shift_by;
}
break;
case is_uint:
{
uint_literal_type shift_by = as_ulong(rhs);
if (shift_by > 64)
if (shift_by > 64)
shift_by = 64;
value.ui <<= shift_by;
// Note: The usual arithmetic conversions are not performed on
value.ui <<= shift_by;
// Note: The usual arithmetic conversions are not performed on
// bit shift operations.
}
break;
@@ -698,22 +698,22 @@ public:
case is_int:
{
int_literal_type shift_by = as_long(rhs);
if (shift_by > 64)
if (shift_by > 64)
shift_by = 64;
else if (shift_by < -64)
shift_by = -64;
value.ui <<= shift_by;
value.ui <<= shift_by;
}
break;
case is_uint:
{
uint_literal_type shift_by = as_ulong(rhs);
if (shift_by > 64)
if (shift_by > 64)
shift_by = 64;
value.ui <<= shift_by;
value.ui <<= shift_by;
}
break;
}
@@ -733,52 +733,52 @@ public:
case is_int:
{
int_literal_type shift_by = as_long(rhs);
if (shift_by > 64)
if (shift_by > 64)
shift_by = 64;
else if (shift_by < -64)
shift_by = -64;
value.i >>= shift_by;
value.i >>= shift_by;
}
break;
case is_uint:
{
uint_literal_type shift_by = as_ulong(rhs);
if (shift_by > 64)
if (shift_by > 64)
shift_by = 64;
value.ui >>= shift_by;
// Note: The usual arithmetic conversions are not performed on
value.ui >>= shift_by;
// Note: The usual arithmetic conversions are not performed on
// bit shift operations.
}
break;
}
break;
case is_uint:
switch (rhs.type) {
case is_bool:
case is_int:
{
int_literal_type shift_by = as_long(rhs);
if (shift_by > 64)
if (shift_by > 64)
shift_by = 64;
else if (shift_by < -64)
shift_by = -64;
value.ui >>= shift_by;
value.ui >>= shift_by;
}
break;
case is_uint:
{
uint_literal_type shift_by = as_ulong(rhs);
if (shift_by > 64)
if (shift_by > 64)
shift_by = 64;
value.ui >>= shift_by;
value.ui >>= shift_by;
}
break;
}
@@ -788,41 +788,41 @@ public:
return *this;
}
friend closure_value
friend closure_value
operator|| (closure_value const &lhs, closure_value const &rhs)
{
bool result = as_bool(lhs) || as_bool(rhs);
return closure_value(result, (value_error)(lhs.valid | rhs.valid));
}
friend closure_value
friend closure_value
operator&& (closure_value const &lhs, closure_value const &rhs)
{
bool result = as_bool(lhs) && as_bool(rhs);
return closure_value(result, (value_error)(lhs.valid | rhs.valid));
}
friend closure_value
friend closure_value
operator| (closure_value const &lhs, closure_value const &rhs)
{
uint_literal_type result = as_ulong(lhs) | as_ulong(rhs);
return closure_value(result, (value_error)(lhs.valid | rhs.valid));
}
friend closure_value
friend closure_value
operator& (closure_value const &lhs, closure_value const &rhs)
{
uint_literal_type result = as_ulong(lhs) & as_ulong(rhs);
return closure_value(result, (value_error)(lhs.valid | rhs.valid));
}
friend closure_value
friend closure_value
operator^ (closure_value const &lhs, closure_value const &rhs)
{
uint_literal_type result = as_ulong(lhs) ^ as_ulong(rhs);
return closure_value(result, (value_error)(lhs.valid | rhs.valid));
}
// handle the ?: operator
closure_value &
handle_questionmark(closure_value const &cond, closure_value const &val2)
@@ -832,20 +832,20 @@ public:
switch (val2.type) {
case is_bool: value.b = as_bool(cond) ? value.b : as_bool(val2); break;
case is_int: value.i = as_bool(cond) ? value.i : as_long(val2); break;
case is_uint:
value.ui = as_bool(cond) ? value.ui : as_ulong(val2);
case is_uint:
value.ui = as_bool(cond) ? value.ui : as_ulong(val2);
type = is_uint; // changing type!
break;
}
break;
case is_uint: value.ui = as_bool(cond) ? value.ui : as_ulong(val2); break;
case is_bool: value.b = as_bool(cond) ? value.b : as_bool(val2); break;
}
valid = as_bool(cond) ? valid : val2.valid;
return *this;
}
#if defined (BOOST_SPIRIT_DEBUG)
friend std::ostream&
operator<< (std::ostream &o, closure_value const &val)

View File

@@ -38,7 +38,7 @@
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace wave {
namespace grammars {
namespace impl {
@@ -47,7 +47,7 @@ namespace impl {
//
// store_found_eof
//
// The store_found_eof functor sets a given flag if the T_EOF token was
// The store_found_eof functor sets a given flag if the T_EOF token was
// found during the parsing process
//
///////////////////////////////////////////////////////////////////////////////
@@ -55,13 +55,13 @@ namespace impl {
struct store_found_eof {
store_found_eof(bool &found_eof_) : found_eof(found_eof_) {}
template <typename TokenT>
void operator()(TokenT const &/*token*/) const
{
found_eof = true;
}
bool &found_eof;
};
@@ -77,14 +77,14 @@ namespace impl {
template <typename TokenT>
struct store_found_directive {
store_found_directive(TokenT &found_directive_)
store_found_directive(TokenT &found_directive_)
: found_directive(found_directive_) {}
void operator()(TokenT const &token) const
{
found_directive = token;
}
TokenT &found_directive;
};
@@ -92,7 +92,7 @@ namespace impl {
//
// store_found_eoltokens
//
// The store_found_eoltokens functor stores the token sequence of the
// The store_found_eoltokens functor stores the token sequence of the
// line ending for a particular pp directive
//
///////////////////////////////////////////////////////////////////////////////
@@ -100,16 +100,16 @@ namespace impl {
template <typename ContainerT>
struct store_found_eoltokens {
store_found_eoltokens(ContainerT &found_eoltokens_)
store_found_eoltokens(ContainerT &found_eoltokens_)
: found_eoltokens(found_eoltokens_) {}
template <typename IteratorT>
void operator()(IteratorT const &first, IteratorT const& last) const
{
std::copy(first, last,
std::copy(first, last,
std::inserter(found_eoltokens, found_eoltokens.end()));
}
ContainerT &found_eoltokens;
};
@@ -134,11 +134,11 @@ namespace impl {
parse(ScannerT const& scan) const
{
scan.first.clear_queue();
return scan.empty_match();
return scan.empty_match();
}
};
flush_underlying_parser const
flush_underlying_parser const
flush_underlying_parser_p = flush_underlying_parser();
} // anonymous namespace
@@ -152,7 +152,7 @@ namespace impl {
///////////////////////////////////////////////////////////////////////////////
// Encapsulation of the C++ preprocessor grammar.
template <typename TokenT, typename ContainerT>
struct cpp_grammar :
struct cpp_grammar :
public boost::spirit::classic::grammar<cpp_grammar<TokenT, ContainerT> >
{
typedef typename TokenT::position_type position_type;
@@ -160,7 +160,7 @@ struct cpp_grammar :
typedef impl::store_found_eof store_found_eof_type;
typedef impl::store_found_directive<TokenT> store_found_directive_type;
typedef impl::store_found_eoltokens<ContainerT> store_found_eoltokens_type;
template <typename ScannerT>
struct definition
{
@@ -168,22 +168,22 @@ struct cpp_grammar :
typedef typename ScannerT::iteration_policy_t iteration_policy_t;
typedef boost::spirit::classic::match_policy match_policy_t;
typedef typename ScannerT::action_policy_t action_policy_t;
typedef
typedef
boost::spirit::classic::scanner_policies<
iteration_policy_t, match_policy_t, action_policy_t>
iteration_policy_t, match_policy_t, action_policy_t>
policies_t;
typedef
boost::spirit::classic::scanner<typename ScannerT::iterator_t, policies_t>
typedef
boost::spirit::classic::scanner<typename ScannerT::iterator_t, policies_t>
non_tree_scanner_t;
typedef
typedef
boost::spirit::classic::rule<
non_tree_scanner_t, boost::spirit::classic::dynamic_parser_tag>
non_tree_scanner_t, boost::spirit::classic::dynamic_parser_tag>
no_tree_rule_type;
// 'normal' (parse_tree generating) rule type
typedef
typedef
boost::spirit::classic::rule<
ScannerT, boost::spirit::classic::dynamic_parser_tag>
ScannerT, boost::spirit::classic::dynamic_parser_tag>
rule_type;
rule_type pp_statement, macro_include_file;
@@ -192,7 +192,7 @@ struct cpp_grammar :
rule_type undefine;
rule_type ppifdef, ppifndef, ppif, ppelif;
// rule_type ppelse, ppendif;
rule_type ppline;
rule_type ppline;
rule_type pperror;
rule_type ppwarning;
rule_type pppragma;
@@ -205,7 +205,7 @@ struct cpp_grammar :
rule_type ppendregion;
#endif
definition(cpp_grammar const &self)
definition(cpp_grammar const &self)
{
// import the spirit and cpplexer namespaces here
using namespace boost::spirit::classic;
@@ -241,16 +241,16 @@ struct cpp_grammar :
#if BOOST_WAVE_DUMP_PARSE_TREE != 0
self.map_rule_id_to_name.init_rule_id_to_name_map(self);
#endif
#endif
// recognizes preprocessor directives only
// C++ standard 16.1: A preprocessing directive consists of a sequence
// of preprocessing tokens. The first token in the sequence is #
// preprocessing token that is either the first character in the source
// file (optionally after white space containing no new-line
// characters) or that follows white space containing at least one
// new-line character. The last token in the sequence is the first
// C++ standard 16.1: A preprocessing directive consists of a sequence
// of preprocessing tokens. The first token in the sequence is #
// preprocessing token that is either the first character in the source
// file (optionally after white space containing no new-line
// characters) or that follows white space containing at least one
// new-line character. The last token in the sequence is the first
// new-line character that follows the first token in the sequence.
pp_statement
@@ -290,21 +290,21 @@ struct cpp_grammar :
// // #include ...
// include_file // include "..."
// = ch_p(T_PP_QHEADER)
// = ch_p(T_PP_QHEADER)
// [ store_found_directive_type(self.found_directive) ]
// #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
// | ch_p(T_PP_QHEADER_NEXT)
// [ store_found_directive_type(self.found_directive) ]
// #endif
// #endif
// ;
// system_include_file // include <...>
// = ch_p(T_PP_HHEADER)
// = ch_p(T_PP_HHEADER)
// [ store_found_directive_type(self.found_directive) ]
// #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
// | ch_p(T_PP_HHEADER_NEXT)
// [ store_found_directive_type(self.found_directive) ]
// #endif
// #endif
// ;
macro_include_file // include ...anything else...
@@ -318,7 +318,7 @@ struct cpp_grammar :
#endif
]
>> *( anychar_p -
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
)
;
@@ -326,23 +326,23 @@ struct cpp_grammar :
plain_define
= no_node_d
[
ch_p(T_PP_DEFINE)
ch_p(T_PP_DEFINE)
[ store_found_directive_type(self.found_directive) ]
>> +ppsp
]
>> ( ch_p(T_IDENTIFIER)
| pattern_p(KeywordTokenType,
>> ( ch_p(T_IDENTIFIER)
| pattern_p(KeywordTokenType,
TokenTypeMask|PPTokenFlag)
| pattern_p(OperatorTokenType|AltExtTokenType,
| pattern_p(OperatorTokenType|AltExtTokenType,
ExtTokenTypeMask|PPTokenFlag) // and, bit_and etc.
| pattern_p(BoolLiteralTokenType,
| pattern_p(BoolLiteralTokenType,
TokenTypeMask|PPTokenFlag) // true/false
)
>> ( ( no_node_d[eps_p(ch_p(T_LEFTPAREN))]
>> macro_parameters
>> !macro_definition
)
| !( no_node_d[+ppsp]
| !( no_node_d[+ppsp]
>> macro_definition
)
)
@@ -354,45 +354,45 @@ struct cpp_grammar :
= confix_p(
no_node_d[ch_p(T_LEFTPAREN) >> *ppsp],
!list_p(
( ch_p(T_IDENTIFIER)
| pattern_p(KeywordTokenType,
( ch_p(T_IDENTIFIER)
| pattern_p(KeywordTokenType,
TokenTypeMask|PPTokenFlag)
| pattern_p(OperatorTokenType|AltExtTokenType,
| pattern_p(OperatorTokenType|AltExtTokenType,
ExtTokenTypeMask|PPTokenFlag) // and, bit_and etc.
| pattern_p(BoolLiteralTokenType,
| pattern_p(BoolLiteralTokenType,
TokenTypeMask|PPTokenFlag) // true/false
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
| ch_p(T_ELLIPSIS)
#endif
),
),
no_node_d[*ppsp >> ch_p(T_COMMA) >> *ppsp]
),
no_node_d[*ppsp >> ch_p(T_RIGHTPAREN)]
)
;
// macro body (anything left until eol)
macro_definition
= no_node_d[*ppsp]
>> *( anychar_p -
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
)
;
// #undef FOO
// #undef FOO
undefine
= no_node_d
[
ch_p(T_PP_UNDEF)
ch_p(T_PP_UNDEF)
[ store_found_directive_type(self.found_directive) ]
>> +ppsp
]
>> ( ch_p(T_IDENTIFIER)
| pattern_p(KeywordTokenType,
>> ( ch_p(T_IDENTIFIER)
| pattern_p(KeywordTokenType,
TokenTypeMask|PPTokenFlag)
| pattern_p(OperatorTokenType|AltExtTokenType,
| pattern_p(OperatorTokenType|AltExtTokenType,
ExtTokenTypeMask|PPTokenFlag) // and, bit_and etc.
| pattern_p(BoolLiteralTokenType,
| pattern_p(BoolLiteralTokenType,
TokenTypeMask|PPTokenFlag) // true/false
)
;
@@ -401,7 +401,7 @@ struct cpp_grammar :
ppifdef
= no_node_d
[
ch_p(T_PP_IFDEF)
ch_p(T_PP_IFDEF)
[ store_found_directive_type(self.found_directive) ]
>> +ppsp
]
@@ -411,7 +411,7 @@ struct cpp_grammar :
ppifndef
= no_node_d
[
ch_p(T_PP_IFNDEF)
ch_p(T_PP_IFNDEF)
[ store_found_directive_type(self.found_directive) ]
>> +ppsp
]
@@ -421,12 +421,12 @@ struct cpp_grammar :
ppif
= no_node_d
[
ch_p(T_PP_IF)
ch_p(T_PP_IF)
[ store_found_directive_type(self.found_directive) ]
// >> *ppsp
]
>> +( anychar_p -
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
)
;
@@ -441,12 +441,12 @@ struct cpp_grammar :
ppelif
= no_node_d
[
ch_p(T_PP_ELIF)
ch_p(T_PP_ELIF)
[ store_found_directive_type(self.found_directive) ]
// >> *ppsp
]
>> +( anychar_p -
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
)
;
@@ -459,24 +459,24 @@ struct cpp_grammar :
// ;
// #line ...
ppline
ppline
= no_node_d
[
ch_p(T_PP_LINE)
ch_p(T_PP_LINE)
[ store_found_directive_type(self.found_directive) ]
>> *ppsp
]
>> +( anychar_p -
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
)
;
#if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
// #region ...
ppregion
= no_node_d
[
ch_p(T_MSEXT_PP_REGION)
ch_p(T_MSEXT_PP_REGION)
[ store_found_directive_type(self.found_directive) ]
>> +ppsp
]
@@ -487,7 +487,7 @@ struct cpp_grammar :
ppendregion
= no_node_d
[
ch_p(T_MSEXT_PP_ENDREGION)
ch_p(T_MSEXT_PP_ENDREGION)
[ store_found_directive_type(self.found_directive) ]
]
;
@@ -497,16 +497,16 @@ struct cpp_grammar :
illformed // for error reporting
= no_node_d
[
pattern_p(T_POUND, MainTokenMask)
pattern_p(T_POUND, MainTokenMask)
>> *ppsp
]
>> ( anychar_p -
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
)
>> no_node_d
[
*( anychar_p -
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
)
]
;
@@ -515,12 +515,12 @@ struct cpp_grammar :
pperror
= no_node_d
[
ch_p(T_PP_ERROR)
ch_p(T_PP_ERROR)
[ store_found_directive_type(self.found_directive) ]
>> *ppsp
]
>> *( anychar_p -
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
)
;
@@ -528,12 +528,12 @@ struct cpp_grammar :
ppwarning
= no_node_d
[
ch_p(T_PP_WARNING)
ch_p(T_PP_WARNING)
[ store_found_directive_type(self.found_directive) ]
>> *ppsp
]
>> *( anychar_p -
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
)
;
@@ -543,22 +543,22 @@ struct cpp_grammar :
[
ch_p(T_PP_PRAGMA)
[ store_found_directive_type(self.found_directive) ]
]
]
>> *( anychar_p -
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
(ch_p(T_NEWLINE) | ch_p(T_CPPCOMMENT) | ch_p(T_EOF))
)
;
ppqualifiedname
= no_node_d[*ppsp]
>> ( ch_p(T_IDENTIFIER)
| pattern_p(KeywordTokenType,
>> ( ch_p(T_IDENTIFIER)
| pattern_p(KeywordTokenType,
TokenTypeMask|PPTokenFlag)
| pattern_p(OperatorTokenType|AltExtTokenType,
| pattern_p(OperatorTokenType|AltExtTokenType,
ExtTokenTypeMask|PPTokenFlag) // and, bit_and etc.
| pattern_p(BoolLiteralTokenType,
| pattern_p(BoolLiteralTokenType,
TokenTypeMask|PPTokenFlag) // true/false
)
)
;
// auxiliary helper rules
@@ -567,10 +567,10 @@ struct cpp_grammar :
;
// end of line tokens
eol_tokens
eol_tokens
= no_node_d
[
*( ch_p(T_SPACE)
*( ch_p(T_SPACE)
| ch_p(T_CCOMMENT)
)
>> ( ch_p(T_NEWLINE)
@@ -615,21 +615,21 @@ struct cpp_grammar :
bool &found_eof;
TokenT &found_directive;
ContainerT &found_eoltokens;
cpp_grammar(bool &found_eof_, TokenT &found_directive_,
cpp_grammar(bool &found_eof_, TokenT &found_directive_,
ContainerT &found_eoltokens_)
: found_eof(found_eof_),
: found_eof(found_eof_),
found_directive(found_directive_),
found_eoltokens(found_eoltokens_)
{
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "cpp_grammar",
TRACE_CPP_GRAMMAR);
{
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "cpp_grammar",
TRACE_CPP_GRAMMAR);
}
#if BOOST_WAVE_DUMP_PARSE_TREE != 0
// helper function and data to get readable names of the rules known to us
struct map_ruleid_to_name :
public std::map<boost::spirit::classic::parser_id, std::string>
public std::map<boost::spirit::classic::parser_id, std::string>
{
typedef std::map<boost::spirit::classic::parser_id, std::string> base_type;
@@ -638,7 +638,7 @@ struct cpp_grammar :
struct {
int parser_id;
char const *rule_name;
}
}
init_ruleid_name_map[] = {
{ BOOST_WAVE_PP_STATEMENT_ID, "pp_statement" },
// { BOOST_WAVE_INCLUDE_FILE_ID, "include_file" },
@@ -671,7 +671,7 @@ struct cpp_grammar :
// initialize parser_id to rule_name map
for (int i = 0; 0 != init_ruleid_name_map[i].parser_id; ++i)
base_type::insert(base_type::value_type(
boost::spirit::classic::parser_id(init_ruleid_name_map[i].parser_id),
boost::spirit::classic::parser_id(init_ruleid_name_map[i].parser_id),
std::string(init_ruleid_name_map[i].rule_name))
);
}
@@ -694,7 +694,7 @@ parsetree_parse(IteratorT const& first_, IteratorT const& last,
boost::spirit::classic::parser<ParserT> const& p)
{
using namespace boost::spirit::classic;
typedef pt_match_policy<IteratorT, NodeFactoryT> pt_match_policy_type;
typedef scanner_policies<iteration_policy, pt_match_policy_type>
scanner_policies_type;
@@ -709,22 +709,22 @@ parsetree_parse(IteratorT const& first_, IteratorT const& last,
}
///////////////////////////////////////////////////////////////////////////////
//
// The following parse function is defined here, to allow the separation of
//
// The following parse function is defined here, to allow the separation of
// the compilation of the cpp_grammar from the function using it.
//
//
///////////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#define BOOST_WAVE_GRAMMAR_GEN_INLINE
#else
#define BOOST_WAVE_GRAMMAR_GEN_INLINE inline
#endif
#endif
template <typename LexIteratorT, typename TokenContainerT>
BOOST_WAVE_GRAMMAR_GEN_INLINE
BOOST_WAVE_GRAMMAR_GEN_INLINE
boost::spirit::classic::tree_parse_info<
LexIteratorT,
LexIteratorT,
typename cpp_grammar_gen<LexIteratorT, TokenContainerT>::node_factory_type
>
cpp_grammar_gen<LexIteratorT, TokenContainerT>::parse_cpp_grammar (
@@ -734,15 +734,15 @@ cpp_grammar_gen<LexIteratorT, TokenContainerT>::parse_cpp_grammar (
{
using namespace boost::spirit::classic;
using namespace boost::wave;
cpp_grammar<token_type, TokenContainerT> g(found_eof, found_directive, found_eoltokens);
tree_parse_info<LexIteratorT, node_factory_type> hit =
tree_parse_info<LexIteratorT, node_factory_type> hit =
parsetree_parse<node_factory_type>(first, last, g);
#if BOOST_WAVE_DUMP_PARSE_TREE != 0
if (hit.match) {
tree_to_xml (BOOST_WAVE_DUMP_PARSE_TREE_OUT, hit.trees, "",
g.map_rule_id_to_name, &token_type::get_token_id,
tree_to_xml (BOOST_WAVE_DUMP_PARSE_TREE_OUT, hit.trees, "",
g.map_rule_id_to_name, &token_type::get_token_id,
&token_type::get_token_value);
}
#endif
@@ -755,7 +755,7 @@ cpp_grammar_gen<LexIteratorT, TokenContainerT>::parse_cpp_grammar (
///////////////////////////////////////////////////////////////////////////////
} // namespace grammars
} // namespace wave
} // namespace boost
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS

View File

@@ -65,10 +65,10 @@ namespace grammars {
#define BOOST_WAVE_ENDREGION_ID 23
///////////////////////////////////////////////////////////////////////////////
//
//
// cpp_grammar_gen template class
//
// This template helps separating the compilation of the cpp_grammar
// This template helps separating the compilation of the cpp_grammar
// class from the compilation of the main pp_iterator. This is done to
// safe compilation time.
//
@@ -83,13 +83,13 @@ struct BOOST_WAVE_DECL cpp_grammar_gen
typedef typename token_type::position_type position_type;
typedef boost::spirit::classic::node_val_data_factory<
// boost::spirit::nil_t,
// boost::pool_allocator<boost::spirit::nil_t>
// boost::pool_allocator<boost::spirit::nil_t>
> node_factory_type;
// parse the cpp_grammar and return the resulting parse tree
static boost::spirit::classic::tree_parse_info<iterator_type, node_factory_type>
// parse the cpp_grammar and return the resulting parse tree
static boost::spirit::classic::tree_parse_info<iterator_type, node_factory_type>
parse_cpp_grammar (iterator_type const &first, iterator_type const &last,
position_type const &act_pos, bool &found_eof,
position_type const &act_pos, bool &found_eof,
token_type &found_directive, token_container_type &found_eoltokens);
};

View File

@@ -41,14 +41,14 @@
//
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace wave {
namespace grammars {
///////////////////////////////////////////////////////////////////////////////
namespace closures {
struct intlit_closure
: boost::spirit::classic::closure<intlit_closure, uint_literal_type>
struct intlit_closure
: boost::spirit::classic::closure<intlit_closure, uint_literal_type>
{
member1 val;
};
@@ -65,10 +65,10 @@ struct intlit_grammar :
{
intlit_grammar(bool &is_unsigned_) : is_unsigned(is_unsigned_)
{
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "intlit_grammar",
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this, "intlit_grammar",
TRACE_INTLIT_GRAMMAR);
}
template <typename ScannerT>
struct definition
{
@@ -84,15 +84,15 @@ struct intlit_grammar :
{
using namespace boost::spirit::classic;
namespace phx = phoenix;
int_lit = (
sub_int_lit =
sub_int_lit =
( ch_p('0')[self.val = 0] >> (hex_lit | oct_lit)
| dec_lit
)
>> !as_lower_d[
(ch_p('u')[phx::var(self.is_unsigned) = true] || ch_p('l'))
(ch_p('u')[phx::var(self.is_unsigned) = true] || ch_p('l'))
| (ch_p('l') || ch_p('u')[phx::var(self.is_unsigned) = true])
]
,
@@ -105,7 +105,7 @@ struct intlit_grammar :
phx::var(self.is_unsigned) = true
]
,
oct_lit =
!uint_parser<uint_literal_type, 8>()
[
@@ -113,7 +113,7 @@ struct intlit_grammar :
phx::var(self.is_unsigned) = true
]
,
dec_lit =
uint_parser<uint_literal_type, 10>()
[
@@ -121,7 +121,7 @@ struct intlit_grammar :
]
)
;
BOOST_SPIRIT_DEBUG_TRACE_RULE(int_lit, TRACE_INTLIT_GRAMMAR);
BOOST_SPIRIT_DEBUG_TRACE_RULE(sub_int_lit, TRACE_INTLIT_GRAMMAR);
BOOST_SPIRIT_DEBUG_TRACE_RULE(hex_lit, TRACE_INTLIT_GRAMMAR);
@@ -133,33 +133,33 @@ struct intlit_grammar :
rule_t const& start() const
{ return int_lit; }
};
bool &is_unsigned;
};
#undef TRACE_INTLIT_GRAMMAR
///////////////////////////////////////////////////////////////////////////////
//
// The following function is defined here, to allow the separation of
//
// The following function is defined here, to allow the separation of
// the compilation of the intlit_grammar from the function using it.
//
//
///////////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#define BOOST_WAVE_INTLITGRAMMAR_GEN_INLINE
#else
#define BOOST_WAVE_INTLITGRAMMAR_GEN_INLINE inline
#endif
#endif
template <typename TokenT>
BOOST_WAVE_INTLITGRAMMAR_GEN_INLINE
uint_literal_type
intlit_grammar_gen<TokenT>::evaluate(TokenT const &token,
BOOST_WAVE_INTLITGRAMMAR_GEN_INLINE
uint_literal_type
intlit_grammar_gen<TokenT>::evaluate(TokenT const &token,
bool &is_unsigned)
{
using namespace boost::spirit::classic;
intlit_grammar g(is_unsigned);
uint_literal_type result = 0;
typename TokenT::string_type const &token_val = token.get_value();
@@ -167,7 +167,7 @@ parse_info<typename TokenT::string_type::const_iterator> hit =
parse(token_val.begin(), token_val.end(), g[spirit_assign_actor(result)]);
if (!hit.hit) {
BOOST_WAVE_THROW(preprocess_exception, ill_formed_integer_literal,
BOOST_WAVE_THROW(preprocess_exception, ill_formed_integer_literal,
token_val.c_str(), token.get_position());
}
return result;

View File

@@ -31,11 +31,11 @@ namespace wave {
namespace grammars {
///////////////////////////////////////////////////////////////////////////////
//
//
// cpp_intlit_grammar_gen template class
//
// This template helps separating the compilation of the intlit_grammar
// class from the compilation of the expression_grammar. This is done
// This template helps separating the compilation of the intlit_grammar
// class from the compilation of the expression_grammar. This is done
// to safe compilation time.
//
///////////////////////////////////////////////////////////////////////////////
@@ -46,11 +46,11 @@ struct BOOST_WAVE_DECL intlit_grammar_gen {
};
///////////////////////////////////////////////////////////////////////////////
//
//
// cpp_chlit_grammar_gen template class
//
// This template helps separating the compilation of the chlit_grammar
// class from the compilation of the expression_grammar. This is done
// This template helps separating the compilation of the chlit_grammar
// class from the compilation of the expression_grammar. This is done
// to safe compilation time.
//
///////////////////////////////////////////////////////////////////////////////
@@ -62,7 +62,7 @@ struct BOOST_WAVE_DECL chlit_grammar_gen {
///////////////////////////////////////////////////////////////////////////////
} // namespace grammars
} // namespace wave
} // namespace wave
} // namespace boost
#ifdef BOOST_MSVC

View File

@@ -41,11 +41,11 @@ namespace grammars {
#define BOOST_WAVE_MACRO_DEFINITION_ID 7
///////////////////////////////////////////////////////////////////////////////
//
//
// predefined_macros_grammar_gen template class
//
// This template helps separating the compilation of the
// predefined_macros_grammar class from the compilation of the
// This template helps separating the compilation of the
// predefined_macros_grammar class from the compilation of the
// main pp_iterator. This is done to safe compilation time.
//
// This class helps parsing command line given macro definitions in a
@@ -58,8 +58,8 @@ struct BOOST_WAVE_DECL predefined_macros_grammar_gen
{
typedef LexIteratorT iterator_type;
// parse the cpp_grammar and return the resulting parse tree
static boost::spirit::classic::tree_parse_info<iterator_type>
// parse the cpp_grammar and return the resulting parse tree
static boost::spirit::classic::tree_parse_info<iterator_type>
parse_predefined_macro (iterator_type const &first, iterator_type const &last);
};

View File

@@ -39,7 +39,7 @@ namespace grammars {
///////////////////////////////////////////////////////////////////////////////
// Encapsulation of the grammar for command line driven predefined macros.
struct predefined_macros_grammar :
struct predefined_macros_grammar :
public boost::spirit::classic::grammar<predefined_macros_grammar>
{
template <typename ScannerT>
@@ -47,18 +47,18 @@ struct predefined_macros_grammar :
{
// 'normal' (parse_tree generating) rule type
typedef boost::spirit::classic::rule<
ScannerT, boost::spirit::classic::dynamic_parser_tag>
ScannerT, boost::spirit::classic::dynamic_parser_tag>
rule_type;
rule_type plain_define, macro_definition, macro_parameters;
definition(predefined_macros_grammar const &/*self*/)
definition(predefined_macros_grammar const &/*self*/)
{
// import the spirit and cpplexer namespaces here
using namespace boost::spirit::classic;
using namespace boost::wave;
using namespace boost::wave::util;
// set the rule id's for later use
plain_define.set_id(BOOST_WAVE_PLAIN_DEFINE_ID);
macro_parameters.set_id(BOOST_WAVE_MACRO_PARAMETERS_ID);
@@ -76,11 +76,11 @@ struct predefined_macros_grammar :
// make it possible to reuse the parse tree traversal code
plain_define
= ( ch_p(T_IDENTIFIER)
| pattern_p(KeywordTokenType,
| pattern_p(KeywordTokenType,
TokenTypeMask|PPTokenFlag)
| pattern_p(OperatorTokenType|AltExtTokenType,
| pattern_p(OperatorTokenType|AltExtTokenType,
ExtTokenTypeMask|PPTokenFlag) // and, bit_and etc.
| pattern_p(BoolLiteralTokenType,
| pattern_p(BoolLiteralTokenType,
TokenTypeMask|PPTokenFlag) // true/false
)
>> !macro_parameters
@@ -93,16 +93,16 @@ struct predefined_macros_grammar :
no_node_d[ch_p(T_LEFTPAREN) >> *ch_p(T_SPACE)],
!list_p(
( ch_p(T_IDENTIFIER)
| pattern_p(KeywordTokenType,
| pattern_p(KeywordTokenType,
TokenTypeMask|PPTokenFlag)
| pattern_p(OperatorTokenType|AltExtTokenType,
| pattern_p(OperatorTokenType|AltExtTokenType,
ExtTokenTypeMask|PPTokenFlag) // and, bit_and etc.
| pattern_p(BoolLiteralTokenType,
| pattern_p(BoolLiteralTokenType,
TokenTypeMask|PPTokenFlag) // true/false
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
| ch_p(T_ELLIPSIS)
#endif
),
),
no_node_d
[
*ch_p(T_SPACE) >> ch_p(T_COMMA) >> *ch_p(T_SPACE)
@@ -128,10 +128,10 @@ struct predefined_macros_grammar :
{ return plain_define; }
};
predefined_macros_grammar()
{
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this,
"predefined_macros_grammar", TRACE_PREDEF_MACROS_GRAMMAR);
predefined_macros_grammar()
{
BOOST_SPIRIT_DEBUG_TRACE_GRAMMAR_NAME(*this,
"predefined_macros_grammar", TRACE_PREDEF_MACROS_GRAMMAR);
}
};
@@ -140,21 +140,21 @@ struct predefined_macros_grammar :
#undef TRACE_PREDEF_MACROS_GRAMMAR
///////////////////////////////////////////////////////////////////////////////
//
// The following parse function is defined here, to allow the separation of
// the compilation of the cpp_predefined_macros_grammar from the function
//
// The following parse function is defined here, to allow the separation of
// the compilation of the cpp_predefined_macros_grammar from the function
// using it.
//
//
///////////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0
#define BOOST_WAVE_PREDEF_MACROS_GRAMMAR_GEN_INLINE
#else
#define BOOST_WAVE_PREDEF_MACROS_GRAMMAR_GEN_INLINE inline
#endif
#endif
template <typename LexIteratorT>
BOOST_WAVE_PREDEF_MACROS_GRAMMAR_GEN_INLINE
BOOST_WAVE_PREDEF_MACROS_GRAMMAR_GEN_INLINE
boost::spirit::classic::tree_parse_info<LexIteratorT>
predefined_macros_grammar_gen<LexIteratorT>::parse_predefined_macro (
LexIteratorT const &first, LexIteratorT const &last)

View File

@@ -27,7 +27,7 @@ namespace grammars {
//
// value_error enum type
//
// This is used to encode any error occurred during the evaluation of a
// This is used to encode any error occurred during the evaluation of a
// conditional preprocessor expression
//
///////////////////////////////////////////////////////////////////////////////
@@ -37,10 +37,10 @@ enum value_error {
error_integer_overflow = 0x2,
error_character_overflow = 0x4
};
///////////////////////////////////////////////////////////////////////////////
} // namespace grammars
} // namespace wave
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code

View File

@@ -35,7 +35,10 @@ enum language_support {
support_c99 = support_option_variadics | support_option_long_long | 0x08,
#endif
#if BOOST_WAVE_SUPPORT_CPP0X != 0
support_cpp0x = support_option_variadics | support_option_long_long | 0x10,
support_option_no_newline_at_end_of_file = 0x20,
support_cpp0x = support_option_variadics | support_option_long_long |
support_option_no_newline_at_end_of_file | 0x10,
support_cpp11 = support_cpp0x,
#endif
@@ -181,24 +184,27 @@ set_support_options(language_support language, language_support option)
/**/
///////////////////////////////////////////////////////////////////////////////
BOOST_WAVE_OPTION(long_long) // support_option_long_long
BOOST_WAVE_OPTION(no_character_validation) // support_option_no_character_validation
BOOST_WAVE_OPTION(preserve_comments) // support_option_preserve_comments
BOOST_WAVE_OPTION(prefer_pp_numbers) // support_option_prefer_pp_numbers
BOOST_WAVE_OPTION(emit_line_directives) // support_option_emit_line_directives
BOOST_WAVE_OPTION(single_line) // support_option_single_line
BOOST_WAVE_OPTION(convert_trigraphs) // support_option_convert_trigraphs
BOOST_WAVE_OPTION(long_long) // support_option_long_long
BOOST_WAVE_OPTION(no_character_validation) // support_option_no_character_validation
BOOST_WAVE_OPTION(preserve_comments) // support_option_preserve_comments
BOOST_WAVE_OPTION(prefer_pp_numbers) // support_option_prefer_pp_numbers
BOOST_WAVE_OPTION(emit_line_directives) // support_option_emit_line_directives
BOOST_WAVE_OPTION(single_line) // support_option_single_line
BOOST_WAVE_OPTION(convert_trigraphs) // support_option_convert_trigraphs
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
BOOST_WAVE_OPTION(include_guard_detection) // support_option_include_guard_detection
BOOST_WAVE_OPTION(include_guard_detection) // support_option_include_guard_detection
#endif
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
BOOST_WAVE_OPTION(variadics) // support_option_variadics
BOOST_WAVE_OPTION(variadics) // support_option_variadics
#endif
#if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0
BOOST_WAVE_OPTION(emit_pragma_directives) // support_option_emit_pragma_directives
BOOST_WAVE_OPTION(emit_pragma_directives) // support_option_emit_pragma_directives
#endif
BOOST_WAVE_OPTION(insert_whitespace) // support_option_insert_whitespace
BOOST_WAVE_OPTION(emit_contnewlines) // support_option_emit_contnewlines
#if BOOST_WAVE_SUPPORT_CPP0X != 0
BOOST_WAVE_OPTION(no_newline_at_end_of_file) // support_no_newline_at_end_of_file
#endif
BOOST_WAVE_OPTION(insert_whitespace) // support_option_insert_whitespace
BOOST_WAVE_OPTION(emit_contnewlines) // support_option_emit_contnewlines
#undef BOOST_WAVE_NEED_OPTION
#undef BOOST_WAVE_ENABLE_OPTION

View File

@@ -1,6 +1,6 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
The definition of a default set of token identifiers and related
The definition of a default set of token identifiers and related
functions.
http://www.boost.org/
@@ -27,7 +27,7 @@
#if !defined(BOOST_WAVE_TOKEN_IDS_DEFINED)
#define BOOST_WAVE_TOKEN_IDS_DEFINED
#if (defined (__FreeBSD__) || defined (__DragonFly__) || defined (__OpenBSD__)) && defined (T_DIVIDE)
#if (defined (__FreeBSD__) || defined (__DragonFly__) || defined (__OpenBSD__)) && defined (T_DIVIDE)
#undef T_DIVIDE
#endif
@@ -42,37 +42,37 @@ namespace wave {
#define BASEID_FROM_TOKEN(tok) ((tok) & ~ExtTokenTypeMask)
///////////////////////////////////////////////////////////////////////////////
// the token_category helps to classify the different token types
// the token_category helps to classify the different token types
enum token_category {
IdentifierTokenType = 0x10080000,
ParameterTokenType = 0x11080000,
ExtParameterTokenType = 0x11180000,
KeywordTokenType = 0x20080000,
OperatorTokenType = 0x30080000,
LiteralTokenType = 0x40080000,
IntegerLiteralTokenType = 0x41080000,
FloatingLiteralTokenType = 0x42080000,
StringLiteralTokenType = 0x43080000,
CharacterLiteralTokenType = 0x44080000,
BoolLiteralTokenType = 0x45080000,
PPTokenType = 0x50080000,
PPConditionalTokenType = 0x50880000,
IdentifierTokenType = 0x08040000,
ParameterTokenType = 0x08840000,
ExtParameterTokenType = 0x088C0000,
KeywordTokenType = 0x10040000,
OperatorTokenType = 0x18040000,
LiteralTokenType = 0x20040000,
IntegerLiteralTokenType = 0x20840000,
FloatingLiteralTokenType = 0x21040000,
StringLiteralTokenType = 0x21840000,
CharacterLiteralTokenType = 0x22040000,
BoolLiteralTokenType = 0x22840000,
PPTokenType = 0x28040000,
PPConditionalTokenType = 0x28440000,
UnknownTokenType = 0xA0000000,
EOLTokenType = 0xB0000000,
EOFTokenType = 0xC0000000,
WhiteSpaceTokenType = 0xD0000000,
InternalTokenType = 0xE0080000,
UnknownTokenType = 0x50000000,
EOLTokenType = 0x58000000,
EOFTokenType = 0x60000000,
WhiteSpaceTokenType = 0x68000000,
InternalTokenType = 0x70040000,
TokenTypeMask = 0xFF000000,
AltTokenType = 0x00100000,
TriGraphTokenType = 0x00200000,
AltExtTokenType = 0x00500000, // and, bit_and etc.
PPTokenFlag = 0x00080000, // these are 'real' pp-tokens
ExtTokenTypeMask = 0xFFF00000,
ExtTokenOnlyMask = 0x00F00000,
TokenValueMask = 0x000FFFFF,
MainTokenMask = 0xFF0FFFFF // TokenTypeMask|TokenValueMask
TokenTypeMask = 0x7F800000,
AltTokenType = 0x00080000,
TriGraphTokenType = 0x00100000,
AltExtTokenType = 0x00280000, // and, bit_and etc.
PPTokenFlag = 0x00040000, // these are 'real' pp-tokens
ExtTokenTypeMask = 0x7FF80000,
ExtTokenOnlyMask = 0x00780000,
TokenValueMask = 0x0007FFFF,
MainTokenMask = 0x7F87FFFF // TokenTypeMask|TokenValueMask
};
///////////////////////////////////////////////////////////////////////////////
@@ -303,7 +303,9 @@ enum token_id {
T_LAST_TOKEN_ID,
T_LAST_TOKEN = ID_FROM_TOKEN(T_LAST_TOKEN_ID & ~PPTokenFlag),
// pseudo tokens to help streamlining macro replacement, these should not
T_UNKNOWN_UNIVERSALCHAR = TOKEN_FROM_ID('\\', UnknownTokenType),
// pseudo tokens to help streamlining macro replacement, these should not
// returned from the lexer nor should these be returned from the pp-iterator
T_NONREPLACABLE_IDENTIFIER = TOKEN_FROM_ID(T_LAST_TOKEN+1, IdentifierTokenType),
T_PLACEHOLDER = TOKEN_FROM_ID(T_LAST_TOKEN+2, WhiteSpaceTokenType),
@@ -355,12 +357,12 @@ inline bool is_pp_token(TokenT const& tok)
///////////////////////////////////////////////////////////////////////////////
// return a token name
BOOST_WAVE_DECL
BOOST_WAVE_DECL
BOOST_WAVE_STRINGTYPE get_token_name(token_id tokid);
///////////////////////////////////////////////////////////////////////////////
// return a token name
BOOST_WAVE_DECL
BOOST_WAVE_DECL
char const *get_token_value(token_id tokid);
///////////////////////////////////////////////////////////////////////////////

View File

@@ -30,23 +30,23 @@ class if_block
{
public:
if_block() :
status(true), some_part_status(true),
status(true), some_part_status(true),
enclosing_status(true), is_in_else(false)
{
}
if_block(bool status_, bool enclosing_status_) :
status(status_),
if_block(bool status_, bool enclosing_status_) :
status(status_),
some_part_status(status_),
enclosing_status(enclosing_status_),
is_in_else(false)
{
}
void set_status(bool status_)
{
status = status_;
if (status_)
some_part_status = true;
void set_status(bool status_)
{
status = status_;
if (status_)
some_part_status = true;
}
bool get_status() const { return status; }
bool get_some_part_status() const { return some_part_status; }
@@ -63,8 +63,8 @@ private:
///////////////////////////////////////////////////////////////////////////////
// stack of conditional compilation contexts
class if_block_stack
: private std::stack<if_block>
class if_block_stack
: private std::stack<if_block>
{
public:
typedef std::stack<if_block>::size_type size_type;
@@ -84,7 +84,7 @@ public:
if (get_status()) {
// entered a (false) #elif block from a true block
this->top().set_status(false);
}
}
else if (new_status && !this->top().get_some_part_status()) {
// Entered true #elif block and no previous block was true
this->top().set_status(new_status);
@@ -101,7 +101,7 @@ public:
if (!this->top().get_some_part_status()) {
// Entered (true) #else block and no previous block was true
this->top().set_status(true);
}
}
else if (get_status()) {
// Entered (false) #else block from true block
this->top().set_status(false);
@@ -123,12 +123,12 @@ public:
// return, whether the top (innermost) condition is true or false
bool get_status() const
{
return 0 == this->size() || this->top().get_status();
{
return 0 == this->size() || this->top().get_status();
}
bool get_some_part_status() const
{
return 0 == this->size() || this->top().get_some_part_status();
{
return 0 == this->size() || this->top().get_some_part_status();
}
bool get_enclosing_status() const
{

View File

@@ -15,6 +15,7 @@
#include <list>
#include <utility>
#include <boost/assert.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/util/filesystem_compatibility.hpp>
@@ -58,10 +59,9 @@ struct bidirectional_map
typedef std::pair<FromType, ToType> value_type;
#if defined(BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS) || \
(defined(BOOST_MSVC) && \
( (BOOST_MSVC < 1300) || (BOOST_MSVC == 1600) )) || \
(defined(BOOST_MSVC) && (BOOST_MSVC == 1600) ) || \
(defined(BOOST_INTEL_CXX_VERSION) && \
(defined(_MSC_VER) && (BOOST_INTEL_CXX_VERSION <= 700)))
(defined(_MSC_VER) && (BOOST_INTEL_CXX_VERSION <= 700)))
BOOST_STATIC_CONSTANT(unsigned, from_offset = offsetof(value_type, first));
BOOST_STATIC_CONSTANT(unsigned, to_offset = offsetof(value_type, second));
@@ -70,12 +70,12 @@ struct bidirectional_map
value_type,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<
boost::multi_index::tag<from>,
boost::multi_index::member_offset<value_type, FromType, from_offset>
boost::multi_index::tag<from>,
boost::multi_index::member_offset<value_type, FromType, from_offset>
>,
boost::multi_index::ordered_non_unique<
boost::multi_index::tag<to>,
boost::multi_index::member_offset<value_type, ToType, to_offset>
boost::multi_index::tag<to>,
boost::multi_index::member_offset<value_type, ToType, to_offset>
>
>
> type;
@@ -87,11 +87,11 @@ struct bidirectional_map
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<
boost::multi_index::tag<from>,
boost::multi_index::member<value_type, FromType, &value_type::first>
boost::multi_index::member<value_type, FromType, &value_type::first>
>,
boost::multi_index::ordered_non_unique<
boost::multi_index::tag<to>,
boost::multi_index::member<value_type, ToType, &value_type::second>
boost::multi_index::tag<to>,
boost::multi_index::member<value_type, ToType, &value_type::second>
>
>
> type;
@@ -115,35 +115,35 @@ struct load_filepos
//
// General notes:
//
// Any directories specified with the 'add_include_path()' function before
// the function 'set_sys_include_delimiter()' is called are searched only
// for the case of '#include "file"' directives, they are not searched for
// '#include <file>' directives. If additional directories are specified
// with the 'add_include_path()' function after a call to the function
// 'set_sys_include_delimiter()', these directories are searched for all
// '#include' directives.
// Any directories specified with the 'add_include_path()' function before
// the function 'set_sys_include_delimiter()' is called are searched only
// for the case of '#include "file"' directives, they are not searched for
// '#include <file>' directives. If additional directories are specified
// with the 'add_include_path()' function after a call to the function
// 'set_sys_include_delimiter()', these directories are searched for all
// '#include' directives.
//
// In addition, a call to the function 'set_sys_include_delimiter()'
// inhibits the use of the current directory as the first search directory
// for '#include "file"' directives. Therefore, the current directory is
// In addition, a call to the function 'set_sys_include_delimiter()'
// inhibits the use of the current directory as the first search directory
// for '#include "file"' directives. Therefore, the current directory is
// searched only if it is requested explicitly with a call to the function
// 'add_include_path(".")'.
// 'add_include_path(".")'.
//
// Calling both functions, the 'set_sys_include_delimiter()' and
// 'add_include_path(".")' allows you to control precisely which
// directories are searched before the current one and which are searched
// Calling both functions, the 'set_sys_include_delimiter()' and
// 'add_include_path(".")' allows you to control precisely which
// directories are searched before the current one and which are searched
// after.
//
///////////////////////////////////////////////////////////////////////////////
class include_paths
{
private:
typedef std::list<std::pair<boost::filesystem::path, std::string> >
typedef std::list<std::pair<boost::filesystem::path, std::string> >
include_list_type;
typedef include_list_type::value_type include_value_type;
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
typedef bidirectional_map<std::string, std::string>::type
typedef bidirectional_map<std::string, std::string>::type
pragma_once_set_type;
#endif
@@ -153,21 +153,21 @@ public:
current_dir(initial_path()),
current_rel_dir(initial_path())
{}
bool add_include_path(char const *path_, bool is_system = false)
{
return add_include_path(path_, (is_system || was_sys_include_path) ?
return add_include_path(path_, (is_system || was_sys_include_path) ?
system_include_paths : user_include_paths);
}
void set_sys_include_delimiter() { was_sys_include_path = true; }
bool find_include_file (std::string &s, std::string &dir, bool is_system,
bool find_include_file (std::string &s, std::string &dir, bool is_system,
char const *current_file) const;
void set_current_directory(char const *path_);
boost::filesystem::path get_current_directory() const
boost::filesystem::path get_current_directory() const
{ return current_dir; }
protected:
bool find_include_file (std::string &s, std::string &dir,
bool find_include_file (std::string &s, std::string &dir,
include_list_type const &pathes, char const *) const;
bool add_include_path(char const *path_, include_list_type &pathes_);
@@ -185,7 +185,7 @@ public:
using boost::multi_index::get;
return get<from>(pragma_once_files).find(filename) != pragma_once_files.end();
}
bool add_pragma_once_header(std::string const &filename,
bool add_pragma_once_header(std::string const &filename,
std::string const& guard_name)
{
typedef pragma_once_set_type::value_type value_type;
@@ -195,7 +195,7 @@ public:
{
typedef pragma_once_set_type::index_iterator<to>::type to_iterator;
typedef std::pair<to_iterator, to_iterator> range_type;
range_type r = pragma_once_files.get<to>().equal_range(guard_name);
if (r.first != r.second) {
using boost::multi_index::get;
@@ -232,7 +232,7 @@ private:
{
using namespace boost::serialization;
if (version != (loaded_version & ~version_mask)) {
BOOST_WAVE_THROW(preprocess_exception, incompatible_config,
BOOST_WAVE_THROW(preprocess_exception, incompatible_config,
"cpp_include_path state version", load_filepos());
return;
}
@@ -247,13 +247,13 @@ private:
if (user_paths != user_include_paths)
{
BOOST_WAVE_THROW(preprocess_exception, incompatible_config,
BOOST_WAVE_THROW(preprocess_exception, incompatible_config,
"user include paths", load_filepos());
return;
}
if (system_paths != system_include_paths)
{
BOOST_WAVE_THROW(preprocess_exception, incompatible_config,
BOOST_WAVE_THROW(preprocess_exception, incompatible_config,
"system include paths", load_filepos());
return;
}
@@ -265,7 +265,7 @@ private:
};
///////////////////////////////////////////////////////////////////////////////
// Add an include path to one of the search lists (user include path or system
// Add an include path to one of the search lists (user include path or system
// include path).
inline
bool include_paths::add_include_path (
@@ -290,7 +290,7 @@ bool include_paths::add_include_path (
///////////////////////////////////////////////////////////////////////////////
// Find an include file by traversing the list of include directories
inline
bool include_paths::find_include_file (std::string &s, std::string &dir,
bool include_paths::find_include_file (std::string &s, std::string &dir,
include_list_type const &pathes, char const *current_file) const
{
namespace fs = boost::filesystem;
@@ -299,7 +299,7 @@ bool include_paths::find_include_file (std::string &s, std::string &dir,
const_include_list_iter_t it = pathes.begin();
const_include_list_iter_t include_paths_end = pathes.end();
#if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
#if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
if (0 != current_file) {
// re-locate the directory of the current file (#include_next handling)
@@ -312,7 +312,7 @@ bool include_paths::find_include_file (std::string &s, std::string &dir,
fs::path file_path (create_path(current_file));
for (/**/; it != include_paths_end; ++it) {
fs::path currpath (create_path((*it).first.string()));
if (std::equal(currpath.begin(), currpath.end(), file_path.begin()))
if (std::equal(currpath.begin(), currpath.end(), file_path.begin()))
{
++it; // start searching with the next directory
break;
@@ -327,7 +327,7 @@ bool include_paths::find_include_file (std::string &s, std::string &dir,
currpath = create_path((*it).first.string());
currpath /= create_path(s); // append filename
}
if (fs::exists(currpath)) {
fs::path dirpath (create_path(s));
if (!dirpath.has_root_directory()) {
@@ -344,10 +344,10 @@ bool include_paths::find_include_file (std::string &s, std::string &dir,
}
///////////////////////////////////////////////////////////////////////////////
// Find an include file by searching the user and system includes in the
// Find an include file by searching the user and system includes in the
// correct sequence (as it was configured by the user of the driver program)
inline bool
include_paths::find_include_file (std::string &s, std::string &dir,
inline bool
include_paths::find_include_file (std::string &s, std::string &dir,
bool is_system, char const *current_file) const
{
namespace fs = boost::filesystem;
@@ -361,7 +361,7 @@ include_paths::find_include_file (std::string &s, std::string &dir,
currpath = create_path(current_dir.string());
currpath /= create_path(s);
}
if (fs::exists(currpath) && 0 == current_file) {
// if 0 != current_path (#include_next handling) it can't be
// the file in the current directory
@@ -374,7 +374,7 @@ include_paths::find_include_file (std::string &s, std::string &dir,
dir = dirpath.string();
s = normalize(currpath).string(); // found in local directory
return true;
}
}
// iterate all user include file directories to find the file
if (find_include_file(s, dir, user_include_paths, current_file))
@@ -387,7 +387,7 @@ include_paths::find_include_file (std::string &s, std::string &dir,
// are searched in the user search path only
return find_include_file(s, dir, user_include_paths, current_file);
}
// if nothing found, fall through
// ...
}
@@ -400,26 +400,26 @@ include_paths::find_include_file (std::string &s, std::string &dir,
// Set current directory from a given file name
inline bool
as_relative_to(boost::filesystem::path const& path,
boost::filesystem::path const& base, boost::filesystem::path& result)
as_relative_to(boost::filesystem::path const& path,
boost::filesystem::path const& base, boost::filesystem::path& result)
{
if (path.has_root_path()) {
if (path.root_path() == base.root_path())
if (path.root_path() == base.root_path())
return as_relative_to(path.relative_path(), base.relative_path(), result);
result = path; // that's our result
}
}
else {
if (base.has_root_path()) {
// cannot find relative path from a relative path and a rooted base
return false;
}
}
else {
typedef boost::filesystem::path::const_iterator path_iterator;
path_iterator path_it = path.begin();
path_iterator base_it = base.begin();
while (path_it != path.end() && base_it != base.end() ) {
if (*path_it != *base_it)
if (*path_it != *base_it)
break;
++path_it; ++base_it;
}
@@ -439,21 +439,16 @@ inline
void include_paths::set_current_directory(char const *path_)
{
namespace fs = boost::filesystem;
fs::path filepath (create_path(path_));
fs::path filename = util::complete_path(filepath, current_dir);
if (fs::exists(filename) && fs::is_directory(filename)) {
current_rel_dir.clear();
if (!as_relative_to(filepath, current_dir, current_rel_dir))
current_rel_dir = filepath;
current_dir = filename;
}
else {
current_rel_dir.clear();
if (!as_relative_to(branch_path(filepath), current_dir, current_rel_dir))
current_rel_dir = branch_path(filepath);
current_dir = branch_path(filename);
}
BOOST_ASSERT(!(fs::exists(filename) && fs::is_directory(filename)));
current_rel_dir.clear();
if (!as_relative_to(branch_path(filepath), current_dir, current_rel_dir))
current_rel_dir = branch_path(filepath);
current_dir = branch_path(filename);
}
///////////////////////////////////////////////////////////////////////////////
@@ -466,7 +461,7 @@ namespace boost { namespace serialization {
///////////////////////////////////////////////////////////////////////////////
// Serialization support for boost::filesystem::path
template<class Archive>
inline void save (Archive & ar, boost::filesystem::path const& p,
inline void save (Archive & ar, boost::filesystem::path const& p,
const unsigned int /* file_version */)
{
using namespace boost::serialization;
@@ -503,7 +498,7 @@ inline void save (Archive & ar,
const unsigned int /* file_version */)
{
boost::serialization::stl::save_collection<
Archive,
Archive,
typename boost::wave::util::bidirectional_map<
std::string, std::string
>::type
@@ -528,7 +523,7 @@ inline void load (Archive & ar,
// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<class Archive>
inline void serialize (Archive & ar,
inline void serialize (Archive & ar,
typename boost::wave::util::bidirectional_map<
std::string, std::string
>::type &t,
@@ -540,7 +535,7 @@ inline void serialize (Archive & ar,
///////////////////////////////////////////////////////////////////////////////
}} // namespace boost::serialization
BOOST_CLASS_VERSION(boost::wave::util::include_paths,
BOOST_CLASS_VERSION(boost::wave::util::include_paths,
boost::wave::util::include_paths::version);
#endif // BOOST_WAVE_SERIALIZATION != 0

View File

@@ -23,6 +23,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/spirit/include/classic_multi_pass.hpp>
#include <boost/spirit/include/classic_parse_tree_utils.hpp>
@@ -546,7 +547,7 @@ pp_iterator_functor<ContextT>::operator()()
// cleanup of certain tokens required
seen_newline = false;
switch (static_cast<unsigned int>(id)) {
switch (id) {
case T_NONREPLACABLE_IDENTIFIER:
act_token.set_token_id(id = T_IDENTIFIER);
break;
@@ -607,7 +608,7 @@ pp_iterator_functor<ContextT>::operator()()
break;
}
if (whitespace.must_insert(id, act_token.get_value())) {
if (token_is_valid(act_token) && whitespace.must_insert(id, act_token.get_value())) {
// must insert some whitespace into the output stream to avoid adjacent
// tokens, which would form different (and wrong) tokens
whitespace.shift_tokens(T_SPACE);
@@ -668,9 +669,19 @@ bool returned_from_include_file = returned_from_include();
if ((!seen_newline || act_pos.get_column() > 1) &&
!need_single_line(ctx.get_language()))
{
// warn, if this file does not end with a newline
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
last_line_not_terminated, "", act_pos);
if (need_no_newline_at_end_of_file(ctx.get_language()))
{
seen_newline = true;
pending_queue.push_back(
result_type(T_NEWLINE, "\n", act_pos)
);
}
else
{
// warn, if this file does not end with a newline
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
last_line_not_terminated, "", act_pos);
}
}
continue; // if this is the main file, the while loop breaks
}
@@ -695,6 +706,11 @@ bool returned_from_include_file = returned_from_include();
// pending_queue.push_back(result_type(T_NEWLINE, "\n", act_pos));
// seen_newline = true;
// must_emit_line_directive = true;
if (iter_ctx->first == iter_ctx->last)
{
seen_newline = true;
act_token = result_type(T_NEWLINE, "\n", act_pos);
}
// loop to the next token to analyze
// simply fall through, since the iterator was already adjusted
@@ -780,7 +796,7 @@ typename ContextT::position_type pos = act_token.get_position();
if (!ctx.get_hooks().emit_line_directive(ctx, pending, act_token))
{
unsigned int column = 6;
unsigned int column = 6;
// the hook did not generate anything, emit default #line
pos.set_column(1);
@@ -789,22 +805,20 @@ typename ContextT::position_type pos = act_token.get_position();
pos.set_column(column); // account for '#line'
pending.push_back(result_type(T_SPACE, " ", pos));
// 21 is the max required size for a 64 bit integer represented as a
// string
char buffer[22];
// 21 is the max required size for a 64 bit integer represented as a
// string
using namespace std; // for some systems sprintf is in namespace std
sprintf (buffer, "%ld", pos.get_line());
std::string buffer = lexical_cast<std::string>(pos.get_line());
pos.set_column(++column); // account for ' '
pending.push_back(result_type(T_INTLIT, buffer, pos));
pos.set_column(column += (unsigned int)strlen(buffer)); // account for <number>
pending.push_back(result_type(T_INTLIT, buffer.c_str(), pos));
pos.set_column(column += (unsigned int)buffer.size()); // account for <number>
pending.push_back(result_type(T_SPACE, " ", pos));
pos.set_column(++column); // account for ' '
std::string file("\"");
boost::filesystem::path filename(
wave::util::create_path(act_pos.get_file().c_str()));
std::string file("\"");
boost::filesystem::path filename(
wave::util::create_path(act_pos.get_file().c_str()));
using wave::util::impl::escape_lit;
file += escape_lit(wave::util::native_file_string(filename)) + "\"";
@@ -962,7 +976,7 @@ namespace impl {
if (call_hook)
util::impl::call_skipped_token_hook(ctx, *it);
}
return false;
return need_no_newline_at_end_of_file(ctx.get_language());
}
///////////////////////////////////////////////////////////////////////////
@@ -1060,10 +1074,13 @@ pp_iterator_functor<ContextT>::ensure_is_last_on_line(IteratorT& it, bool call_h
seen_newline = true; // allow to resume after warning
iter_ctx->first = it;
// Trigger a warning that the last line was not terminated with a
// newline.
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
last_line_not_terminated, "", act_pos);
if (!need_no_newline_at_end_of_file(ctx.get_language()))
{
// Trigger a warning that the last line was not terminated with a
// newline.
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
last_line_not_terminated, "", act_pos);
}
return false;
}
@@ -1083,10 +1100,13 @@ pp_iterator_functor<ContextT>::skip_to_eol_with_check(IteratorT &it, bool call_h
seen_newline = true; // allow to resume after warning
iter_ctx->first = it;
// Trigger a warning, that the last line was not terminated with a
// newline.
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
last_line_not_terminated, "", act_pos);
if (!need_no_newline_at_end_of_file(ctx.get_language()))
{
// Trigger a warning, that the last line was not terminated with a
// newline.
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
last_line_not_terminated, "", act_pos);
}
return false;
}
@@ -1109,7 +1129,7 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it)
if (!ctx.get_if_block_status()) {
if (IS_EXTCATEGORY(*it, PPConditionalTokenType)) {
// simulate the if block hierarchy
switch (static_cast<unsigned int>(id)) {
switch (id) {
case T_PP_IFDEF: // #ifdef
case T_PP_IFNDEF: // #ifndef
case T_PP_IF: // #if
@@ -1163,7 +1183,7 @@ pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it)
// try to handle the simple pp directives without parsing
result_type directive = *it;
bool include_next = false;
switch (static_cast<unsigned int>(id)) {
switch (id) {
case T_PP_QHEADER: // #include "..."
#if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
case T_PP_QHEADER_NEXT:
@@ -1368,7 +1388,9 @@ tree_parse_info_type hit = cpp_grammar_type::parse_cpp_grammar(
// the found pp directive
bool result = dispatch_directive (hit, found_directive, found_eoltokens);
if (found_eof && !need_single_line(ctx.get_language())) {
if (found_eof && !need_single_line(ctx.get_language()) &&
!need_no_newline_at_end_of_file(ctx.get_language()))
{
// The line was terminated with an end of file token.
// So trigger a warning, that the last line was not terminated with a
// newline.
@@ -1424,7 +1446,7 @@ token_id id = token_id(found_directive);
if (impl::call_found_directive_hook(ctx, found_directive))
return true; // skip this directive and return newline only
switch (static_cast<unsigned int>(id)) {
switch (id) {
// case T_PP_QHEADER: // #include "..."
// #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
// case T_PP_QHEADER_NEXT: // #include_next "..."
@@ -2316,7 +2338,10 @@ token_sequence_type toexpand;
act_pos.set_file(unescape_lit(file_name).c_str());
}
act_pos.set_line(line);
iter_ctx->first.set_position(act_pos);
if (iter_ctx->first != iter_ctx->last)
{
iter_ctx->first.set_position(act_pos);
}
}
///////////////////////////////////////////////////////////////////////////////

View File

@@ -32,6 +32,7 @@
#endif
#include <boost/filesystem/path.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/wave/util/time_conversion_helper.hpp>
#include <boost/wave/util/unput_queue_iterator.hpp>
@@ -582,7 +583,6 @@ macromap<ContextT>::expand_tokensequence_worker(
// analyze the next element of the given sequence, if it is an
// T_IDENTIFIER token, try to replace this as a macro etc.
using namespace boost::wave;
typedef unput_queue_iterator<IteratorT, token_type, ContainerT> iterator_type;
if (first != last) {
token_id id = token_id(*first);
@@ -742,7 +742,7 @@ token_type startof_argument_list = *next;
return 0;
}
switch (static_cast<unsigned int>(id)) {
switch (id) {
case T_LEFTPAREN:
++nested_parenthesis_level;
argument->push_back(*next);
@@ -1411,11 +1411,9 @@ string_type const &value = curr_token.get_value();
if (value == "__LINE__") {
// expand the __LINE__ macro
char buffer[22]; // 21 bytes holds all NUL-terminated unsigned 64-bit numbers
std::string buffer = lexical_cast<std::string>(main_pos.get_line());
using namespace std; // for some systems sprintf is in namespace std
sprintf(buffer, "%ld", main_pos.get_line());
expanded.push_back(token_type(T_INTLIT, buffer, curr_token.get_position()));
expanded.push_back(token_type(T_INTLIT, buffer.c_str(), curr_token.get_position()));
return true;
}
else if (value == "__FILE__") {

View File

@@ -2,7 +2,7 @@
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the predefined macros
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -19,7 +19,7 @@
#include <boost/wave/wave_config.hpp>
#include <boost/wave/wave_config_constant.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/util/time_conversion_helper.hpp> // time_conversion_helper
#include <boost/wave/util/time_conversion_helper.hpp> // time_conversion_helper
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
@@ -42,10 +42,10 @@ namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////
class predefined_macros
class predefined_macros
{
typedef BOOST_WAVE_STRINGTYPE string_type;
public:
// list of static predefined macros
struct static_macros {
@@ -107,7 +107,7 @@ namespace util {
char buffer[sizeof("\"12:34:56\"")+1];
tb = localtime (&tt);
sprintf (buffer, "\"%02d:%02d:%02d\"", tb->tm_hour,
sprintf (buffer, "\"%02d:%02d:%02d\"", tb->tm_hour,
tb->tm_min, tb->tm_sec);
timestr_ = buffer;
}
@@ -123,7 +123,7 @@ namespace util {
// for some systems sprintf, time_t etc. is in namespace std
using namespace std;
// calculate the number of days since Dec 13 2001
// calculate the number of days since Dec 13 2001
// (the day the Wave project was started)
tm first_day;
@@ -136,7 +136,7 @@ namespace util {
long seconds = long(difftime(compilation_time_.get_time(), mktime(&first_day)));
sprintf(buffer, "0x%02d%1d%1d%04ld", BOOST_WAVE_VERSION_MAJOR,
BOOST_WAVE_VERSION_MINOR, BOOST_WAVE_VERSION_SUBMINOR,
BOOST_WAVE_VERSION_MINOR, BOOST_WAVE_VERSION_SUBMINOR,
seconds/(3600*24));
version_ = buffer;
}
@@ -148,7 +148,7 @@ namespace util {
// for some systems sprintf, time_t etc. is in namespace std
using namespace std;
// calculate the number of days since Dec 13 2001
// calculate the number of days since Dec 13 2001
// (the day the Wave project was started)
tm first_day;
@@ -160,13 +160,13 @@ namespace util {
long seconds = long(difftime(compilation_time_.get_time(), mktime(&first_day)));
sprintf(buffer, "\"%d.%d.%d.%ld [%s/%s]\"", BOOST_WAVE_VERSION_MAJOR,
BOOST_WAVE_VERSION_MINOR, BOOST_WAVE_VERSION_SUBMINOR,
BOOST_WAVE_VERSION_MINOR, BOOST_WAVE_VERSION_SUBMINOR,
seconds/(3600*24), BOOST_PLATFORM, BOOST_COMPILER);
versionstr_ = buffer;
}
// dynamic predefined macros
string_type get_date() const { return datestr_; } // __DATE__
string_type get_date() const { return datestr_; } // __DATE__
string_type get_time() const { return timestr_; } // __TIME__
// __SPIRIT_PP__/__WAVE__
@@ -175,7 +175,7 @@ namespace util {
char buffer[sizeof("0x0000")+1];
using namespace std; // for some systems sprintf is in namespace std
sprintf(buffer, "0x%02d%1d%1d", BOOST_WAVE_VERSION_MAJOR,
sprintf(buffer, "0x%02d%1d%1d", BOOST_WAVE_VERSION_MAJOR,
BOOST_WAVE_VERSION_MINOR, BOOST_WAVE_VERSION_SUBMINOR);
return buffer;
}
@@ -191,10 +191,10 @@ namespace util {
}
public:
predefined_macros()
predefined_macros()
: compilation_time_(__DATE__ " " __TIME__)
{
reset();
{
reset();
reset_version();
reset_versionstr();
}
@@ -211,20 +211,20 @@ namespace util {
// __SPIRIT_PP_VERSION_STR__/__WAVE_VERSION_STR__
string_type get_versionstr() const { return versionstr_; }
// C++ mode
// C++ mode
static_macros const& static_data_cpp(std::size_t i) const
{
static static_macros data[] = {
{ "__STDC__", T_INTLIT, "1" },
{ "__cplusplus", T_INTLIT, "199711L" },
{ 0, T_EOF, 0 }
};
};
BOOST_ASSERT(i < sizeof(data)/sizeof(data[0]));
return data[i];
}
#if BOOST_WAVE_SUPPORT_CPP0X != 0
// C++11 mode
// C++11 mode
static_macros const& static_data_cpp0x(std::size_t i) const
{
static static_macros data[] = {
@@ -234,7 +234,7 @@ namespace util {
{ "__STDC_HOSTED__", T_INTLIT, "0" },
{ "__WAVE_HAS_VARIADICS__", T_INTLIT, "1" },
{ 0, T_EOF, 0 }
};
};
BOOST_ASSERT(i < sizeof(data)/sizeof(data[0]));
return data[i];
}
@@ -250,11 +250,11 @@ namespace util {
{ "__STDC_HOSTED__", T_INTLIT, "0" },
{ "__WAVE_HAS_VARIADICS__", T_INTLIT, "1" },
{ 0, T_EOF, 0 }
};
};
BOOST_ASSERT(i < sizeof(data)/sizeof(data[0]));
return data[i];
}
#endif
#endif
dynamic_macros const& dynamic_data(std::size_t i) const
{

View File

@@ -17,7 +17,7 @@
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/util/unput_queue_iterator.hpp>
#include <boost/wave/util/unput_queue_iterator.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
@@ -26,7 +26,7 @@
///////////////////////////////////////////////////////////////////////////////
//
// This file contains the definition of several token sequence analyze
// This file contains the definition of several token sequence analyze
// and transformation utility functions needed during macro handling.
//
///////////////////////////////////////////////////////////////////////////////
@@ -41,7 +41,7 @@ namespace on_exit {
///////////////////////////////////////////////////////////////////////////
//
// On destruction pop the first element of the list given as the argument
// On destruction pop the first element of the list given as the argument
//
///////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
@@ -56,15 +56,15 @@ namespace on_exit {
///////////////////////////////////////////////////////////////////////////
//
// Append a given list to the list given as argument
// On destruction pop the first element of the list given as argument
// Append a given list to the list given as argument
// On destruction pop the first element of the list given as argument
//
///////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
class splice_pop_front {
public:
splice_pop_front(ContainerT &list_, ContainerT &queue)
: list(list_)
splice_pop_front(ContainerT &list_, ContainerT &queue)
: list(list_)
{
list.splice(list.end(), queue);
}
@@ -103,7 +103,7 @@ namespace on_exit {
class assign
{
public:
assign(IteratorT &it_, UnputIteratorT const &uit_)
assign(IteratorT &it_, UnputIteratorT const &uit_)
: it(it_), uit(uit_) {}
~assign() { it = uit.base(); }
@@ -115,7 +115,7 @@ namespace on_exit {
template <typename IteratorT>
class assign<IteratorT, IteratorT> {
public:
assign(IteratorT &it_, IteratorT const &uit_)
assign(IteratorT &it_, IteratorT const &uit_)
: it(it_), uit(uit_) {}
~assign() { it = uit; }
@@ -136,7 +136,7 @@ namespace impl {
//
///////////////////////////////////////////////////////////////////////////////
template <typename StringT>
inline bool
inline bool
is_special_macroname (StringT const &name)
{
if (name.size() < 7)
@@ -148,7 +148,7 @@ is_special_macroname (StringT const &name)
if ('_' == name[0] && '_' == name[1]) {
StringT str = name.substr(2);
if (str == "cplusplus" || str == "STDC__" ||
if (str == "cplusplus" || str == "STDC__" ||
str == "TIME__" || str == "DATE__" ||
str == "LINE__" || str == "FILE__" ||
str == "INCLUDE_LEVEL__")
@@ -166,20 +166,20 @@ is_special_macroname (StringT const &name)
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
inline bool
inline bool
token_equals(TokenT const &left, TokenT const &right)
{
using namespace boost::wave;
if (IS_CATEGORY(left, ParameterTokenType)) {
// if the existing token is of type T_PARAMETERBASE, then the right token
// if the existing token is of type T_PARAMETERBASE, then the right token
// must be of type T_IDENTIFIER or a keyword
token_id id = token_id(right);
return (T_IDENTIFIER == id ||
return (T_IDENTIFIER == id ||
IS_CATEGORY(id, KeywordTokenType) ||
IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) ||
IS_CATEGORY(id, BoolLiteralTokenType)) &&
IS_CATEGORY(id, BoolLiteralTokenType)) &&
left.get_value() == right.get_value();
}
@@ -196,8 +196,8 @@ token_equals(TokenT const &left, TokenT const &right)
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
inline bool
definition_equals(ContainerT const &definition,
inline bool
definition_equals(ContainerT const &definition,
ContainerT const &new_definition)
{
typedef typename ContainerT::const_iterator const_iterator_type;
@@ -207,22 +207,22 @@ const_iterator_type last1 = definition.end();
const_iterator_type first2 = new_definition.begin();
const_iterator_type last2 = new_definition.end();
while (first1 != last1 && first2 != last2 && token_equals(*first1, *first2))
while (first1 != last1 && first2 != last2 && token_equals(*first1, *first2))
{
// skip whitespace, if both sequences have a whitespace next
token_id id1 = next_token<const_iterator_type>::peek(first1, last1, false);
token_id id2 = next_token<const_iterator_type>::peek(first2, last2, false);
if (IS_CATEGORY(id1, WhiteSpaceTokenType) &&
IS_CATEGORY(id2, WhiteSpaceTokenType))
if (IS_CATEGORY(id1, WhiteSpaceTokenType) &&
IS_CATEGORY(id2, WhiteSpaceTokenType))
{
// all consecutive whitespace tokens count as one whitespace
// adjust first1 and first2 accordingly
skip_whitespace(first1, last1);
skip_whitespace(first2, last2);
}
else if (!IS_CATEGORY(id1, WhiteSpaceTokenType) &&
!IS_CATEGORY(id2, WhiteSpaceTokenType))
else if (!IS_CATEGORY(id1, WhiteSpaceTokenType) &&
!IS_CATEGORY(id2, WhiteSpaceTokenType))
{
++first1;
++first2;
@@ -241,7 +241,7 @@ const_iterator_type last2 = new_definition.end();
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
inline bool
inline bool
parameters_equal(ContainerT const &parameters, ContainerT const &new_parameters)
{
if (parameters.size() != new_parameters.size())
@@ -284,7 +284,7 @@ trim_replacement_list (ContainerT &replacement_list)
typename ContainerT::iterator end = replacement_list.end();
typename ContainerT::iterator it = replacement_list.begin();
while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
token_id id(*it);
if (T_PLACEHOLDER != id && T_PLACEMARKER != id) {
typename ContainerT::iterator next = it;
@@ -303,13 +303,13 @@ trim_replacement_list (ContainerT &replacement_list)
typename ContainerT::reverse_iterator rend = replacement_list.rend();
typename ContainerT::reverse_iterator rit = replacement_list.rbegin();
while (rit != rend && IS_CATEGORY(*rit, WhiteSpaceTokenType))
while (rit != rend && IS_CATEGORY(*rit, WhiteSpaceTokenType))
++rit;
typename ContainerT::iterator end = replacement_list.end();
typename ContainerT::iterator it = rit.base();
while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
token_id id(*it);
if (T_PLACEHOLDER != id && T_PLACEMARKER != id) {
typename ContainerT::iterator next = it;
@@ -372,7 +372,7 @@ remove_placeholders (ContainerT &replacement_list)
}
}
// remove all 'new' leading and trailing whitespace
// remove all 'new' leading and trailing whitespace
if (is_whitespace_only(replacement_list))
trim_replacement_list(replacement_list);
}
@@ -396,7 +396,7 @@ trim_sequence_left (ContainerT &argument)
argument.pop_front();
}
}
///////////////////////////////////////////////////////////////////////////////
//
// Remove all whitespace tokens on the right side of the given token sequence
@@ -418,7 +418,7 @@ trim_sequence_right (ContainerT &argument)
///////////////////////////////////////////////////////////////////////////////
//
// Remove all whitespace tokens on the left and right sides of the given token
// Remove all whitespace tokens on the left and right sides of the given token
// sequence
//
///////////////////////////////////////////////////////////////////////////////
@@ -433,11 +433,11 @@ trim_sequence (ContainerT &argument)
///////////////////////////////////////////////////////////////////////////////
// call 'skipped_token' preprocessing hook
template <typename ContextT>
void call_skipped_token_hook(ContextT& ctx,
void call_skipped_token_hook(ContextT& ctx,
typename ContextT::token_type const& skipped)
{
#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
ctx.get_hooks().skipped_token(skipped);
ctx.get_hooks().skipped_token(skipped);
#else
ctx.get_hooks().skipped_token(ctx.derived(), skipped);
#endif
@@ -449,20 +449,20 @@ void call_skipped_token_hook(ContextT& ctx,
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContextT, typename IteratorT>
inline bool
skip_to_token(ContextT& ctx, IteratorT &it, IteratorT const &end,
inline bool
skip_to_token(ContextT& ctx, IteratorT &it, IteratorT const &end,
token_id id, bool& seen_newline)
{
using namespace boost::wave;
if (token_id(*it) == id)
if (token_id(*it) == id)
return true;
// call_skipped_token_hook(ctx, *it);
if (++it == end)
if (++it == end)
return false;
while (IS_CATEGORY(*it, WhiteSpaceTokenType) ||
T_NEWLINE == token_id(*it))
while (IS_CATEGORY(*it, WhiteSpaceTokenType) ||
T_NEWLINE == token_id(*it))
{
if (T_NEWLINE == token_id(*it))
seen_newline = true;
@@ -476,7 +476,7 @@ skip_to_token(ContextT& ctx, IteratorT &it, IteratorT const &end,
///////////////////////////////////////////////////////////////////////////////
//
// Get the full name of a given macro name (concatenate the string
// Get the full name of a given macro name (concatenate the string
// representations of the single tokens).
//
///////////////////////////////////////////////////////////////////////////////
@@ -485,7 +485,7 @@ inline std::string
get_full_name(IteratorT const &begin, IteratorT const &end)
{
std::string full_name;
for (IteratorT err_it = begin; err_it != end; ++err_it)
for (IteratorT err_it = begin; err_it != end; ++err_it)
full_name += (*err_it).get_value().c_str();
return full_name;
@@ -516,7 +516,7 @@ private:
};
///////////////////////////////////////////////////////////////////////////////
// Convert a string of an arbitrary string compatible type to a internal
// Convert a string of an arbitrary string compatible type to a internal
// string (BOOST_WAVE_STRING)
template <typename Target, typename Src>
struct to_string_helper

View File

@@ -2,7 +2,7 @@
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the position_iterator and file_position templates
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -52,7 +52,7 @@ public:
file_position()
: file(), line(1), column(1)
{}
explicit file_position(string_type const& file_, std::size_t line_ = 1,
explicit file_position(string_type const& file_, std::size_t line_ = 1,
std::size_t column_ = 1)
: file(file_), line(line_), column(column_)
{}
@@ -62,9 +62,9 @@ public:
std::size_t get_line() const { return line; }
std::size_t get_column() const { return column; }
void set_file(string_type const &file_)
{
file = file_;
void set_file(string_type const &file_)
{
file = file_;
}
void set_line(std::size_t line_) { line = line_; }
void set_column(std::size_t column_) { column = column_; }
@@ -88,10 +88,10 @@ private:
};
template <typename StringT>
bool operator== (file_position<StringT> const &lhs,
bool operator== (file_position<StringT> const &lhs,
file_position<StringT> const &rhs)
{
return lhs.get_column() == rhs.get_column() &&
return lhs.get_column() == rhs.get_column() &&
lhs.get_line() == rhs.get_line() && lhs.get_file() == rhs.get_file();
}
@@ -109,15 +109,15 @@ typedef file_position<BOOST_WAVE_STRINGTYPE> file_position_type;
//
// position_iterator
//
// The position_iterator used by Wave is now based on the corresponding Spirit
// The position_iterator used by Wave is now based on the corresponding Spirit
// type. This type is used with our own file_position though. The needed
// specialization of the boost::spirit::classic::position_policy class is
// specialization of the boost::spirit::classic::position_policy class is
// provided below.
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename PositionT>
struct position_iterator
struct position_iterator
: boost::spirit::classic::position_iterator<IteratorT, PositionT>
{
typedef boost::spirit::classic::position_iterator<IteratorT, PositionT> base_type;
@@ -143,7 +143,7 @@ namespace spirit { namespace classic {
///////////////////////////////////////////////////////////////////////////////
//
// The boost::spirit::classic::position_policy has to be specialized for our
// The boost::spirit::classic::position_policy has to be specialized for our
// file_position class
//
///////////////////////////////////////////////////////////////////////////////
@@ -172,9 +172,9 @@ namespace spirit { namespace classic {
pos.set_column(pos.get_column() + 1);
}
void tabulation(boost::wave::util::file_position_type &pos)
void tabulation(boost::wave::util::file_position_type &pos)
{
pos.set_column(pos.get_column() + m_CharsPerTab -
pos.set_column(pos.get_column() + m_CharsPerTab -
(pos.get_column() - 1) % m_CharsPerTab);
}
@@ -185,7 +185,7 @@ namespace spirit { namespace classic {
///////////////////////////////////////////////////////////////////////////////
}} // namespace spirit::classic
} // namespace boost
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS

View File

@@ -59,7 +59,7 @@ namespace boost { namespace wave { namespace util
inline boost::filesystem::path normalize(boost::filesystem::path& p)
{
return p.normalize();
return p.normalize().make_preferred();
}
inline std::string native_file_string(boost::filesystem::path const& p)

File diff suppressed because it is too large Load Diff

View File

@@ -26,18 +26,18 @@ namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////////
//
//
// class functor_input
//
// Implementation of the InputPolicy used by multi_pass
//
// Implementation of the InputPolicy used by multi_pass
// functor_input gets tokens from a functor
// Note: the functor must have a typedef for result_type
// It also must have a static variable of type result_type defined
// It also must have a static variable of type result_type defined
// to represent eof that is called eof.
//
// This functor input policy template is essentially the same as the
// predefined multi_pass functor_input policy. The difference is,
// that the first token is not read at initialization time, but only
// This functor input policy template is essentially the same as the
// predefined multi_pass functor_input policy. The difference is,
// that the first token is not read at initialization time, but only
// just before returning the first token. Additionally it does not
// call operator new() twice but only once.
//
@@ -54,10 +54,10 @@ struct functor_input {
private:
struct Data {
Data(FunctorT const &ftor_)
Data(FunctorT const &ftor_)
: ftor(ftor_), was_initialized(false)
{}
FunctorT ftor;
value_type curtok;
bool was_initialized;
@@ -145,7 +145,7 @@ struct functor_input {
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS

View File

@@ -2,7 +2,7 @@
Boost.Wave: A Standard compliant C++ preprocessor library
Detect the need to insert a whitespace token into the output stream
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -12,8 +12,8 @@
#if !defined(INSERT_WHITESPACE_DETECTION_HPP_765EF77B_0513_4967_BDD6_6A38148C4C96_INCLUDED)
#define INSERT_WHITESPACE_DETECTION_HPP_765EF77B_0513_4967_BDD6_6A38148C4C96_INCLUDED
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp>
#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
@@ -38,11 +38,11 @@ namespace impl {
return false;
if ('U' == value[0] && value.size() < 9)
return false;
typename StringT::size_type pos =
typename StringT::size_type pos =
value.find_first_not_of("0123456789abcdefABCDEF", 1);
if (StringT::npos == pos ||
if (StringT::npos == pos ||
('u' == value[0] && pos > 5) ||
('U' == value[0] && pos > 9))
{
@@ -51,12 +51,12 @@ namespace impl {
return false;
}
template <typename StringT>
inline bool
handle_identifier(boost::wave::token_id prev,
inline bool
handle_identifier(boost::wave::token_id prev,
boost::wave::token_id before, StringT const &value)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_IDENTIFIER:
case T_NONREPLACABLE_IDENTIFIER:
case T_COMPL_ALT:
@@ -75,19 +75,22 @@ namespace impl {
case T_INTLIT:
case T_PP_NUMBER:
return (value.size() > 1 || (value[0] != 'e' && value[0] != 'E'));
// avoid constructing universal characters (\u1234)
case TOKEN_FROM_ID('\\', UnknownTokenType):
case T_UNKNOWN_UNIVERSALCHAR:
return would_form_universal_char(value);
default:
break;
}
return false;
}
// T_INTLIT
inline bool
inline bool
handle_intlit(boost::wave::token_id prev, boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_IDENTIFIER:
case T_NONREPLACABLE_IDENTIFIER:
case T_INTLIT:
@@ -95,16 +98,19 @@ namespace impl {
case T_FIXEDPOINTLIT:
case T_PP_NUMBER:
return true;
default:
break;
}
return false;
}
// T_FLOATLIT
inline bool
handle_floatlit(boost::wave::token_id prev,
inline bool
handle_floatlit(boost::wave::token_id prev,
boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_IDENTIFIER:
case T_NONREPLACABLE_IDENTIFIER:
case T_INTLIT:
@@ -112,42 +118,51 @@ namespace impl {
case T_FIXEDPOINTLIT:
case T_PP_NUMBER:
return true;
default:
break;
}
return false;
}
// <% T_LEFTBRACE
inline bool
handle_alt_leftbrace(boost::wave::token_id prev,
inline bool
handle_alt_leftbrace(boost::wave::token_id prev,
boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_LESS: // <<%
case T_SHIFTLEFT: // <<<%
return true;
default:
break;
}
return false;
}
// <: T_LEFTBRACKET
inline bool
handle_alt_leftbracket(boost::wave::token_id prev,
inline bool
handle_alt_leftbracket(boost::wave::token_id prev,
boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_LESS: // <<:
case T_SHIFTLEFT: // <<<:
return true;
default:
break;
}
return false;
}
// T_FIXEDPOINTLIT
inline bool
handle_fixedpointlit(boost::wave::token_id prev,
inline bool
handle_fixedpointlit(boost::wave::token_id prev,
boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_IDENTIFIER:
case T_NONREPLACABLE_IDENTIFIER:
case T_INTLIT:
@@ -155,55 +170,67 @@ namespace impl {
case T_FIXEDPOINTLIT:
case T_PP_NUMBER:
return true;
default:
break;
}
return false;
}
// T_DOT
inline bool
inline bool
handle_dot(boost::wave::token_id prev, boost::wave::token_id before)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_DOT:
if (T_DOT == before)
return true; // ...
break;
default:
break;
}
return false;
}
// T_QUESTION_MARK
inline bool
handle_questionmark(boost::wave::token_id prev,
inline bool
handle_questionmark(boost::wave::token_id prev,
boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch(static_cast<unsigned int>(prev)) {
case TOKEN_FROM_ID('\\', UnknownTokenType): // \?
switch(prev) {
case T_UNKNOWN_UNIVERSALCHAR: // \?
case T_QUESTION_MARK: // ??
return true;
default:
break;
}
return false;
}
// T_NEWLINE
inline bool
handle_newline(boost::wave::token_id prev,
handle_newline(boost::wave::token_id prev,
boost::wave::token_id before)
{
using namespace boost::wave;
switch(static_cast<unsigned int>(prev)) {
switch(prev) {
case TOKEN_FROM_ID('\\', UnknownTokenType): // \ \n
case T_DIVIDE:
if (T_QUESTION_MARK == before)
return true; // ?/\n // may be \\n
break;
default:
break;
}
return false;
}
inline bool
inline bool
handle_parens(boost::wave::token_id prev)
{
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_LEFTPAREN:
case T_RIGHTPAREN:
case T_LEFTBRACKET:
@@ -214,56 +241,56 @@ namespace impl {
case T_COMMA:
case T_COLON:
// no insertion between parens/brackets/braces and operators
return false;
return false;
default:
break;
}
return true;
}
} // namespace impl
class insert_whitespace_detection
class insert_whitespace_detection
{
public:
insert_whitespace_detection(bool insert_whitespace_ = true)
insert_whitespace_detection(bool insert_whitespace_ = true)
: insert_whitespace(insert_whitespace_),
prev(boost::wave::T_EOF), beforeprev(boost::wave::T_EOF)
prev(boost::wave::T_EOF), beforeprev(boost::wave::T_EOF)
{}
template <typename StringT>
bool must_insert(boost::wave::token_id current, StringT const &value)
{
if (!insert_whitespace)
return false; // skip whitespace insertion alltogether
using namespace boost::wave;
switch (static_cast<unsigned int>(current)) {
switch (current) {
case T_NONREPLACABLE_IDENTIFIER:
case T_IDENTIFIER:
return impl::handle_identifier(prev, beforeprev, value);
case T_IDENTIFIER:
return impl::handle_identifier(prev, beforeprev, value);
case T_PP_NUMBER:
case T_INTLIT:
return impl::handle_intlit(prev, beforeprev);
return impl::handle_intlit(prev, beforeprev);
case T_FLOATLIT:
return impl::handle_floatlit(prev, beforeprev);
return impl::handle_floatlit(prev, beforeprev);
case T_STRINGLIT:
if (TOKEN_FROM_ID('L', IdentifierTokenType) == prev) // 'L'
return true;
break;
case T_LEFTBRACE_ALT:
return impl::handle_alt_leftbrace(prev, beforeprev);
return impl::handle_alt_leftbrace(prev, beforeprev);
case T_LEFTBRACKET_ALT:
return impl::handle_alt_leftbracket(prev, beforeprev);
return impl::handle_alt_leftbracket(prev, beforeprev);
case T_FIXEDPOINTLIT:
return impl::handle_fixedpointlit(prev, beforeprev);
return impl::handle_fixedpointlit(prev, beforeprev);
case T_DOT:
return impl::handle_dot(prev, beforeprev);
return impl::handle_dot(prev, beforeprev);
case T_QUESTION_MARK:
return impl::handle_questionmark(prev, beforeprev);
return impl::handle_questionmark(prev, beforeprev);
case T_NEWLINE:
return impl::handle_newline(prev, beforeprev);
return impl::handle_newline(prev, beforeprev);
case T_LEFTPAREN:
case T_RIGHTPAREN:
@@ -272,7 +299,7 @@ public:
case T_SEMICOLON:
case T_COMMA:
case T_COLON:
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_LEFTPAREN:
case T_RIGHTPAREN:
case T_LEFTBRACKET:
@@ -285,12 +312,12 @@ public:
if (IS_CATEGORY(prev, OperatorTokenType))
return false;
break;
}
}
break;
case T_LEFTBRACE:
case T_RIGHTBRACE:
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_LEFTPAREN:
case T_RIGHTPAREN:
case T_LEFTBRACKET:
@@ -308,12 +335,12 @@ public:
if (IS_CATEGORY(prev, OperatorTokenType))
return false;
break;
default:
break;
}
break;
case T_MINUS:
case T_MINUSMINUS:
case T_MINUSASSIGN:
@@ -324,7 +351,7 @@ public:
if (T_QUESTION_MARK == prev && T_QUESTION_MARK == beforeprev)
return true;
break;
case T_PLUS:
case T_PLUSPLUS:
case T_PLUSASSIGN:
@@ -335,7 +362,7 @@ public:
if (T_QUESTION_MARK == prev && T_QUESTION_MARK == beforeprev)
return true;
break;
case T_DIVIDE:
case T_DIVIDEASSIGN:
if (T_DIVIDE == prev)
@@ -345,10 +372,10 @@ public:
if (T_QUESTION_MARK == prev && T_QUESTION_MARK == beforeprev)
return true;
break;
case T_EQUAL:
case T_ASSIGN:
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_PLUSASSIGN:
case T_MINUSASSIGN:
case T_DIVIDEASSIGN:
@@ -379,7 +406,7 @@ public:
if (T_QUESTION_MARK == beforeprev)
return true;
break;
default:
if (!impl::handle_parens(prev))
return false;
@@ -416,21 +443,21 @@ public:
if (T_AND == prev || T_ANDAND == prev)
return true;
break;
case T_OR:
if (!impl::handle_parens(prev))
return false;
if (T_OR == prev)
return true;
break;
case T_XOR:
if (!impl::handle_parens(prev))
return false;
if (T_XOR == prev)
return true;
break;
case T_COMPL_ALT:
case T_OR_ALT:
case T_AND_ALT:
@@ -440,7 +467,7 @@ public:
case T_ORASSIGN_ALT:
case T_XORASSIGN_ALT:
case T_NOTEQUAL_ALT:
switch (static_cast<unsigned int>(prev)) {
switch (prev) {
case T_LEFTPAREN:
case T_RIGHTPAREN:
case T_LEFTBRACKET:
@@ -451,7 +478,7 @@ public:
case T_COMMA:
case T_COLON:
// no insertion between parens/brackets/braces and operators
return false;
return false;
case T_IDENTIFIER:
if (T_NONREPLACABLE_IDENTIFIER == prev ||
@@ -460,16 +487,16 @@ public:
return true;
}
break;
default:
break;
}
break;
case T_STAR:
if (T_STAR == prev)
return false; // '*****' do not need to be separated
if (T_GREATER== prev &&
if (T_GREATER== prev &&
(T_MINUS == beforeprev || T_MINUSMINUS == beforeprev)
)
{
@@ -481,10 +508,13 @@ public:
if (T_POUND == prev)
return true;
break;
default:
break;
}
// FIXME: else, handle operators separately (will catch to many cases)
// if (IS_CATEGORY(current, OperatorTokenType) &&
// if (IS_CATEGORY(current, OperatorTokenType) &&
// IS_CATEGORY(prev, OperatorTokenType))
// {
// return true; // operators must be delimited always
@@ -498,7 +528,7 @@ public:
prev = next_id;
}
}
private:
bool insert_whitespace; // enable this component
boost::wave::token_id prev; // the previous analyzed token
@@ -507,7 +537,7 @@ private:
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code

View File

@@ -47,12 +47,12 @@ namespace util {
///////////////////////////////////////////////////////////////////////////////
//
// The function interpret_pragma interprets the given token sequence as the
// body of a #pragma directive (or parameter to the _Pragma operator) and
// body of a #pragma directive (or parameter to the _Pragma operator) and
// executes the actions associated with recognized Wave specific options.
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContextT, typename IteratorT, typename ContainerT>
inline bool
inline bool
interpret_pragma(ContextT &ctx, typename ContextT::token_type const &act_token,
IteratorT it, IteratorT const &end, ContainerT &pending)
{
@@ -62,44 +62,44 @@ interpret_pragma(ContextT &ctx, typename ContextT::token_type const &act_token,
using namespace cpplexer;
if (T_IDENTIFIER == token_id(*it)) {
// check for pragma wave ...
if ((*it).get_value() == BOOST_WAVE_PRAGMA_KEYWORD)
if ((*it).get_value() == BOOST_WAVE_PRAGMA_KEYWORD)
{
// this is a wave specific option, it should have the form:
//
// #pragma command option(value)
//
// where
// where
// 'command' is the value of the preprocessor constant
// BOOST_WAVE_PRAGMA_KEYWORD (defaults to "wave") and
// '(value)' is required only for some pragma directives (this is
// '(value)' is required only for some pragma directives (this is
// optional)
//
// All recognized #pragma operators are forwarded to the supplied
// All recognized #pragma operators are forwarded to the supplied
// preprocessing hook.
using namespace boost::spirit::classic;
token_type option;
ContainerT values;
if (!parse (++it, end,
if (!parse (++it, end,
( ch_p(T_IDENTIFIER)
[
spirit_assign_actor(option)
]
| pattern_p(KeywordTokenType,
]
| pattern_p(KeywordTokenType,
TokenTypeMask|PPTokenFlag)
[
spirit_assign_actor(option)
]
| pattern_p(OperatorTokenType|AltExtTokenType,
]
| pattern_p(OperatorTokenType|AltExtTokenType,
ExtTokenTypeMask|PPTokenFlag) // and, bit_and etc.
[
spirit_assign_actor(option)
]
| pattern_p(BoolLiteralTokenType,
]
| pattern_p(BoolLiteralTokenType,
TokenTypeMask|PPTokenFlag)
[
spirit_assign_actor(option)
]
]
)
>> !comment_nest_p(
ch_p(T_LEFTPAREN),
@@ -109,7 +109,7 @@ interpret_pragma(ContextT &ctx, typename ContextT::token_type const &act_token,
{
typename ContextT::string_type msg(
impl::as_string<string_type>(it, end));
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
ill_formed_pragma_option,
msg.c_str(), act_token.get_position());
return false;
@@ -125,9 +125,9 @@ interpret_pragma(ContextT &ctx, typename ContextT::token_type const &act_token,
// decode the option (call the context_policy hook)
if (!ctx.get_hooks().interpret_pragma(
ctx.derived(), pending, option, values, act_token))
ctx.derived(), pending, option, values, act_token))
{
// unknown #pragma option
// unknown #pragma option
string_type option_str ((*it).get_value());
option_str += option.get_value();
@@ -136,7 +136,7 @@ interpret_pragma(ContextT &ctx, typename ContextT::token_type const &act_token,
option_str += impl::as_string(values);
option_str += ")";
}
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
ill_formed_pragma_option,
option_str.c_str(), act_token.get_position());
return false;
@@ -148,15 +148,15 @@ interpret_pragma(ContextT &ctx, typename ContextT::token_type const &act_token,
// #pragma once
return ctx.add_pragma_once_header(act_token, ctx.get_current_filename());
}
#endif
#endif
#if BOOST_WAVE_SUPPORT_PRAGMA_MESSAGE != 0
else if ((*it).get_value() == "message") {
// #pragma message(...) or #pragma message ...
using namespace boost::spirit::classic;
ContainerT values;
if (!parse (++it, end,
( ( ch_p(T_LEFTPAREN)
if (!parse (++it, end,
( ( ch_p(T_LEFTPAREN)
>> lexeme_d[
*(anychar_p[spirit_append_actor(values)] - ch_p(T_RIGHTPAREN))
]
@@ -172,7 +172,7 @@ interpret_pragma(ContextT &ctx, typename ContextT::token_type const &act_token,
{
typename ContextT::string_type msg(
impl::as_string<string_type>(it, end));
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
ill_formed_pragma_message,
msg.c_str(), act_token.get_position());
return false;
@@ -187,8 +187,8 @@ interpret_pragma(ContextT &ctx, typename ContextT::token_type const &act_token,
// output the message itself
typename ContextT::string_type msg(impl::as_string(values));
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
pragma_message_directive,
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
pragma_message_directive,
msg.c_str(), act_token.get_position());
return false;
}

View File

@@ -40,7 +40,7 @@ namespace util {
//
// macro_definition
//
// This class containes all infos for a defined macro.
// This class containes all infos for a defined macro.
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT, typename ContainerT>
@@ -49,14 +49,14 @@ struct macro_definition {
typedef std::vector<TokenT> parameter_container_type;
typedef ContainerT definition_container_type;
typedef typename parameter_container_type::const_iterator
typedef typename parameter_container_type::const_iterator
const_parameter_iterator_t;
typedef typename definition_container_type::const_iterator
typedef typename definition_container_type::const_iterator
const_definition_iterator_t;
macro_definition(TokenT const &token_, bool has_parameters,
macro_definition(TokenT const &token_, bool has_parameters,
bool is_predefined_, long uid_)
: macroname(token_), uid(uid_), is_functionlike(has_parameters),
: macroname(token_), uid(uid_), is_functionlike(has_parameters),
replaced_parameters(false), is_available_for_replacement(true),
is_predefined(is_predefined_)
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
@@ -79,29 +79,29 @@ struct macro_definition {
if (!replaced_parameters) {
typename definition_container_type::iterator end = macrodefinition.end();
typename definition_container_type::iterator it = macrodefinition.begin();
typename definition_container_type::iterator it = macrodefinition.begin();
for (/**/; it != end; ++it) {
token_id id = *it;
if (T_IDENTIFIER == id ||
if (T_IDENTIFIER == id ||
IS_CATEGORY(id, KeywordTokenType) ||
IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) ||
IS_CATEGORY(id, OperatorTokenType))
IS_CATEGORY(id, OperatorTokenType))
{
// may be a parameter to replace
const_parameter_iterator_t cend = macroparameters.end();
const_parameter_iterator_t cit = macroparameters.begin();
for (typename parameter_container_type::size_type i = 0;
cit != cend; ++cit, ++i)
for (typename parameter_container_type::size_type i = 0;
cit != cend; ++cit, ++i)
{
if ((*it).get_value() == (*cit).get_value()) {
(*it).set_token_id(token_id(T_PARAMETERBASE+i));
break;
}
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
else if (T_ELLIPSIS == token_id(*cit) &&
"__VA_ARGS__" == (*it).get_value())
else if (T_ELLIPSIS == token_id(*cit) &&
"__VA_ARGS__" == (*it).get_value())
{
// __VA_ARGS__ requires special handling
(*it).set_token_id(token_id(T_EXTPARAMETERBASE+i));
@@ -112,14 +112,14 @@ struct macro_definition {
}
}
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
// we need to know, if the last of the formal arguments is an ellipsis
if (macroparameters.size() > 0 &&
T_ELLIPSIS == token_id(macroparameters.back()))
T_ELLIPSIS == token_id(macroparameters.back()))
{
has_ellipsis = true;
}
#endif
#endif
replaced_parameters = true; // do it only once
}
}
@@ -139,7 +139,7 @@ struct macro_definition {
#if BOOST_WAVE_SERIALIZATION != 0
// default constructor is needed for serialization only
macro_definition()
macro_definition()
: uid(0), is_functionlike(false), replaced_parameters(false),
is_available_for_replacement(false), is_predefined(false)
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0

View File

@@ -41,8 +41,8 @@ namespace impl {
typename StringT::size_type pos1 = value.find_first_of ("\"\\?", 0);
if (StringT::npos != pos1) {
do {
result += value.substr(pos, pos1-pos)
+ StringT("\\")
result += value.substr(pos, pos1-pos)
+ StringT("\\")
+ StringT(1, value[pos1]);
pos1 = value.find_first_of ("\"\\?", pos = pos1+1);
} while (StringT::npos != pos1);
@@ -104,16 +104,16 @@ namespace impl {
string_type result("\"");
bool was_whitespace = false;
typename ContainerT::const_iterator end = token_sequence.end();
for (typename ContainerT::const_iterator it = token_sequence.begin();
it != end; ++it)
for (typename ContainerT::const_iterator it = token_sequence.begin();
it != end; ++it)
{
token_id id = token_id(*it);
if (IS_CATEGORY(*it, WhiteSpaceTokenType) || T_NEWLINE == id) {
if (!was_whitespace) {
// C++ standard 16.3.2.2 [cpp.stringize]
// Each occurrence of white space between the argument's
// preprocessing tokens becomes a single space character in the
// Each occurrence of white space between the argument's
// preprocessing tokens becomes a single space character in the
// character string literal.
result += " ";
was_whitespace = true;
@@ -124,10 +124,10 @@ namespace impl {
result += impl::escape_lit((*it).get_value());
was_whitespace = false;
}
else
else
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
if (T_PLACEMARKER != id)
#endif
if (T_PLACEMARKER != id)
#endif
{
// now append this token to the string
result += (*it).get_value();
@@ -138,8 +138,8 @@ namespace impl {
// validate the resulting literal to contain no invalid universal character
// value (throws if invalid chars found)
boost::wave::cpplexer::impl::validate_literal(result, pos.get_line(),
pos.get_column(), pos.get_file());
boost::wave::cpplexer::impl::validate_literal(result, pos.get_line(),
pos.get_column(), pos.get_file());
return result;
}
@@ -147,7 +147,7 @@ namespace impl {
// return the string representation of a token sequence
template <typename ContainerT, typename PositionT>
inline typename ContainerT::value_type::string_type
as_stringlit (std::vector<ContainerT> const &arguments,
as_stringlit (std::vector<ContainerT> const &arguments,
typename std::vector<ContainerT>::size_type i, PositionT const &pos)
{
using namespace boost::wave;
@@ -161,16 +161,16 @@ namespace impl {
for (/**/; i < arguments.size(); ++i) {
// stringize all remaining arguments
typename ContainerT::const_iterator end = arguments[i].end();
for (typename ContainerT::const_iterator it = arguments[i].begin();
it != end; ++it)
for (typename ContainerT::const_iterator it = arguments[i].begin();
it != end; ++it)
{
token_id id = token_id(*it);
if (IS_CATEGORY(*it, WhiteSpaceTokenType) || T_NEWLINE == id) {
if (!was_whitespace) {
// C++ standard 16.3.2.2 [cpp.stringize]
// Each occurrence of white space between the argument's
// preprocessing tokens becomes a single space character in the
// Each occurrence of white space between the argument's
// preprocessing tokens becomes a single space character in the
// character string literal.
result += " ";
was_whitespace = true;
@@ -198,8 +198,8 @@ namespace impl {
// validate the resulting literal to contain no invalid universal character
// value (throws if invalid chars found)
boost::wave::cpplexer::impl::validate_literal(result, pos.get_line(),
pos.get_column(), pos.get_file());
boost::wave::cpplexer::impl::validate_literal(result, pos.get_line(),
pos.get_column(), pos.get_file());
return result;
}
#endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
@@ -210,7 +210,7 @@ namespace impl {
as_string(IteratorT it, IteratorT const& end)
{
StringT result;
for (/**/; it != end; ++it)
for (/**/; it != end; ++it)
{
result += (*it).get_value();
}
@@ -223,32 +223,32 @@ namespace impl {
as_string (ContainerT const &token_sequence)
{
typedef typename ContainerT::value_type::string_type string_type;
return as_string<string_type>(token_sequence.begin(),
return as_string<string_type>(token_sequence.begin(),
token_sequence.end());
}
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
///////////////////////////////////////////////////////////////////////////
//
// Copies all arguments beginning with the given index to the output
// Copies all arguments beginning with the given index to the output
// sequence. The arguments are separated by commas.
//
template <typename ContainerT, typename PositionT>
void replace_ellipsis (std::vector<ContainerT> const &arguments,
typename ContainerT::size_type index,
typename ContainerT::size_type index,
ContainerT &expanded, PositionT const &pos)
{
using namespace cpplexer;
typedef typename ContainerT::value_type token_type;
token_type comma(T_COMMA, ",", pos);
for (/**/; index < arguments.size(); ++index) {
ContainerT const &arg = arguments[index];
std::copy(arg.begin(), arg.end(),
std::copy(arg.begin(), arg.end(),
std::inserter(expanded, expanded.end()));
if (index < arguments.size()-1)
if (index < arguments.size()-1)
expanded.push_back(comma);
}
}
@@ -257,7 +257,7 @@ namespace impl {
// Skip all whitespace characters and queue the skipped characters into the
// given container
template <typename IteratorT>
inline boost::wave::token_id
inline boost::wave::token_id
skip_whitespace(IteratorT &first, IteratorT const &last)
{
token_id id = util::impl::next_token<IteratorT>::peek(first, last, false);
@@ -272,7 +272,7 @@ namespace impl {
}
template <typename IteratorT, typename ContainerT>
inline boost::wave::token_id
inline boost::wave::token_id
skip_whitespace(IteratorT &first, IteratorT const &last, ContainerT &queue)
{
queue.push_back (*first); // queue up the current token
@@ -280,7 +280,7 @@ namespace impl {
token_id id = util::impl::next_token<IteratorT>::peek(first, last, false);
if (IS_CATEGORY(id, WhiteSpaceTokenType)) {
do {
queue.push_back(*++first); // queue up the next whitespace
queue.push_back(*++first); // queue up the next whitespace
id = util::impl::next_token<IteratorT>::peek(first, last, false);
} while (IS_CATEGORY(id, WhiteSpaceTokenType));
}

View File

@@ -2,7 +2,7 @@
Boost.Wave: A Standard compliant C++ preprocessor library
Global application configuration
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -32,12 +32,12 @@ namespace util {
//
///////////////////////////////////////////////////////////////////////////
template <typename CharT = char>
struct pattern_and
struct pattern_and
: public boost::spirit::classic::char_parser<pattern_and<CharT> >
{
pattern_and(CharT pattern_, unsigned long pattern_mask_ = 0UL)
: pattern(pattern_),
pattern_mask((0UL != pattern_mask_) ?
: pattern(pattern_),
pattern_mask((0UL != pattern_mask_) ?
pattern_mask_ : (unsigned long)pattern_)
{}

View File

@@ -14,14 +14,14 @@
#include <map>
#include <boost/wave/wave_config.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/intrusive_ptr.hpp>
#if BOOST_WAVE_SERIALIZATION != 0
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/map.hpp>
#include <boost/shared_ptr.hpp>
#else
#include <boost/intrusive_ptr.hpp>
#include <boost/intrusive_ptr.hpp>
#endif
#include <boost/iterator/transform_iterator.hpp>
@@ -38,16 +38,16 @@ namespace util {
///////////////////////////////////////////////////////////////////////////////
//
// The symbol_table class is used for the storage of defined macros.
// The symbol_table class is used for the storage of defined macros.
//
///////////////////////////////////////////////////////////////////////////////
template <typename StringT, typename MacroDefT>
struct symbol_table
struct symbol_table
#if BOOST_WAVE_SERIALIZATION != 0
: public std::map<StringT, boost::shared_ptr<MacroDefT> >
: public std::map<StringT, boost::shared_ptr<MacroDefT> >
#else
: public std::map<StringT, boost::intrusive_ptr<MacroDefT> >
: public std::map<StringT, boost::intrusive_ptr<MacroDefT> >
#endif
{
#if BOOST_WAVE_SERIALIZATION != 0
@@ -58,7 +58,7 @@ struct symbol_table
typedef typename base_type::iterator iterator_type;
typedef typename base_type::const_iterator const_iterator_type;
symbol_table(long uid_ = 0)
symbol_table(long uid_ = 0)
{}
#if BOOST_WAVE_SERIALIZATION != 0
@@ -68,7 +68,7 @@ private:
void serialize(Archive &ar, const unsigned int version)
{
using namespace boost::serialization;
ar & make_nvp("symbol_table",
ar & make_nvp("symbol_table",
boost::serialization::base_object<base_type>(*this));
}
#endif
@@ -76,7 +76,7 @@ private:
private:
///////////////////////////////////////////////////////////////////////////
//
// This is a special iterator allowing to iterate the names of all defined
// This is a special iterator allowing to iterate the names of all defined
// macros.
//
///////////////////////////////////////////////////////////////////////////
@@ -94,13 +94,13 @@ private:
typedef get_first<StringT> unary_functor;
public:
typedef transform_iterator<unary_functor, iterator_type>
typedef transform_iterator<unary_functor, iterator_type>
name_iterator;
typedef transform_iterator<unary_functor, const_iterator_type>
typedef transform_iterator<unary_functor, const_iterator_type>
const_name_iterator;
template <typename Iterator>
static
static
transform_iterator<unary_functor, Iterator> make_iterator(Iterator it)
{
return boost::make_transform_iterator<unary_functor>(it);

View File

@@ -38,7 +38,7 @@ namespace util {
namespace time_conversion {
using namespace std; // some systems have std::tm etc. in namespace std
///////////////////////////////////////////////////////////////////////////////
// define, whether the rule's should generate some debug output
#define TRACE_CPP_TIME_CONVERSION \
@@ -47,7 +47,7 @@ namespace time_conversion {
///////////////////////////////////////////////////////////////////////////////
// Grammar for parsing a date/time string generated by the C++ compiler from
// __DATE__ and __TIME__
// __DATE__ and __TIME__
class time_conversion_grammar :
public boost::spirit::classic::grammar<time_conversion_grammar>
{
@@ -59,17 +59,17 @@ namespace time_conversion {
BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME(*this, "time_conversion_grammar",
TRACE_CPP_TIME_CONVERSION);
}
template <typename ScannerT>
struct definition {
definition(time_conversion_grammar const &self)
{
using boost::spirit::classic::int_p;
using boost::spirit::classic::add;
char const *m[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
@@ -77,26 +77,26 @@ namespace time_conversion {
add (month, m[i], i);
time_rule // expected format is 'Dec 29 2001 11:23:59'
= month[spirit_assign_actor(self.time_stamp.tm_mon)]
>> int_p[spirit_assign_actor(self.time_stamp.tm_mday)]
= month[spirit_assign_actor(self.time_stamp.tm_mon)]
>> int_p[spirit_assign_actor(self.time_stamp.tm_mday)]
>> int_p[spirit_assign_actor(self.time_stamp.tm_year)]
>> int_p[spirit_assign_actor(self.time_stamp.tm_hour)] >> ':'
>> int_p[spirit_assign_actor(self.time_stamp.tm_hour)] >> ':'
>> int_p[spirit_assign_actor(self.time_stamp.tm_min)] >> ':'
>> int_p[spirit_assign_actor(self.time_stamp.tm_sec)]
;
BOOST_SPIRIT_DEBUG_TRACE_RULE(time_rule, TRACE_CPP_TIME_CONVERSION);
}
boost::spirit::classic::rule<ScannerT> time_rule;
boost::spirit::classic::symbols<> month;
boost::spirit::classic::rule<ScannerT> const&
start() const { return time_rule; }
};
void correct_year()
{
void correct_year()
{
if (!fYearIsCorrected) {
time_stamp.tm_year -= 1900;
fYearIsCorrected = true;
@@ -106,36 +106,36 @@ namespace time_conversion {
mutable tm time_stamp;
bool fYearIsCorrected;
};
///////////////////////////////////////////////////////////////////////////////
// calculate the time of the compilation as a std::time_t to ensure correctness
// of the saved dfa table
// calculate the time of the compilation as a std::time_t to ensure correctness
// of the saved dfa table
class time_conversion_helper
{
public:
time_conversion_helper(char const *act_time) : compile_time(0)
{
using namespace boost::spirit::classic;
time_conversion_grammar g;
parse_info<> pi = parse (act_time, g, space_p);
if (pi.hit) {
g.correct_year();
compile_time = mktime(&g.time_stamp);
}
BOOST_ASSERT(0 != compile_time);
BOOST_ASSERT(0 != compile_time);
}
time_t get_time() const { return compile_time; }
private:
time_t compile_time;
time_t compile_time;
};
///////////////////////////////////////////////////////////////////////////////
#undef TRACE_CPP_TIME_CONVERSION
} // namespace time_conversion
} // namespace time_conversion
// import time_conversion into the boost::wave::util namespace
using namespace time_conversion;

View File

@@ -24,12 +24,12 @@
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace wave {
namespace impl {
///////////////////////////////////////////////////////////////////////////////
//
// The new Boost.Iterator library already conatins a transform_iterator usable
// The new Boost.Iterator library already conatins a transform_iterator usable
// for our needs. The code below wraps this up.
//
///////////////////////////////////////////////////////////////////////////////
@@ -46,7 +46,7 @@ namespace impl {
};
template <class AdaptableUnaryFunctionT, class IteratorT>
inline
inline
typename ref_transform_iterator_generator<
AdaptableUnaryFunctionT, IteratorT>::type
make_ref_transform_iterator(
@@ -68,9 +68,9 @@ namespace impl {
typedef ParseTreeNodeT const &argument_type;
static result_type
transform (argument_type node)
transform (argument_type node)
{
BOOST_ASSERT(1 == std::distance(node.value.begin(),
BOOST_ASSERT(1 == std::distance(node.value.begin(),
node.value.end()));
return *node.value.begin();
}

View File

@@ -2,7 +2,7 @@
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the unput queue iterator
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -18,7 +18,7 @@
#include <boost/iterator_adaptors.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp> // token_id
#include <boost/wave/token_ids.hpp> // token_id
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
@@ -42,13 +42,13 @@ namespace util {
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename TokenT, typename ContainerT>
class unput_queue_iterator
class unput_queue_iterator
: public boost::iterator_adaptor<
unput_queue_iterator<IteratorT, TokenT, ContainerT>,
unput_queue_iterator<IteratorT, TokenT, ContainerT>,
IteratorT, TokenT const, std::forward_iterator_tag>
{
typedef boost::iterator_adaptor<
unput_queue_iterator<IteratorT, TokenT, ContainerT>,
unput_queue_iterator<IteratorT, TokenT, ContainerT>,
IteratorT, TokenT const, std::forward_iterator_tag>
base_type;
@@ -59,62 +59,62 @@ public:
unput_queue_iterator(IteratorT const &it, ContainerT &queue)
: base_type(it), unput_queue(queue)
{}
ContainerT &get_unput_queue()
ContainerT &get_unput_queue()
{ return unput_queue; }
ContainerT const &get_unput_queue() const
ContainerT const &get_unput_queue() const
{ return unput_queue; }
IteratorT &get_base_iterator()
IteratorT &get_base_iterator()
{ return base_type::base_reference(); }
IteratorT const &get_base_iterator() const
IteratorT const &get_base_iterator() const
{ return base_type::base_reference(); }
unput_queue_iterator &operator= (unput_queue_iterator const &rhs)
{
{
if (this != &rhs) {
unput_queue = rhs.unput_queue;
unput_queue = rhs.unput_queue;
base_type::operator=(rhs);
}
return *this;
return *this;
}
typename base_type::reference dereference() const
{
if (!unput_queue.empty())
return unput_queue.front();
return *base_type::base_reference();
return *base_type::base_reference();
}
void increment()
{
{
if (!unput_queue.empty()) {
// there exist pending tokens in the unput queue
unput_queue.pop_front();
}
else {
// the unput_queue is empty, so advance the base iterator
++base_type::base_reference();
++base_type::base_reference();
}
}
template <
typename OtherDerivedT, typename OtherIteratorT,
typename OtherDerivedT, typename OtherIteratorT,
typename V, typename C, typename R, typename D
>
>
bool equal(
boost::iterator_adaptor<OtherDerivedT, OtherIteratorT, V, C, R, D>
boost::iterator_adaptor<OtherDerivedT, OtherIteratorT, V, C, R, D>
const &x) const
{
// two iterators are equal, if both begin() iterators of the queue
// two iterators are equal, if both begin() iterators of the queue
// objects are equal and the base iterators are equal as well
OtherDerivedT const &rhs = static_cast<OtherDerivedT const &>(x);
return
return
((unput_queue.empty() && rhs.unput_queue.empty()) ||
(&unput_queue == &rhs.unput_queue &&
unput_queue.begin() == rhs.unput_queue.begin()
)
) &&
(get_base_iterator() == rhs.get_base_iterator());
(get_base_iterator() == rhs.get_base_iterator());
}
private:
@@ -125,11 +125,11 @@ namespace impl {
///////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename TokenT, typename ContainerT>
struct gen_unput_queue_iterator
struct gen_unput_queue_iterator
{
typedef ContainerT container_type;
typedef IteratorT iterator_type;
typedef unput_queue_iterator<IteratorT, TokenT, ContainerT>
typedef unput_queue_iterator<IteratorT, TokenT, ContainerT>
return_type;
static container_type last;
@@ -149,32 +149,32 @@ namespace impl {
template <typename IteratorT, typename TokenT, typename ContainerT>
typename gen_unput_queue_iterator<IteratorT, TokenT, ContainerT>::
container_type
gen_unput_queue_iterator<IteratorT, TokenT, ContainerT>::last =
container_type
gen_unput_queue_iterator<IteratorT, TokenT, ContainerT>::last =
typename gen_unput_queue_iterator<IteratorT, TokenT, ContainerT>::
container_type();
///////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename TokenT, typename ContainerT>
struct gen_unput_queue_iterator<
unput_queue_iterator<IteratorT, TokenT, ContainerT>,
TokenT, ContainerT>
unput_queue_iterator<IteratorT, TokenT, ContainerT>,
TokenT, ContainerT>
{
typedef ContainerT container_type;
typedef unput_queue_iterator<IteratorT, TokenT, ContainerT>
typedef unput_queue_iterator<IteratorT, TokenT, ContainerT>
iterator_type;
typedef unput_queue_iterator<IteratorT, TokenT, ContainerT>
typedef unput_queue_iterator<IteratorT, TokenT, ContainerT>
return_type;
static container_type last;
static return_type
static return_type
generate(iterator_type &it)
{
return return_type(it.base(), last);
}
static return_type
static return_type
generate(ContainerT &queue, iterator_type &it)
{
return return_type(it.base(), queue);
@@ -183,9 +183,9 @@ namespace impl {
///////////////////////////////////////////////////////////////////////////
template <typename IteratorT>
struct assign_iterator
struct assign_iterator
{
static void
static void
do_ (IteratorT &dest, IteratorT const &src)
{
dest = src;
@@ -198,9 +198,9 @@ namespace impl {
// Note though, that the embedded unput_queues are not touched in any way!
//
template <typename IteratorT>
struct next_token
struct next_token
{
static boost::wave::token_id
static boost::wave::token_id
peek(IteratorT it, IteratorT end, bool skip_whitespace = true)
{
using namespace boost::wave;
@@ -216,7 +216,7 @@ namespace impl {
else {
++it; // we have at least to look ahead
}
if (it != end)
if (it != end)
return token_id(*it);
return T_EOI;
}
@@ -228,7 +228,7 @@ namespace impl {
typedef unput_queue_iterator<IteratorT, TokenT, ContainerT> iterator_type;
static boost::wave::token_id
static boost::wave::token_id
peek(iterator_type it, iterator_type end, bool skip_whitespace = true)
{
using namespace boost::wave;
@@ -252,7 +252,7 @@ namespace impl {
else {
++cit; // we have at least to look ahead
}
if (cit != cend)
if (cit != cend)
return token_id(*cit);
}

View File

@@ -2,7 +2,7 @@
Boost.Wave: A Standard compliant C++ preprocessor library
Global application configuration
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -20,10 +20,10 @@
#include <boost/wave/wave_version.hpp>
///////////////////////////////////////////////////////////////////////////////
// Define the maximal include nesting depth allowed. If this value isn't
// Define the maximal include nesting depth allowed. If this value isn't
// defined it defaults to 1024
//
// To define a new initial include nesting define the following constant
// To define a new initial include nesting define the following constant
// before including this file.
//
#if !defined(BOOST_WAVE_MAX_INCLUDE_LEVEL_DEPTH)
@@ -33,7 +33,7 @@
///////////////////////////////////////////////////////////////////////////////
// Decide, whether to support variadics and placemarkers
//
// To implement support variadics and placemarkers define the following to
// To implement support variadics and placemarkers define the following to
// something not equal to zero.
//
#if !defined(BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS)
@@ -41,10 +41,10 @@
#endif
///////////////////////////////////////////////////////////////////////////////
// Decide, whether to implement a #warning directive as an extension to the
// Decide, whether to implement a #warning directive as an extension to the
// C++ Standard (same as #error, but emits a warning, not an error)
//
// To disable the implementation of #warning directives, define the following
// To disable the implementation of #warning directives, define the following
// constant as zero before including this file.
//
#if !defined(BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE)
@@ -52,9 +52,9 @@
#endif
///////////////////////////////////////////////////////////////////////////////
// Decide, whether to implement #pragma once
// Decide, whether to implement #pragma once
//
// To disable the implementation of #pragma once, define the following
// To disable the implementation of #pragma once, define the following
// constant as zero before including this file.
//
#if !defined(BOOST_WAVE_SUPPORT_PRAGMA_ONCE)
@@ -62,9 +62,9 @@
#endif
///////////////////////////////////////////////////////////////////////////////
// Decide, whether to implement #pragma message("")
// Decide, whether to implement #pragma message("")
//
// To disable the implementation of #pragma message(""), define the following
// To disable the implementation of #pragma message(""), define the following
// constant as zero before including this file.
//
#if !defined(BOOST_WAVE_SUPPORT_PRAGMA_MESSAGE)
@@ -75,7 +75,7 @@
// Decide, whether to implement #include_next
// Please note, that this is an extension to the C++ Standard.
//
// To disable the implementation of #include_next, define the following
// To disable the implementation of #include_next, define the following
// constant as zero before including this file.
//
#if !defined(BOOST_WAVE_SUPPORT_INCLUDE_NEXT)
@@ -85,7 +85,7 @@
///////////////////////////////////////////////////////////////////////////////
// Decide, whether to support C++11
//
// To implement C++11 keywords and preprocessor semantics define the following
// To implement C++11 keywords and preprocessor semantics define the following
// to something not equal to zero.
//
#if !defined(BOOST_WAVE_SUPPORT_CPP0X)
@@ -96,11 +96,11 @@
///////////////////////////////////////////////////////////////////////////////
// Undefine the following, to enable some MS specific language extensions:
// __int8, __int16, __int32, __int64, __based, __declspec, __cdecl,
// __int8, __int16, __int32, __int64, __based, __declspec, __cdecl,
// __fastcall, __stdcall, __try, __except, __finally, __leave, __inline,
// __asm, #region, #endregion
//
// Note: By default this is enabled for Windows based systems, otherwise it's
// Note: By default this is enabled for Windows based systems, otherwise it's
// disabled.
#if !defined(BOOST_WAVE_SUPPORT_MS_EXTENSIONS)
#if defined(BOOST_WINDOWS)
@@ -111,10 +111,10 @@
#endif
///////////////////////////////////////////////////////////////////////////////
// Allow the message body of the #error and #warning directives to be
// Allow the message body of the #error and #warning directives to be
// preprocessed before the diagnostic is issued.
//
// To disable preprocessing of the body of #error and #warning directives,
// To disable preprocessing of the body of #error and #warning directives,
// define the following constant as zero before including this file.
//
#if !defined(BOOST_WAVE_PREPROCESS_ERROR_MESSAGE_BODY)
@@ -122,10 +122,10 @@
#endif
///////////////////////////////////////////////////////////////////////////////
// Allow the #pragma directives to be returned to the caller (optionally after
// preprocessing the body)
// Allow the #pragma directives to be returned to the caller (optionally after
// preprocessing the body)
//
// To disable the library to emit unknown #pragma directives, define the
// To disable the library to emit unknown #pragma directives, define the
// following constant as zero before including this file.
//
#if !defined(BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES)
@@ -133,10 +133,10 @@
#endif
///////////////////////////////////////////////////////////////////////////////
// Allow the body of a #pragma directive to be preprocessed before the
// Allow the body of a #pragma directive to be preprocessed before the
// directive is returned to the caller.
//
// To disable the preprocessing of the body of #pragma directives, define the
// To disable the preprocessing of the body of #pragma directives, define the
// following constant as zero before including this file.
//
#if !defined(BOOST_WAVE_PREPROCESS_PRAGMA_BODY)
@@ -146,7 +146,7 @@
///////////////////////////////////////////////////////////////////////////////
// Allow to define macros with the command line syntax (-DMACRO(x)=definition)
//
// To disable the possibility to define macros based on the command line
// To disable the possibility to define macros based on the command line
// syntax, define the following constant as zero before including this file.
//
#if !defined(BOOST_WAVE_ENABLE_COMMANDLINE_MACROS)
@@ -155,27 +155,27 @@
///////////////////////////////////////////////////////////////////////////////
// Define the pragma keyword to be used by the library to recognize its own
// pragma's. If nothing else is defined, then 'wave' will be used as the
// default keyword, i.e. the library recognizes all
// pragma's. If nothing else is defined, then 'wave' will be used as the
// default keyword, i.e. the library recognizes all
//
// #pragma wave option [(argument)]
//
// and dispatches the handling to the interpret_pragma() preprocessing hook
// and dispatches the handling to the interpret_pragma() preprocessing hook
// function (see file: preprocessing_hooks.hpp). The arguments part of the
// pragma is optional.
// The BOOST_WAVE_PRAGMA_KEYWORD constant needs to be defined to
// resolve as a string literal value.
#if !defined(BOOST_WAVE_PRAGMA_KEYWORD)
#define BOOST_WAVE_PRAGMA_KEYWORD "wave"
#endif
#endif
///////////////////////////////////////////////////////////////////////////////
// Configure Wave thread support, Boost.Spirit and Boost.Pool are configured
// Configure Wave thread support, Boost.Spirit and Boost.Pool are configured
// based on these settings automatically
//
// If BOOST_WAVE_SUPPORT_THREADING is not defined, Wave will use the global
// If BOOST_WAVE_SUPPORT_THREADING is not defined, Wave will use the global
// Boost build settings (BOOST_HAS_THREADS), if it is defined its value
// defines, whether threading will be enabled or not (should be set to '0'
// defines, whether threading will be enabled or not (should be set to '0'
// or '1').
#if !defined(BOOST_WAVE_SUPPORT_THREADING)
#if defined(BOOST_HAS_THREADS)
@@ -185,8 +185,10 @@
#endif
#endif
#if BOOST_WAVE_SUPPORT_THREADING != 0
#define BOOST_SPIRIT_THREADSAFE 1
#if BOOST_WAVE_SUPPORT_THREADING != 0
#ifndef BOOST_SPIRIT_THREADSAFE
#define BOOST_SPIRIT_THREADSAFE
#endif
#define PHOENIX_THREADSAFE 1
#else
// disable thread support in Boost.Pool
@@ -194,18 +196,17 @@
#endif
///////////////////////////////////////////////////////////////////////////////
// Define the string type to be used to store the token values and the file
// Define the string type to be used to store the token values and the file
// names inside a file_position template class
//
#if !defined(BOOST_WAVE_STRINGTYPE)
// VC7 isn't able to compile the flex_string class, fall back to std::string
// VC7 isn't able to compile the flex_string class, fall back to std::string
// CW up to 8.3 chokes as well *sigh*
// Tru64/CXX has linker problems when using flex_string
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) || \
BOOST_WORKAROUND(__MWERKS__, < 0x3200) || \
#if BOOST_WORKAROUND(__MWERKS__, < 0x3200) || \
(defined(__DECCXX) && defined(__alpha)) || \
defined(BOOST_WAVE_STRINGTYPE_USE_STDSTRING)
defined(BOOST_WAVE_STRINGTYPE_USE_STDSTRING)
#define BOOST_WAVE_STRINGTYPE std::string
@@ -223,12 +224,12 @@
> \
> \
/**/
// This include is needed for the flex_string class used in the
// This include is needed for the flex_string class used in the
// BOOST_WAVE_STRINGTYPE above.
#include <boost/wave/util/flex_string.hpp>
#endif // BOOST_WORKAROUND(_MSC_VER, <= 1300) et.al.
#endif // BOOST_WORKAROUND(__MWERKS__, < 0x3200) et.al.
#endif // !defined(BOOST_WAVE_STRINGTYPE)
///////////////////////////////////////////////////////////////////////////////
@@ -237,13 +238,13 @@
// #define BOOST_SPIRIT_USE_LIST_FOR_TREES
///////////////////////////////////////////////////////////////////////////////
// The following definition forces the Spirit tree code to use boost pool
// The following definition forces the Spirit tree code to use boost pool
// allocators instead of the std::allocator for the vector/list's.
// #define BOOST_SPIRIT_USE_BOOST_ALLOCATOR_FOR_TREES
///////////////////////////////////////////////////////////////////////////////
// Uncomment the following, if you need debug output, the
// BOOST_SPIRIT_DEBUG_FLAGS_CPP constants below help to fine control the
// Uncomment the following, if you need debug output, the
// BOOST_SPIRIT_DEBUG_FLAGS_CPP constants below help to fine control the
// amount of the generated debug output.
//#define BOOST_SPIRIT_DEBUG
@@ -262,16 +263,16 @@
#if !defined(BOOST_SPIRIT_DEBUG_FLAGS_CPP)
#define BOOST_SPIRIT_DEBUG_FLAGS_CPP 0 // default is no debugging
#endif
#endif
///////////////////////////////////////////////////////////////////////////////
//
// For all recognized preprocessor statements the output parse trees
// formatted as xml are printed. The formatted parse trees are streamed to the
// For all recognized preprocessor statements the output parse trees
// formatted as xml are printed. The formatted parse trees are streamed to the
// std::ostream defined by the WAVE_DUMP_PARSE_TREE_OUT constant.
//
// To enable the output of these parse trees, define the following constant
// as zero something not equal to zero before including this file.
// To enable the output of these parse trees, define the following constant
// as zero something not equal to zero before including this file.
//
#if !defined(BOOST_WAVE_DUMP_PARSE_TREE)
#define BOOST_WAVE_DUMP_PARSE_TREE 0
@@ -283,10 +284,10 @@
///////////////////////////////////////////////////////////////////////////////
//
// For all #if and #elif directives the preprocessed expressions are printed.
// These expressions are streamed to the std::ostream defined by the
// These expressions are streamed to the std::ostream defined by the
// BOOST_WAVE_DUMP_CONDITIONAL_EXPRESSIONS_OUT constant.
//
// To enable the output of the preprocessed expressions, define the following
// To enable the output of the preprocessed expressions, define the following
// constant as something not equal to zero before including this file.
//
#if !defined(BOOST_WAVE_DUMP_CONDITIONAL_EXPRESSIONS)
@@ -298,14 +299,14 @@
#endif
///////////////////////////////////////////////////////////////////////////////
// Decide, whether to use the separate compilation model for the instantiation
// Decide, whether to use the separate compilation model for the instantiation
// of the C++ lexer objects.
//
// If this is defined, you should explicitly instantiate the C++ lexer
// template with the correct parameters in a separate compilation unit of
// your program (see the file instantiate_re2c_lexer.cpp).
// your program (see the file instantiate_re2c_lexer.cpp).
//
// To use the lexer inclusion model, define the following constant as
// To use the lexer inclusion model, define the following constant as
// something not equal to zero before including this file.
//
#if !defined(BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION)
@@ -313,14 +314,14 @@
#endif
///////////////////////////////////////////////////////////////////////////////
// Decide, whether to use the separate compilation model for the instantiation
// Decide, whether to use the separate compilation model for the instantiation
// of the grammar objects.
//
// If this is defined, you should explicitly instantiate the grammar
// templates with the correct parameters in a separate compilation unit of
// your program (see the files instantiate_cpp_grammar.cpp et.al.).
// your program (see the files instantiate_cpp_grammar.cpp et.al.).
//
// To use the grammar inclusion model, define the following constant as
// To use the grammar inclusion model, define the following constant as
// something not equal to zero before including this file.
//
#if !defined(BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION)
@@ -329,9 +330,9 @@
///////////////////////////////////////////////////////////////////////////////
// Decide whether to use a strict C++ lexer.
//
// If this is defined to something != 0, then the C++ lexers recognize the
// strict C99/C++ basic source character set. If it is not defined or defined
//
// If this is defined to something != 0, then the C++ lexers recognize the
// strict C99/C++ basic source character set. If it is not defined or defined
// to zero, the C++ lexers recognize the '$' character as part of identifiers.
//
// The default is to recognize the '$' character as part of identifiers.
@@ -341,14 +342,14 @@
#endif
///////////////////////////////////////////////////////////////////////////////
// Decide, whether the serialization of the wave::context class should be
// Decide, whether the serialization of the wave::context class should be
// supported
//
// If this is defined to something not equal to zero the generated code will
// expose routines allowing to store and reload the internal state of the
// expose routines allowing to store and reload the internal state of the
// wave::context object.
//
// To enable the availability of the serialization functionality, define the
// To enable the availability of the serialization functionality, define the
// following constant as something not equal to zero before including this file.
//
#if !defined(BOOST_WAVE_SERIALIZATION)
@@ -368,19 +369,19 @@
///////////////////////////////////////////////////////////////////////////////
// Decide, whether to support long long integers in the preprocessor.
//
// The C++ standard requires the preprocessor to use one of the following
// types for integer literals: long or unsigned long depending on an optional
// The C++ standard requires the preprocessor to use one of the following
// types for integer literals: long or unsigned long depending on an optional
// suffix ('u', 'l', 'ul', or 'lu')
//
// Sometimes it's required to preprocess integer literals bigger than that
// (i.e. long long or unsigned long long). In this case you need to define the
// (i.e. long long or unsigned long long). In this case you need to define the
// BOOST_WAVE_SUPPORT_LONGLONG_INTEGER_LITERALS to something not equal to zero.
//
// This pp constant is effective only, if your target platform supports
// This pp constant is effective only, if your target platform supports
// long long integers (BOOST_HAS_LONG_LONG is defined).
//
// Please note, that this setting doesn't relate to the Wave support option
// support_option_long_long, which enables the recognition of 'll' suffixes
// support_option_long_long, which enables the recognition of 'll' suffixes
// only.
//
// Defining this pp constant enables the recognition of long long integers
@@ -390,7 +391,7 @@
#define BOOST_WAVE_SUPPORT_LONGLONG_INTEGER_LITERALS 0
#endif
namespace boost { namespace wave
namespace boost { namespace wave
{
#if defined(BOOST_HAS_LONG_LONG) && \
BOOST_WAVE_SUPPORT_LONGLONG_INTEGER_LITERALS != 0
@@ -404,7 +405,7 @@ namespace boost { namespace wave
///////////////////////////////////////////////////////////////////////////////
// On some platforms Wave will not be able to properly detect whether wchar_t
// is representing a signed or unsigned integral data type. Use the
// is representing a signed or unsigned integral data type. Use the
// configuration constants below to force wchar_t being signed or unsigned, as
// appropriate.
//
@@ -424,7 +425,7 @@ namespace boost { namespace wave
#define PHOENIX_LIMIT 6
#endif
#if PHOENIX_LIMIT < 6
// boost/home/classic/spirit/classic_attribute.hpp sets PHOENIX_LIMIT to 3!
// boost/home/classic/spirit/classic_attribute.hpp sets PHOENIX_LIMIT to 3!
#error "Boost.Wave: the constant PHOENIX_LIMIT must be at least defined to 6" \
" to compile the library."
#endif
@@ -433,12 +434,12 @@ namespace boost { namespace wave
// Set up dll import/export options
#if (defined(BOOST_WAVE_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && \
!defined(BOOST_WAVE_STATIC_LINK)
#if defined(BOOST_WAVE_SOURCE)
#define BOOST_WAVE_DECL BOOST_SYMBOL_EXPORT
#define BOOST_WAVE_DECL BOOST_SYMBOL_EXPORT
#define BOOST_WAVE_BUILD_DLL
#else
#define BOOST_WAVE_DECL BOOST_SYMBOL_IMPORT
#define BOOST_WAVE_DECL BOOST_SYMBOL_IMPORT
#endif
#endif // building a shared library
@@ -449,7 +450,7 @@ namespace boost { namespace wave
///////////////////////////////////////////////////////////////////////////////
// Auto library naming
#if BOOST_VERSION >= 103100
#if BOOST_VERSION >= 103100
// auto link features work beginning from Boost V1.31.0
#if !defined(BOOST_WAVE_SOURCE) && !defined(BOOST_ALL_NO_LIB) && \
!defined(BOOST_WAVE_NO_LIB)
@@ -467,15 +468,15 @@ namespace boost { namespace wave
#endif // BOOST_VERSION
///////////////////////////////////////////////////////////////////////////////
// Compatibility macros
// Compatibility macros
// (ensure interface compatibility to older Wave versions)
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// The preprocessing hook signatures changed after the Boost V1.34.0 release
//
// To use the preprocessing hook signatures as released with Boost V1.34.0
// you need to define the BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS
// To use the preprocessing hook signatures as released with Boost V1.34.0
// you need to define the BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS
// constant to something not equal zero.
//
// To force using the new interface define this constant to zero.

View File

@@ -1,7 +1,7 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Persistent application configuration
http://www.boost.org/
Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
@@ -74,9 +74,9 @@ namespace boost { namespace wave {
///////////////////////////////////////////////////////////////////////////
// Call this function to test the configuration of the calling application
// against the configuration of the linked library.
BOOST_WAVE_DECL bool test_configuration(unsigned int config,
BOOST_WAVE_DECL bool test_configuration(unsigned int config,
char const* pragma_keyword, char const* string_type);
///////////////////////////////////////////////////////////////////////////////
}} // namespace boost::wave
@@ -87,5 +87,5 @@ namespace boost { namespace wave {
BOOST_PP_STRINGIZE((BOOST_WAVE_STRINGTYPE)) \
) \
/**/
#endif // !BOOST_WAVE_CONFIG_CONSTANT_HPP

View File

@@ -1,20 +1,20 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Whitespace eater
http://www.boost.org/
Copyright (c) 2003 Paul Mensonides
Copyright (c) 2001-2012 Hartmut Kaiser.
Distributed under the Boost Software License, Version 1.0. (See accompanying
Copyright (c) 2001-2012 Hartmut Kaiser.
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(WHITESPACE_HANDLING_HPP_INCLUDED)
#define WHITESPACE_HANDLING_HPP_INCLUDED
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/preprocessing_hooks.hpp>
#include <boost/wave/language_support.hpp>
@@ -30,7 +30,7 @@ namespace context_policies {
namespace util {
///////////////////////////////////////////////////////////////////////////
// This function returns true if the given C style comment contains at
// This function returns true if the given C style comment contains at
// least one newline
template <typename TokenT>
bool ccomment_has_newline(TokenT const& token)
@@ -46,8 +46,8 @@ namespace util {
}
///////////////////////////////////////////////////////////////////////////
// This function returns the number of newlines in the given C style
// comment
// This function returns the number of newlines in the given C style
// comment
template <typename TokenT>
int ccomment_count_newlines(TokenT const& token)
{
@@ -60,14 +60,14 @@ namespace util {
while (TokenT::string_type::npos != p) {
++newlines;
p = value.find_first_of("\n", p+1);
}
}
}
return newlines;
}
#if BOOST_WAVE_SUPPORT_CPP0X != 0
///////////////////////////////////////////////////////////////////////////
// This function returns the number of newlines in the given C++11 style
// This function returns the number of newlines in the given C++11 style
// raw string
template <typename TokenT>
int rawstring_count_newlines(TokenT const& token)
@@ -81,7 +81,7 @@ namespace util {
while (TokenT::string_type::npos != p) {
++newlines;
p = value.find_first_of("\n", p+1);
}
}
}
return newlines;
}
@@ -90,17 +90,17 @@ namespace util {
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
class eat_whitespace
class eat_whitespace
: public default_preprocessing_hooks
{
public:
eat_whitespace();
template <typename ContextT>
bool may_skip_whitespace(ContextT const& ctx, TokenT &token,
bool may_skip_whitespace(ContextT const& ctx, TokenT &token,
bool &skipped_newline);
template <typename ContextT>
bool may_skip_whitespace(ContextT const& ctx, TokenT &token,
bool may_skip_whitespace(ContextT const& ctx, TokenT &token,
bool preserve_comments_, bool preserve_bol_whitespace_,
bool &skipped_newline);
@@ -119,7 +119,7 @@ private:
};
template <typename TokenT>
inline
inline
eat_whitespace<TokenT>::eat_whitespace()
: state(&eat_whitespace::newline), preserve_comments(false),
preserve_bol_whitespace(false)
@@ -128,9 +128,9 @@ eat_whitespace<TokenT>::eat_whitespace()
template <typename TokenT>
template <typename ContextT>
inline bool
eat_whitespace<TokenT>::may_skip_whitespace(ContextT const& ctx, TokenT &token,
bool &skipped_newline)
inline bool
eat_whitespace<TokenT>::may_skip_whitespace(ContextT const& ctx, TokenT &token,
bool &skipped_newline)
{
// re-initialize the preserve comments state
preserve_comments = boost::wave::need_preserve_comments(ctx.get_language());
@@ -139,10 +139,10 @@ eat_whitespace<TokenT>::may_skip_whitespace(ContextT const& ctx, TokenT &token,
template <typename TokenT>
template <typename ContextT>
inline bool
eat_whitespace<TokenT>::may_skip_whitespace(ContextT const& ctx, TokenT &token,
inline bool
eat_whitespace<TokenT>::may_skip_whitespace(ContextT const& ctx, TokenT &token,
bool preserve_comments_, bool preserve_bol_whitespace_,
bool &skipped_newline)
bool &skipped_newline)
{
// re-initialize the preserve comments state
preserve_comments = preserve_comments_;
@@ -151,8 +151,8 @@ eat_whitespace<TokenT>::may_skip_whitespace(ContextT const& ctx, TokenT &token,
}
template <typename TokenT>
inline bool
eat_whitespace<TokenT>::general(TokenT &token, bool &skipped_newline)
inline bool
eat_whitespace<TokenT>::general(TokenT &token, bool &skipped_newline)
{
using namespace boost::wave;
@@ -163,10 +163,10 @@ eat_whitespace<TokenT>::general(TokenT &token, bool &skipped_newline)
else if (T_SPACE == id || T_SPACE2 == id || T_CCOMMENT == id) {
state = &eat_whitespace::whitespace;
if (util::ccomment_has_newline(token))
if (util::ccomment_has_newline(token))
skipped_newline = true;
if ((!preserve_comments || T_CCOMMENT != id) &&
if ((!preserve_comments || T_CCOMMENT != id) &&
token.get_value().size() > 1)
{
token.set_value(" "); // replace with a single space
@@ -179,8 +179,8 @@ eat_whitespace<TokenT>::general(TokenT &token, bool &skipped_newline)
}
template <typename TokenT>
inline bool
eat_whitespace<TokenT>::newline(TokenT &token, bool &skipped_newline)
inline bool
eat_whitespace<TokenT>::newline(TokenT &token, bool &skipped_newline)
{
using namespace boost::wave;
@@ -191,7 +191,7 @@ eat_whitespace<TokenT>::newline(TokenT &token, bool &skipped_newline)
return T_NEWLINE == id || skip_cppcomment(id);
}
if (T_SPACE != id && T_SPACE2 != id && T_CCOMMENT != id)
if (T_SPACE != id && T_SPACE2 != id && T_CCOMMENT != id)
return general(token, skipped_newline);
if (T_CCOMMENT == id) {
@@ -215,8 +215,8 @@ eat_whitespace<TokenT>::newline(TokenT &token, bool &skipped_newline)
}
template <typename TokenT>
inline bool
eat_whitespace<TokenT>::newline_2nd(TokenT &token, bool &skipped_newline)
inline bool
eat_whitespace<TokenT>::newline_2nd(TokenT &token, bool &skipped_newline)
{
using namespace boost::wave;
@@ -240,7 +240,7 @@ eat_whitespace<TokenT>::newline_2nd(TokenT &token, bool &skipped_newline)
return true;
}
if (T_NEWLINE != id && T_CPPCOMMENT != id)
if (T_NEWLINE != id && T_CPPCOMMENT != id)
return general(token, skipped_newline);
skipped_newline = true;
@@ -248,27 +248,27 @@ eat_whitespace<TokenT>::newline_2nd(TokenT &token, bool &skipped_newline)
}
template <typename TokenT>
inline bool
eat_whitespace<TokenT>::bol_whitespace(TokenT &token, bool &skipped_newline)
inline bool
eat_whitespace<TokenT>::bol_whitespace(TokenT &token, bool &skipped_newline)
{
using namespace boost::wave;
token_id id = token_id(token);
if (T_SPACE == id || T_SPACE2 == id)
if (T_SPACE == id || T_SPACE2 == id)
return !preserve_bol_whitespace;
return general(token, skipped_newline);
}
template <typename TokenT>
inline bool
eat_whitespace<TokenT>::whitespace(TokenT &token, bool &skipped_newline)
inline bool
eat_whitespace<TokenT>::whitespace(TokenT &token, bool &skipped_newline)
{
using namespace boost::wave;
token_id id = token_id(token);
if (T_SPACE != id && T_SPACE2 != id &&
T_CCOMMENT != id && T_CPPCOMMENT != id)
if (T_SPACE != id && T_SPACE2 != id &&
T_CCOMMENT != id && T_CPPCOMMENT != id)
{
return general(token, skipped_newline);
}