mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
c++: avoid using the obsolete names
* data/skeletons/c++.m4: Don't define obsolete identifiers in the case of glr2.cc. Let's not start with technical debt. * data/skeletons/glr2.cc, data/skeletons/lalr1.cc, * data/skeletons/variant.hh: Use token_kind_type, not token_type. * tests/c++.at, tests/local.at: Use value_type, not semantic_type.
This commit is contained in:
@@ -227,6 +227,8 @@ m4_define([b4_value_type_declare],
|
|||||||
# Define the public types: token, semantic value, location, and so forth.
|
# Define the public types: token, semantic value, location, and so forth.
|
||||||
# Depending on %define token_lex, may be output in the header or source file.
|
# Depending on %define token_lex, may be output in the header or source file.
|
||||||
m4_define([b4_public_types_declare],
|
m4_define([b4_public_types_declare],
|
||||||
|
[m4_if(b4_skeleton, ["glr2.cc"],
|
||||||
|
[b4_value_type_declare],
|
||||||
[[#ifdef ]b4_api_PREFIX[STYPE
|
[[#ifdef ]b4_api_PREFIX[STYPE
|
||||||
# ifdef __GNUC__
|
# ifdef __GNUC__
|
||||||
# pragma GCC message "bison: do not #define ]b4_api_PREFIX[STYPE in C++, use %define api.value.type"
|
# pragma GCC message "bison: do not #define ]b4_api_PREFIX[STYPE in C++, use %define api.value.type"
|
||||||
@@ -236,7 +238,8 @@ m4_define([b4_public_types_declare],
|
|||||||
]b4_value_type_declare[
|
]b4_value_type_declare[
|
||||||
#endif
|
#endif
|
||||||
/// Backward compatibility (Bison 3.8).
|
/// Backward compatibility (Bison 3.8).
|
||||||
typedef value_type semantic_type;]b4_locations_if([
|
typedef value_type semantic_type;
|
||||||
|
]])[]b4_locations_if([
|
||||||
/// Symbol locations.
|
/// Symbol locations.
|
||||||
typedef b4_percent_define_get([[api.location.type]],
|
typedef b4_percent_define_get([[api.location.type]],
|
||||||
[[location]]) location_type;])[
|
[[location]]) location_type;])[
|
||||||
@@ -262,16 +265,16 @@ m4_define([b4_public_types_declare],
|
|||||||
/// Token kinds.
|
/// Token kinds.
|
||||||
struct token
|
struct token
|
||||||
{
|
{
|
||||||
]b4_token_enums[
|
]b4_token_enums[]m4_if(b4_skeleton, ["glr2.cc"], [], [[
|
||||||
/// Backward compatibility alias (Bison 3.6).
|
/// Backward compatibility alias (Bison 3.6).
|
||||||
typedef token_kind_type yytokentype;
|
typedef token_kind_type yytokentype;]])[
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Token kind, as returned by yylex.
|
/// Token kind, as returned by yylex.
|
||||||
typedef token::yytokentype token_kind_type;
|
typedef token::token_kind_type token_kind_type;]m4_if(b4_skeleton, ["glr2.cc"], [], [[
|
||||||
|
|
||||||
/// Backward compatibility alias (Bison 3.6).
|
/// Backward compatibility alias (Bison 3.6).
|
||||||
typedef token_kind_type token_type;
|
typedef token_kind_type token_type;]])[
|
||||||
|
|
||||||
/// Symbol kinds.
|
/// Symbol kinds.
|
||||||
struct symbol_kind
|
struct symbol_kind
|
||||||
@@ -383,10 +386,10 @@ m4_define([b4_symbol_type_define],
|
|||||||
std::string name () const YY_NOEXCEPT
|
std::string name () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return ]b4_parser_class[::symbol_name (this->kind ());
|
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||||
}]])[
|
}]])[]m4_if(b4_skeleton, ["glr2.cc"], [], [[
|
||||||
|
|
||||||
/// Backward compatibility (Bison 3.6).
|
/// Backward compatibility (Bison 3.6).
|
||||||
symbol_kind_type type_get () const YY_NOEXCEPT;
|
symbol_kind_type type_get () const YY_NOEXCEPT;]])[
|
||||||
|
|
||||||
/// Whether empty.
|
/// Whether empty.
|
||||||
bool empty () const YY_NOEXCEPT;
|
bool empty () const YY_NOEXCEPT;
|
||||||
@@ -435,18 +438,18 @@ m4_define([b4_symbol_type_define],
|
|||||||
|
|
||||||
/// The (internal) type number (corresponding to \a type).
|
/// The (internal) type number (corresponding to \a type).
|
||||||
/// \a empty when empty.
|
/// \a empty when empty.
|
||||||
symbol_kind_type kind () const YY_NOEXCEPT;
|
symbol_kind_type kind () const YY_NOEXCEPT;]m4_if(b4_skeleton, ["glr2.cc"], [], [[
|
||||||
|
|
||||||
/// Backward compatibility (Bison 3.6).
|
/// Backward compatibility (Bison 3.6).
|
||||||
symbol_kind_type type_get () const YY_NOEXCEPT;
|
symbol_kind_type type_get () const YY_NOEXCEPT;]])[
|
||||||
|
|
||||||
/// The symbol kind.
|
/// The symbol kind.
|
||||||
/// \a ]b4_symbol_prefix[YYEMPTY when empty.
|
/// \a ]b4_symbol_prefix[YYEMPTY when empty.
|
||||||
symbol_kind_type kind_;
|
symbol_kind_type kind_;
|
||||||
};
|
};]m4_if(b4_skeleton, ["glr2.cc"], [], [[
|
||||||
|
|
||||||
/// Backward compatibility for a private implementation detail (Bison 3.6).
|
/// Backward compatibility for a private implementation detail (Bison 3.6).
|
||||||
typedef by_kind by_type;
|
typedef by_kind by_type;]])[
|
||||||
|
|
||||||
/// "External" symbols: returned by the scanner.
|
/// "External" symbols: returned by the scanner.
|
||||||
struct symbol_type : basic_symbol<by_kind>
|
struct symbol_type : basic_symbol<by_kind>
|
||||||
@@ -501,12 +504,14 @@ m4_define([b4_public_types_define],
|
|||||||
(void) v;
|
(void) v;
|
||||||
]b4_symbol_variant([this->kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
]b4_symbol_variant([this->kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
||||||
|
|
||||||
|
]m4_if(b4_skeleton, ["glr2.cc"], [], [[
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class[::symbol_kind_type
|
]b4_parser_class[::symbol_kind_type
|
||||||
]b4_parser_class[::basic_symbol<Base>::type_get () const YY_NOEXCEPT
|
]b4_parser_class[::basic_symbol<Base>::type_get () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return this->kind ();
|
return this->kind ();
|
||||||
}
|
}
|
||||||
|
]])[
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
bool
|
bool
|
||||||
@@ -566,11 +571,13 @@ m4_define([b4_public_types_define],
|
|||||||
return kind_;
|
return kind_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
]m4_if(b4_skeleton, ["glr2.cc"], [], [[
|
||||||
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
||||||
]b4_parser_class[::by_kind::type_get () const YY_NOEXCEPT
|
]b4_parser_class[::by_kind::type_get () const YY_NOEXCEPT
|
||||||
{
|
{
|
||||||
return this->kind ();
|
return this->kind ();
|
||||||
}
|
}
|
||||||
|
]])[
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ m4_define([b4_shared_declarations],
|
|||||||
public: // FIXME: Private
|
public: // FIXME: Private
|
||||||
/// Convert a scanner token kind \a t to a symbol kind.
|
/// Convert a scanner token kind \a t to a symbol kind.
|
||||||
/// In theory \a t should be a token_kind_type, but character literals
|
/// In theory \a t should be a token_kind_type, but character literals
|
||||||
/// are valid, yet not members of the token_type enum.
|
/// are valid, yet not members of the token_kind_type enum.
|
||||||
static symbol_kind_type yytranslate_ (int t);
|
static symbol_kind_type yytranslate_ (int t);
|
||||||
|
|
||||||
]b4_parse_error_bmatch(
|
]b4_parse_error_bmatch(
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ m4_define([b4_shared_declarations],
|
|||||||
|
|
||||||
/// Convert a scanner token kind \a t to a symbol kind.
|
/// Convert a scanner token kind \a t to a symbol kind.
|
||||||
/// In theory \a t should be a token_kind_type, but character literals
|
/// In theory \a t should be a token_kind_type, but character literals
|
||||||
/// are valid, yet not members of the token_type enum.
|
/// are valid, yet not members of the token_kind_type enum.
|
||||||
static symbol_kind_type yytranslate_ (int t);
|
static symbol_kind_type yytranslate_ (int t);
|
||||||
|
|
||||||
]b4_parse_error_bmatch(
|
]b4_parse_error_bmatch(
|
||||||
@@ -637,9 +637,9 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
|
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*---------------.
|
/*---------.
|
||||||
| symbol kinds. |
|
| symbol. |
|
||||||
`---------------*/
|
`---------*/
|
||||||
|
|
||||||
]b4_token_ctor_if([], [b4_public_types_define([cc])])[
|
]b4_token_ctor_if([], [b4_public_types_define([cc])])[
|
||||||
|
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ m4_define([_b4_symbol_constructor_define],
|
|||||||
b4_symbol_if([$1], [has_type],
|
b4_symbol_if([$1], [has_type],
|
||||||
[b4_symbol([$1], [type]) v]),
|
[b4_symbol([$1], [type]) v]),
|
||||||
b4_locations_if([location_type l]))[)
|
b4_locations_if([location_type l]))[)
|
||||||
: super_type (]b4_join([token_type (tok)],
|
: super_type (]b4_join([token_kind_type (tok)],
|
||||||
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||||
b4_locations_if([std::move (l)]))[)
|
b4_locations_if([std::move (l)]))[)
|
||||||
#else
|
#else
|
||||||
@@ -479,7 +479,7 @@ m4_define([_b4_symbol_constructor_define],
|
|||||||
b4_symbol_if([$1], [has_type],
|
b4_symbol_if([$1], [has_type],
|
||||||
[const b4_symbol([$1], [type])& v]),
|
[const b4_symbol([$1], [type])& v]),
|
||||||
b4_locations_if([const location_type& l]))[)
|
b4_locations_if([const location_type& l]))[)
|
||||||
: super_type (]b4_join([token_type (tok)],
|
: super_type (]b4_join([token_kind_type (tok)],
|
||||||
b4_symbol_if([$1], [has_type], [v]),
|
b4_symbol_if([$1], [has_type], [v]),
|
||||||
b4_locations_if([l]))[)
|
b4_locations_if([l]))[)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -969,7 +969,7 @@ AT_DATA_GRAMMAR([[input.yy]],
|
|||||||
%code
|
%code
|
||||||
{
|
{
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
int yylex (yy::parser::semantic_type *);
|
int yylex (yy::parser::value_type *);
|
||||||
}
|
}
|
||||||
|
|
||||||
%define parse.error verbose
|
%define parse.error verbose
|
||||||
@@ -1013,7 +1013,7 @@ AT_DATA_SOURCE([scan.cc],
|
|||||||
|
|
||||||
// 'a': valid item, 's': syntax error, 'l': lexical error.
|
// 'a': valid item, 's': syntax error, 'l': lexical error.
|
||||||
int
|
int
|
||||||
yylex (yy::parser::semantic_type *lval)
|
yylex (yy::parser::value_type *lval)
|
||||||
{
|
{
|
||||||
switch (int res = getchar ())
|
switch (int res = getchar ())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ m4_pushdef([AT_TOKEN],
|
|||||||
|
|
||||||
|
|
||||||
m4_pushdef([AT_YYSTYPE],
|
m4_pushdef([AT_YYSTYPE],
|
||||||
[AT_CXX_IF([AT_NAMESPACE[::]AT_PARSER_CLASS[::semantic_type]],
|
[AT_CXX_IF([AT_NAMESPACE[::]AT_PARSER_CLASS[::value_type]],
|
||||||
[AT_API_PREFIX[STYPE]])])
|
[AT_API_PREFIX[STYPE]])])
|
||||||
m4_pushdef([AT_YYLTYPE],
|
m4_pushdef([AT_YYLTYPE],
|
||||||
[AT_CXX_IF([AT_NAMESPACE[::]AT_PARSER_CLASS[::location_type]],
|
[AT_CXX_IF([AT_NAMESPACE[::]AT_PARSER_CLASS[::location_type]],
|
||||||
|
|||||||
Reference in New Issue
Block a user