From aa24ef4c9874f7d1d281268546c1172bf7c34b29 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Sun, 7 Aug 2011 01:27:31 +0000 Subject: [PATCH] Wave: adding support_option_emit_contnewlines for the SLex lexer only. [SVN r73589] --- ChangeLog | 8 ++++++++ doc/class_reference_context.html | 6 ++++-- include/boost/wave/language_support.hpp | 6 ++++-- index.html | 4 ++-- samples/cpp_tokens/cpp_tokens.cpp | 1 + samples/cpp_tokens/slex/cpp_slex_lexer.hpp | 10 ++++++---- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0553986e6..db5e12e10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,14 @@ TODO (known issues): CHANGELOG +Boost V1.48.0 + - V2.3.1 + - Added the flag support_option_emit_contnewlines allowing to control whether + backslash newline sequences are emitted by the Wave library. The default is + as before: these tokens will be silently ignored (after the token positions + have been properly updated). Note: this option is supported by the SLex lexer + module only. + Boost V1.47.0 - V2.3.0 - After preprocessing the body of any #pragma wave option() the wave tool now diff --git a/doc/class_reference_context.html b/doc/class_reference_context.html index e4c92e081..e1d320341 100644 --- a/doc/class_reference_context.html +++ b/doc/class_reference_context.html @@ -381,7 +381,8 @@

Control extended options

This functions allows to specify the language mode, in which the Wave library should work. The possible language modes are defined by the enumerated type language_support:

-
    enum language_support {
// support flags for C++98
support_normal = 0x01,
support_cpp = support_normal,

// support flags for C99

support_option_long_long = 0x02,
support_option_variadics = 0x04,
support_c99 = support_option_variadics | support_option_long_long | 0x08,

// the mask for the main language settings

support_option_mask = 0xFF80,

// additional fine tuning of the general behavior
support_option_insert_whitespace = 0x0080,
support_option_preserve_comments = 0x0100,
support_option_no_character_validation = 0x0200,
support_option_convert_trigraphs = 0x0400,
support_option_single_line = 0x0800,
support_option_prefer_pp_numbers = 0x1000,
support_option_emit_line_directives = 0x2000,
support_option_include_guard_detection = 0x4000,
support_option_emit_pragma_directives = 0x8000
};
+
    enum language_support {
// support flags for C++98
support_normal = 0x01,
support_cpp = support_normal,

// support flags for C99

support_option_long_long = 0x02,
support_option_variadics = 0x04,
support_c99 = support_option_variadics | support_option_long_long | 0x08,

// the mask for the main language settings

support_option_mask = 0xFFB0,

// additional fine tuning of the general behavior + support_option_emit_contline = 0x0040,
support_option_insert_whitespace = 0x0080,
support_option_preserve_comments = 0x0100,
support_option_no_character_validation = 0x0200,
support_option_convert_trigraphs = 0x0400,
support_option_single_line = 0x0800,
support_option_prefer_pp_numbers = 0x1000,
support_option_emit_line_directives = 0x2000,
support_option_include_guard_detection = 0x4000,
support_option_emit_pragma_directives = 0x8000
};

When used with support_option_variadics the support for variadics, placemarkers and the operator _Pragma() is enabled in normal C++ mode. When used with the support_option_long_long the support for long long suffixes is enabled in C++ mode.

The support_c99 switches on the C99 language support, which enables variadics, placemarkers, the operator _Pragma and long long suffixes by default. Additionally it disables the C++ @@ -444,6 +445,7 @@

Control extended options

the BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES is defined during compilation to a value not equal to zero (see here for more information). +
  • If the support_option_emit_contlines flag is set, the Wave library will emit all backslash newline sequences encountered in the input. It will generate a T_CONTLINE token for each of those character sequences. Please note that this option is supported by the custom SLex lexer module only. See the cpp_tokens example for a working example.
  • If the parameter reset_macros is true the set_language function internally resets the list of defined macros, so please be careful not to call it @@ -476,7 +478,7 @@

    Control extended options

     

    diff --git a/include/boost/wave/language_support.hpp b/include/boost/wave/language_support.hpp index 7e0c60e06..f4e599894 100644 --- a/include/boost/wave/language_support.hpp +++ b/include/boost/wave/language_support.hpp @@ -26,7 +26,7 @@ enum language_support { // support flags for C++98 support_normal = 0x01, support_cpp = support_normal, - + support_option_long_long = 0x02, #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 @@ -38,7 +38,8 @@ enum language_support { support_cpp0x = support_option_variadics | support_option_long_long | 0x10, #endif - support_option_mask = 0xFF80, + support_option_mask = 0xFFB0, + support_option_emit_contnewlines = 0x0040, support_option_insert_whitespace = 0x0080, support_option_preserve_comments = 0x0100, support_option_no_character_validation = 0x0200, @@ -196,6 +197,7 @@ BOOST_WAVE_OPTION(variadics) // support_option_variadics 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 #undef BOOST_WAVE_NEED_OPTION #undef BOOST_WAVE_ENABLE_OPTION diff --git a/index.html b/index.html index 1f87feab3..7a3fa315d 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@   - Wave V2.0 + Wave V2.3 @@ -100,7 +100,7 @@ http://www.boost.org/LICENSE_1_0.txt)

    diff --git a/samples/cpp_tokens/cpp_tokens.cpp b/samples/cpp_tokens/cpp_tokens.cpp index bab5ad91b..7ee3eaf71 100644 --- a/samples/cpp_tokens/cpp_tokens.cpp +++ b/samples/cpp_tokens/cpp_tokens.cpp @@ -94,6 +94,7 @@ main(int argc, char *argv[]) ctx.set_language(boost::wave::support_cpp0x); ctx.set_language(boost::wave::enable_preserve_comments(ctx.get_language())); ctx.set_language(boost::wave::enable_prefer_pp_numbers(ctx.get_language())); + ctx.set_language(boost::wave::enable_emit_contnewlines(ctx.get_language())); context_type::iterator_type first = ctx.begin(); context_type::iterator_type last = ctx.end(); diff --git a/samples/cpp_tokens/slex/cpp_slex_lexer.hpp b/samples/cpp_tokens/slex/cpp_slex_lexer.hpp index f07c073e5..170863c68 100644 --- a/samples/cpp_tokens/slex/cpp_slex_lexer.hpp +++ b/samples/cpp_tokens/slex/cpp_slex_lexer.hpp @@ -637,8 +637,10 @@ class slex_functor id = T_EOF; // end of input reached string_type token_val(value.c_str()); - - if (T_CONTLINE != id) { + + if (boost::wave::need_emit_contnewlines(language) || + T_CONTLINE != id) + { // The cast should avoid spurious warnings about missing case labels // for the other token ids's. switch (static_cast(id)) { @@ -673,7 +675,7 @@ class slex_functor pos.get_line(), pos.get_column(), pos.get_file()); } break; - + case T_LONGINTLIT: // supported in C99 and long_long mode if (!boost::wave::need_long_long(language)) { // syntax error: not allowed in C++ mode @@ -706,7 +708,7 @@ class slex_functor at_eof = true; token_val.clear(); break; - + case T_OR_TRIGRAPH: case T_XOR_TRIGRAPH: case T_LEFTBRACE_TRIGRAPH: