mirror of
https://github.com/boostorg/wave.git
synced 2026-07-21 13:43:40 +00:00
Introduce c++23 feature flag and condition size_t literals with it
This commit is contained in:
@@ -492,31 +492,35 @@ pp_number:
|
||||
/* this subscanner is called, whenever an Integer was recognized */
|
||||
integer_suffix:
|
||||
{
|
||||
if (s->enable_ms_extensions) {
|
||||
auto suffix_start = YYCURSOR;
|
||||
|
||||
/*!re2c
|
||||
LongIntegerSuffix | MSLongIntegerSuffix
|
||||
{ BOOST_WAVE_RET(T_LONGINTLIT); }
|
||||
LongIntegerSuffix
|
||||
{ BOOST_WAVE_RET(T_LONGINTLIT); }
|
||||
|
||||
SizeTSuffix
|
||||
{ BOOST_WAVE_RET(T_SIZETLIT); }
|
||||
|
||||
IntegerSuffix?
|
||||
{ BOOST_WAVE_RET(T_INTLIT); }
|
||||
*/
|
||||
MSLongIntegerSuffix {
|
||||
if (s->enable_ms_extensions) {
|
||||
BOOST_WAVE_RET(T_LONGINTLIT);
|
||||
} else {
|
||||
YYCURSOR = suffix_start;
|
||||
BOOST_WAVE_RET(T_INTLIT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*!re2c
|
||||
LongIntegerSuffix
|
||||
{ BOOST_WAVE_RET(T_LONGINTLIT); }
|
||||
|
||||
SizeTSuffix
|
||||
{ BOOST_WAVE_RET(T_SIZETLIT); }
|
||||
|
||||
IntegerSuffix?
|
||||
{ BOOST_WAVE_RET(T_INTLIT); }
|
||||
*/
|
||||
SizeTSuffix {
|
||||
if (s->act_in_cpp2b_mode) {
|
||||
BOOST_WAVE_RET(T_SIZETLIT);
|
||||
} else {
|
||||
YYCURSOR = suffix_start;
|
||||
BOOST_WAVE_RET(T_INTLIT);
|
||||
}
|
||||
}
|
||||
|
||||
IntegerSuffix?
|
||||
{ BOOST_WAVE_RET(T_INTLIT); }
|
||||
|
||||
*/
|
||||
|
||||
// re2c will complain about -Wmatch-empty-string above
|
||||
// it's OK because we've already matched an integer
|
||||
// and will return T_INTLIT
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -160,6 +160,17 @@ lexer<IteratorT, PositionT, TokenT>::lexer(IteratorT const &first,
|
||||
#else
|
||||
scanner.act_in_cpp2a_mode = false;
|
||||
#endif
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_CPP2B != 0
|
||||
scanner.act_in_cpp2b_mode = boost::wave::need_cpp2b(language_);
|
||||
scanner.act_in_cpp2a_mode = boost::wave::need_cpp2b(language_)
|
||||
|| boost::wave::need_cpp2a(language_);
|
||||
scanner.act_in_cpp0x_mode = boost::wave::need_cpp2b(language_)
|
||||
|| boost::wave::need_cpp2a(language_)
|
||||
|| boost::wave::need_cpp0x(language_);
|
||||
#else
|
||||
scanner.act_in_cpp2b_mode = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename IteratorT, typename PositionT, typename TokenT>
|
||||
|
||||
@@ -75,6 +75,7 @@ struct Scanner {
|
||||
bool single_line_only; /* don't report missing eol's in C++ comments */
|
||||
bool act_in_cpp0x_mode; /* lexer works in C++11 mode */
|
||||
bool act_in_cpp2a_mode; /* lexer works in C++20 mode */
|
||||
bool act_in_cpp2b_mode; /* lexer works in C++23 mode */
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -488,31 +488,35 @@ pp_number:
|
||||
/* this subscanner is called, whenever an Integer was recognized */
|
||||
integer_suffix:
|
||||
{
|
||||
if (s->enable_ms_extensions) {
|
||||
auto suffix_start = YYCURSOR;
|
||||
|
||||
/*!re2c
|
||||
LongIntegerSuffix | "i64"
|
||||
{ BOOST_WAVE_RET(T_LONGINTLIT); }
|
||||
LongIntegerSuffix
|
||||
{ BOOST_WAVE_RET(T_LONGINTLIT); }
|
||||
|
||||
SizeTSuffix
|
||||
{ BOOST_WAVE_RET(T_SIZETLIT); }
|
||||
|
||||
IntegerSuffix?
|
||||
{ BOOST_WAVE_RET(T_INTLIT); }
|
||||
*/
|
||||
"i64" {
|
||||
if (s->enable_ms_extensions) {
|
||||
BOOST_WAVE_RET(T_LONGINTLIT);
|
||||
} else {
|
||||
YYCURSOR = suffix_start;
|
||||
BOOST_WAVE_RET(T_INTLIT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*!re2c
|
||||
LongIntegerSuffix
|
||||
{ BOOST_WAVE_RET(T_LONGINTLIT); }
|
||||
|
||||
SizeTSuffix
|
||||
{ BOOST_WAVE_RET(T_SIZETLIT); }
|
||||
|
||||
IntegerSuffix?
|
||||
{ BOOST_WAVE_RET(T_INTLIT); }
|
||||
*/
|
||||
SizeTSuffix {
|
||||
if (s->act_in_cpp2b_mode) {
|
||||
BOOST_WAVE_RET(T_SIZETLIT);
|
||||
} else {
|
||||
YYCURSOR = suffix_start;
|
||||
BOOST_WAVE_RET(T_INTLIT);
|
||||
}
|
||||
}
|
||||
|
||||
IntegerSuffix?
|
||||
{ BOOST_WAVE_RET(T_INTLIT); }
|
||||
|
||||
*/
|
||||
|
||||
// re2c will complain about -Wmatch-empty-string above
|
||||
// it's OK because we've already matched an integer
|
||||
// and will return T_INTLIT
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -58,6 +58,15 @@ enum language_support {
|
||||
support_option_va_opt | 0x80000,
|
||||
support_cpp20 = support_cpp2a,
|
||||
#endif
|
||||
#if BOOST_WAVE_SUPPORT_CPP2B != 0
|
||||
// support flags for C++23
|
||||
support_option_sizet_lit = 0x100000,
|
||||
|
||||
support_cpp2b = support_option_variadics | support_option_long_long |
|
||||
support_option_no_newline_at_end_of_file | support_option_has_include |
|
||||
support_option_va_opt | support_option_sizet_lit | 0x200000,
|
||||
support_cpp23 = support_cpp2b,
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -137,6 +146,31 @@ need_cpp2a(language_support language)
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// need_cpp2b
|
||||
//
|
||||
// Extract if the language to support is C++23
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_WAVE_SUPPORT_CPP2B != 0
|
||||
|
||||
inline bool
|
||||
need_cpp2b(language_support language)
|
||||
{
|
||||
return (language & ~support_option_mask) == support_cpp2b;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline bool
|
||||
need_cpp2b(language_support language)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
@@ -142,6 +142,27 @@
|
||||
# define BOOST_WAVE_SUPPORT_VA_OPT 0
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Decide whether to support C++23
|
||||
//
|
||||
#if !defined(BOOST_WAVE_SUPPORT_CPP2B)
|
||||
# define BOOST_WAVE_SUPPORT_CPP2B 1
|
||||
# undef BOOST_WAVE_SUPPORT_CPP2A
|
||||
# define BOOST_WAVE_SUPPORT_CPP2A 1
|
||||
# undef BOOST_WAVE_SUPPORT_CPP0X
|
||||
# define BOOST_WAVE_SUPPORT_CPP0X 1
|
||||
# undef BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS
|
||||
# define BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS 1
|
||||
# undef BOOST_WAVE_SUPPORT_CPP1Z
|
||||
# define BOOST_WAVE_SUPPORT_CPP1Z 1
|
||||
# if !defined(BOOST_WAVE_SUPPORT_HAS_INCLUDE)
|
||||
# define BOOST_WAVE_SUPPORT_HAS_INCLUDE 1
|
||||
# endif
|
||||
# if !defined(BOOST_WAVE_SUPPORT_VA_OPT)
|
||||
# define BOOST_WAVE_SUPPORT_VA_OPT 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Undefine the following, to enable some MS specific language extensions:
|
||||
// __int8, __int16, __int32, __int64, __based, __declspec, __cdecl,
|
||||
|
||||
@@ -568,7 +568,7 @@ lexer<IteratorT, PositionT>::init_dfa(boost::wave::language_support lang)
|
||||
|
||||
// if in C++0x mode, add appropriate keywords
|
||||
#if BOOST_WAVE_SUPPORT_CPP0X != 0
|
||||
if (boost::wave::need_cpp0x(lang) || boost::wave::need_cpp2a(lang)) {
|
||||
if (boost::wave::need_cpp0x(lang) || boost::wave::need_cpp2a(lang) || boost::wave::need_cpp2b(lang)) {
|
||||
for (int j = 0; 0 != init_data_cpp0x[j].tokenid; ++j) {
|
||||
this->register_regex(init_data_cpp0x[j].tokenregex,
|
||||
init_data_cpp0x[j].tokenid, init_data_cpp0x[j].tokencb,
|
||||
@@ -577,14 +577,14 @@ lexer<IteratorT, PositionT>::init_dfa(boost::wave::language_support lang)
|
||||
}
|
||||
#endif
|
||||
|
||||
// if in C++2a mode, add those keywords
|
||||
// if in C++2a mode, add those keywords
|
||||
#if BOOST_WAVE_SUPPORT_CPP2A != 0
|
||||
if (wave::need_cpp2a(lang)) {
|
||||
for (int j = 0; 0 != init_data_cpp2a[j].tokenid; ++j) {
|
||||
this->register_regex(init_data_cpp2a[j].tokenregex,
|
||||
init_data_cpp2a[j].tokenid,
|
||||
init_data_cpp2a[j].tokencb,
|
||||
init_data_cpp2a[j].lexerstate);
|
||||
if (wave::need_cpp2a(lang) || wave::need_cpp2b(lang)) {
|
||||
for (int j = 0; 0 != init_data_cpp2a[j].tokenid; ++j) {
|
||||
this->register_regex(init_data_cpp2a[j].tokenregex,
|
||||
init_data_cpp2a[j].tokenid,
|
||||
init_data_cpp2a[j].tokencb,
|
||||
init_data_cpp2a[j].lexerstate);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -524,7 +524,7 @@ std::ifstream dfa_in("wave_lexertl_lexer.dfa", std::ios::in|std::ios::binary);
|
||||
|
||||
// if in C++0x mode, add appropriate keywords
|
||||
#if BOOST_WAVE_SUPPORT_CPP0X != 0
|
||||
if (wave::need_cpp0x(lang) || wave::need_cpp2a(lang)) {
|
||||
if (wave::need_cpp0x(lang) || wave::need_cpp2a(lang) || wave::need_cpp2b(lang)) {
|
||||
for (int j = 0; 0 != init_data_cpp0x[j].tokenid; ++j) {
|
||||
rules.add(init_data_cpp0x[j].tokenregex,
|
||||
init_data_cpp0x[j].tokenid);
|
||||
@@ -534,7 +534,7 @@ std::ifstream dfa_in("wave_lexertl_lexer.dfa", std::ios::in|std::ios::binary);
|
||||
|
||||
// if in C++2a mode, add those keywords
|
||||
#if BOOST_WAVE_SUPPORT_CPP2A != 0
|
||||
if (wave::need_cpp2a(lang)) {
|
||||
if (wave::need_cpp2a(lang) || wave::need_cpp2b(lang)) {
|
||||
for (int j = 0; 0 != init_data_cpp2a[j].tokenid; ++j) {
|
||||
rules.add(init_data_cpp2a[j].tokenregex,
|
||||
init_data_cpp2a[j].tokenid);
|
||||
|
||||
@@ -506,7 +506,7 @@ lexer<Iterator, Position>::lexer(Iterator const &first,
|
||||
}
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_CPP0X != 0
|
||||
if (boost::wave::need_cpp0x(language) || boost::wave::need_cpp2a(language)) {
|
||||
if (boost::wave::need_cpp0x(language) || boost::wave::need_cpp2a(language) || boost::wave::need_cpp2b(language)) {
|
||||
for (int j = 0; 0 != init_data_cpp0x[j].tokenid; ++j) {
|
||||
xlexer.register_regex(init_data_cpp0x[j].tokenregex,
|
||||
init_data_cpp0x[j].tokenid, init_data_cpp[j].tokencb);
|
||||
@@ -515,7 +515,7 @@ lexer<Iterator, Position>::lexer(Iterator const &first,
|
||||
#endif
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_CPP2A != 0
|
||||
if (boost::wave::need_cpp2a(language) || boost::wave::need_cpp2a(language)) {
|
||||
if (boost::wave::need_cpp2a(language) || boost::wave::need_cpp2b(language)) {
|
||||
for (int j = 0; 0 != init_data_cpp2a[j].tokenid; ++j) {
|
||||
xlexer.register_regex(init_data_cpp2a[j].tokenregex,
|
||||
init_data_cpp2a[j].tokenid, init_data_cpp[j].tokencb);
|
||||
|
||||
@@ -50,7 +50,7 @@ main(int argc, char *argv[])
|
||||
token_type::string_type instr(data->token);
|
||||
|
||||
lexer_type it = lexer_type(instr.begin(), instr.end(), pos,
|
||||
boost::wave::support_cpp2a);
|
||||
boost::wave::support_cpp2b);
|
||||
lexer_type end = lexer_type();
|
||||
|
||||
// verify the correct outcome of the tokenization
|
||||
|
||||
@@ -56,7 +56,7 @@ main(int argc, char *argv[])
|
||||
token_type::string_type instr(data->token);
|
||||
|
||||
lexer_type it = lexer_type(instr.begin(), instr.end(), pos,
|
||||
boost::wave::support_cpp2a);
|
||||
boost::wave::support_cpp2b);
|
||||
lexer_type end = lexer_type();
|
||||
|
||||
// verify the correct outcome of the tokenization
|
||||
|
||||
@@ -59,7 +59,7 @@ main(int argc, char *argv[])
|
||||
token_type::string_type instr(data->token);
|
||||
|
||||
lexer_type it = lexer_type(instr.begin(), instr.end(), pos,
|
||||
boost::wave::support_cpp2a);
|
||||
boost::wave::support_cpp2b);
|
||||
lexer_type end = lexer_type();
|
||||
|
||||
// verify the correct outcome of the tokenization
|
||||
|
||||
@@ -57,7 +57,7 @@ main(int argc, char *argv[])
|
||||
token_type::string_type instr(data->token);
|
||||
|
||||
lexer_type it = lexer_type(instr.begin(), instr.end(), pos,
|
||||
boost::wave::support_cpp2a);
|
||||
boost::wave::support_cpp2b);
|
||||
lexer_type end = lexer_type();
|
||||
|
||||
// verify the correct outcome of the tokenisation
|
||||
|
||||
@@ -422,6 +422,9 @@ testwave_app::testwave_app(po::variables_map const& vm)
|
||||
#endif
|
||||
#if BOOST_WAVE_SUPPORT_CPP2A != 0
|
||||
("c++20", "enable C++20 mode (implies --variadics and --long_long, adds __has_include and __VA_OPT__)")
|
||||
#endif
|
||||
#if BOOST_WAVE_SUPPORT_CPP2B != 0
|
||||
("c++23", "enable C++23 mode (all C++20 features, plus size_t literals)")
|
||||
#endif
|
||||
("warning,W", po::value<std::vector<std::string> >()->composing(),
|
||||
"Warning settings.")
|
||||
@@ -1078,6 +1081,35 @@ testwave_app::initialise_options(Context& ctx, po::variables_map const& vm,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_CPP2B
|
||||
if (vm.count("c++23")) {
|
||||
ctx.set_language(
|
||||
boost::wave::language_support(
|
||||
boost::wave::support_cpp2b
|
||||
#if BOOST_WAVE_SUPPORT_HAS_INCLUDE != 0
|
||||
| boost::wave::support_option_has_include
|
||||
#endif
|
||||
#if BOOST_WAVE_SUPPORT_VA_OPT != 0
|
||||
| boost::wave::support_option_va_opt
|
||||
#endif
|
||||
| boost::wave::support_option_convert_trigraphs
|
||||
| boost::wave::support_option_long_long
|
||||
| boost::wave::support_option_emit_line_directives
|
||||
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
|
||||
| boost::wave::support_option_include_guard_detection
|
||||
#endif
|
||||
#if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0
|
||||
| boost::wave::support_option_emit_pragma_directives
|
||||
#endif
|
||||
| boost::wave::support_option_insert_whitespace
|
||||
));
|
||||
|
||||
if (9 == debuglevel) {
|
||||
std::cerr << "initialise_options: option: c++23" << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// enable long_long mode, if appropriate
|
||||
if (vm.count("long_long")) {
|
||||
if (9 == debuglevel) {
|
||||
|
||||
@@ -946,6 +946,31 @@ do_actual_work (std::string file_name, std::istream &instream,
|
||||
}
|
||||
#endif // BOOST_WAVE_SUPPORT_CPP2A != 0
|
||||
|
||||
#if BOOST_WAVE_SUPPORT_CPP2B != 0
|
||||
if (vm.count("c++23")) {
|
||||
ctx.set_language(
|
||||
boost::wave::language_support(
|
||||
boost::wave::support_cpp2b
|
||||
#if BOOST_WAVE_SUPPORT_HAS_INCLUDE != 0
|
||||
| boost::wave::support_option_has_include
|
||||
#endif
|
||||
#if BOOST_WAVE_SUPPORT_VA_OPT != 0
|
||||
| boost::wave::support_option_va_opt
|
||||
#endif
|
||||
| boost::wave::support_option_convert_trigraphs
|
||||
| boost::wave::support_option_long_long
|
||||
| boost::wave::support_option_emit_line_directives
|
||||
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
|
||||
| boost::wave::support_option_include_guard_detection
|
||||
#endif
|
||||
#if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0
|
||||
| boost::wave::support_option_emit_pragma_directives
|
||||
#endif
|
||||
| boost::wave::support_option_insert_whitespace
|
||||
));
|
||||
}
|
||||
#endif // BOOST_WAVE_SUPPORT_CPP2B != 0
|
||||
|
||||
// enable long long support, if appropriate
|
||||
if (vm.count("long_long")) {
|
||||
ctx.set_language(
|
||||
@@ -1380,6 +1405,9 @@ main (int argc, char *argv[])
|
||||
#endif
|
||||
#if BOOST_WAVE_SUPPORT_CPP2A != 0
|
||||
("c++20", "enable C++20 mode (implies --variadics and --long_long, adds __VA_OPT__)")
|
||||
#endif
|
||||
#if BOOST_WAVE_SUPPORT_CPP2B != 0
|
||||
("c++23", "enable C++23 mode (all C++20 features, plus size_t literals)")
|
||||
#endif
|
||||
("listincludes,l", po::value<std::string>(),
|
||||
"list names of included files to a file [arg] or to stdout [-]")
|
||||
|
||||
Reference in New Issue
Block a user