mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
c++: rename semantic_type as value_type
We always refer to the triplet "kind, value, location". All of them are nouns, and we support api.value.type and api.location.type. On this regard, "semantic_type" was a poor choice. Make it "value_type". The test suite was not updated to use value_type, on purpose, to enforce backward compatibility. * data/skeletons/c++.m4, data/skeletons/glr.cc, data/skeletons/glr2.cc, * data/skeletons/variant.hh, doc/bison.texi: Define value_type rather than semantic_type. Add a backward compatibility typedef. * examples/c++/glr/c++-types.yy: Migrate.
This commit is contained in:
@@ -206,16 +206,16 @@ m4_define([b4_declare_symbol_enum],
|
||||
|
||||
# b4_value_type_declare
|
||||
# ---------------------
|
||||
# Declare semantic_type.
|
||||
# Declare value_type.
|
||||
m4_define([b4_value_type_declare],
|
||||
[b4_value_type_setup[]dnl
|
||||
[ /// Symbol semantic values.
|
||||
]m4_bmatch(b4_percent_define_get_kind([[api.value.type]]),
|
||||
[code],
|
||||
[[ typedef ]b4_percent_define_get([[api.value.type]])[ semantic_type;]],
|
||||
[[ typedef ]b4_percent_define_get([[api.value.type]])[ value_type;]],
|
||||
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
||||
[union\|union-directive],
|
||||
[[ union semantic_type
|
||||
[[ union value_type
|
||||
{
|
||||
]b4_user_union_members[
|
||||
};]])])dnl
|
||||
@@ -230,8 +230,10 @@ m4_define([b4_public_types_declare],
|
||||
[[#ifndef ]b4_api_PREFIX[STYPE
|
||||
]b4_value_type_declare[
|
||||
#else
|
||||
typedef ]b4_api_PREFIX[STYPE semantic_type;
|
||||
#endif]b4_locations_if([
|
||||
typedef ]b4_api_PREFIX[STYPE value_type;
|
||||
#endif
|
||||
/// Backward compatibility (Bison 3.8).
|
||||
typedef value_type semantic_type;]b4_locations_if([
|
||||
/// Symbol locations.
|
||||
typedef b4_percent_define_get([[api.location.type]],
|
||||
[[location]]) location_type;])[
|
||||
@@ -329,7 +331,7 @@ m4_define([b4_symbol_type_define],
|
||||
|
||||
/// Constructor for symbols with semantic value.
|
||||
basic_symbol (typename Base::kind_type t,
|
||||
YY_RVREF (semantic_type) v]b4_locations_if([,
|
||||
YY_RVREF (value_type) v]b4_locations_if([,
|
||||
YY_RVREF (location_type) l])[);
|
||||
]])[
|
||||
/// Destroy the symbol.
|
||||
@@ -390,7 +392,7 @@ m4_define([b4_symbol_type_define],
|
||||
void move (basic_symbol& s);
|
||||
|
||||
/// The semantic value.
|
||||
semantic_type value;]b4_locations_if([
|
||||
value_type value;]b4_locations_if([
|
||||
|
||||
/// The location.
|
||||
location_type location;])[
|
||||
@@ -487,7 +489,7 @@ m4_define([b4_public_types_define],
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
[YY_RVREF (semantic_type) v],
|
||||
[YY_RVREF (value_type) v],
|
||||
b4_locations_if([YY_RVREF (location_type) l]))[)
|
||||
: Base (t)
|
||||
, value (]b4_variant_if([], [YY_MOVE (v)])[)]b4_locations_if([
|
||||
|
||||
@@ -78,7 +78,7 @@ m4_define([b4_yy_symbol_print_define],
|
||||
|
||||
static void
|
||||
yy_symbol_print (FILE *, ]b4_namespace_ref::b4_parser_class[::symbol_kind_type yytoken,
|
||||
const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep]b4_locations_if([[,
|
||||
const ]b4_namespace_ref::b4_parser_class[::value_type *yyvaluep]b4_locations_if([[,
|
||||
const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
]b4_parse_param_use[]dnl
|
||||
@@ -154,7 +154,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const
|
||||
{]b4_locations_if([[
|
||||
YYUSE (yylocationp);]])[
|
||||
@@ -168,7 +168,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const
|
||||
{
|
||||
*yycdebug_ << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||
@@ -247,7 +247,7 @@ m4_define([b4_glr_cc_setup],
|
||||
#define ]b4_symbol(error, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(error, [id])[
|
||||
|
||||
#ifndef ]b4_api_PREFIX[STYPE
|
||||
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::semantic_type
|
||||
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::value_type
|
||||
#endif
|
||||
#ifndef ]b4_api_PREFIX[LTYPE
|
||||
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type
|
||||
@@ -355,14 +355,14 @@ b4_percent_code_get([[requires]])[
|
||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const;
|
||||
/// \brief Report a symbol on the debug stream.
|
||||
/// \param yykind The symbol kind.
|
||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const;
|
||||
private:
|
||||
/// Debug stream.
|
||||
|
||||
@@ -250,14 +250,14 @@ const std::ptrdiff_t strong_index_alias<T>::INVALID_INDEX =
|
||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const;
|
||||
/// \brief Report a symbol on the debug stream.
|
||||
/// \param yykind The symbol kind.
|
||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const;
|
||||
private:
|
||||
/// Debug stream.
|
||||
@@ -285,7 +285,7 @@ const std::ptrdiff_t strong_index_alias<T>::INVALID_INDEX =
|
||||
/// If null, print nothing.
|
||||
/// \param yykind The symbol kind.
|
||||
void yy_destroy_ (const char* yymsg, symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[);
|
||||
|
||||
]b4_parse_param_vars[
|
||||
@@ -434,7 +434,7 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
|
||||
[b4_shared_declarations])[
|
||||
|
||||
#ifndef ]b4_api_PREFIX[STYPE
|
||||
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::semantic_type
|
||||
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::value_type
|
||||
#endif
|
||||
#ifndef ]b4_api_PREFIX[LTYPE
|
||||
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type
|
||||
@@ -763,7 +763,7 @@ yyrhsLength (rule_num yyrule);
|
||||
class glr_state
|
||||
{
|
||||
public:
|
||||
typedef ]b4_namespace_ref[::]b4_parser_class[::semantic_type value_type;]b4_locations_if([[
|
||||
typedef ]b4_namespace_ref[::]b4_parser_class[::value_type value_type;]b4_locations_if([[
|
||||
typedef ]b4_namespace_ref[::]b4_parser_class[::location_type location_type;]])[
|
||||
|
||||
glr_state ()
|
||||
@@ -3238,7 +3238,7 @@ b4_dollar_popdef])[]dnl
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_destroy_ (const char* yymsg, symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[)
|
||||
{
|
||||
YYUSE (yyvaluep);]b4_locations_if([[
|
||||
@@ -3261,7 +3261,7 @@ b4_dollar_popdef])[]dnl
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const
|
||||
{]b4_locations_if([[
|
||||
YYUSE (yylocationp);]])[
|
||||
@@ -3274,7 +3274,7 @@ b4_dollar_popdef])[]dnl
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const semantic_type* yyvaluep]b4_locations_if([[,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const
|
||||
{
|
||||
*yycdebug_ << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||
|
||||
@@ -94,28 +94,28 @@ m4_define([b4_variant_includes],
|
||||
|
||||
# b4_value_type_declare
|
||||
# ---------------------
|
||||
# Define semantic_type.
|
||||
# Define value_type.
|
||||
m4_define([b4_value_type_declare],
|
||||
[[ /// A buffer to store and retrieve objects.
|
||||
///
|
||||
/// Sort of a variant, but does not keep track of the nature
|
||||
/// of the stored data, since that knowledge is available
|
||||
/// via the current parser state.
|
||||
class semantic_type
|
||||
class value_type
|
||||
{
|
||||
public:
|
||||
/// Type of *this.
|
||||
typedef semantic_type self_type;
|
||||
typedef value_type self_type;
|
||||
|
||||
/// Empty construction.
|
||||
semantic_type () YY_NOEXCEPT
|
||||
value_type () YY_NOEXCEPT
|
||||
: yyraw_ ()]b4_parse_assert_if([
|
||||
, yytypeid_ (YY_NULLPTR)])[
|
||||
{}
|
||||
|
||||
/// Construct and fill.
|
||||
template <typename T>
|
||||
semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([
|
||||
value_type (YY_RVREF (T) t)]b4_parse_assert_if([
|
||||
: yytypeid_ (&typeid (T))])[
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (sizeof (T) <= size);]])[
|
||||
@@ -124,13 +124,13 @@ m4_define([b4_value_type_declare],
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Non copyable.
|
||||
semantic_type (const self_type&) = delete;
|
||||
value_type (const self_type&) = delete;
|
||||
/// Non copyable.
|
||||
self_type& operator= (const self_type&) = delete;
|
||||
#endif
|
||||
|
||||
/// Destruction, allowed only if empty.
|
||||
~semantic_type () YY_NOEXCEPT
|
||||
~value_type () YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
]b4_assert[ (!yytypeid_);
|
||||
])[}
|
||||
@@ -274,7 +274,7 @@ m4_define([b4_value_type_declare],
|
||||
private:
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Non copyable.
|
||||
semantic_type (const self_type&);
|
||||
value_type (const self_type&);
|
||||
/// Non copyable.
|
||||
self_type& operator= (const self_type&);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user