c++.m4 (bison-3.8.1.tar.xz) | : | c++.m4 (bison-3.8.2.tar.xz) | ||
---|---|---|---|---|
skipping to change at line 214 | skipping to change at line 214 | |||
{ | { | |||
]b4_user_union_members[ | ]b4_user_union_members[ | |||
};]])])dnl | };]])])dnl | |||
]) | ]) | |||
# b4_public_types_declare | # b4_public_types_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], | |||
[b4_glr2_cc_if( | ||||
[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 %d efine api.value.type" | # pragma GCC message "bison: do not #define ]b4_api_PREFIX[STYPE in C++, use %d efine api.value.type" | |||
# endif | # endif | |||
typedef ]b4_api_PREFIX[STYPE value_type; | typedef ]b4_api_PREFIX[STYPE value_type; | |||
#else | #else | |||
]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;])[ | |||
/// Syntax errors thrown from user actions. | /// Syntax errors thrown from user actions. | |||
struct syntax_error : std::runtime_error | struct syntax_error : std::runtime_error | |||
{ | { | |||
syntax_error (]b4_locations_if([const location_type& l, ])[const std::stri ng& m) | syntax_error (]b4_locations_if([const location_type& l, ])[const std::stri ng& m) | |||
: std::runtime_error (m)]b4_locations_if([ | : std::runtime_error (m)]b4_locations_if([ | |||
, location (l)])[ | , location (l)])[ | |||
skipping to change at line 249 | skipping to change at line 252 | |||
{} | {} | |||
~syntax_error () YY_NOEXCEPT YY_NOTHROW;]b4_locations_if([ | ~syntax_error () YY_NOEXCEPT YY_NOTHROW;]b4_locations_if([ | |||
location_type location;])[ | location_type location;])[ | |||
}; | }; | |||
/// Token kinds. | /// Token kinds. | |||
struct token | struct token | |||
{ | { | |||
]b4_token_enums[ | ]b4_token_enums[]b4_glr2_cc_if([], [[ | |||
/// 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;]b4_glr2_cc_if([], [[ | |||
/// 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 | |||
{ | { | |||
]b4_declare_symbol_enum[ | ]b4_declare_symbol_enum[ | |||
}; | }; | |||
/// (Internal) symbol kind. | /// (Internal) symbol kind. | |||
typedef symbol_kind::symbol_kind_type symbol_kind_type; | typedef symbol_kind::symbol_kind_type symbol_kind_type; | |||
skipping to change at line 291 | skipping to change at line 294 | |||
/// via kind (). | /// via kind (). | |||
/// | /// | |||
/// Provide access to semantic value]b4_locations_if([ and location])[. | /// Provide access to semantic value]b4_locations_if([ and location])[. | |||
template <typename Base> | template <typename Base> | |||
struct basic_symbol : Base | struct basic_symbol : Base | |||
{ | { | |||
/// Alias to Base. | /// Alias to Base. | |||
typedef Base super_type; | typedef Base super_type; | |||
/// Default constructor. | /// Default constructor. | |||
basic_symbol () | basic_symbol () YY_NOEXCEPT | |||
: value ()]b4_locations_if([ | : value ()]b4_locations_if([ | |||
, location ()])[ | , location ()])[ | |||
{} | {} | |||
#if 201103L <= YY_CPLUSPLUS | #if 201103L <= YY_CPLUSPLUS | |||
/// Move constructor. | /// Move constructor. | |||
basic_symbol (basic_symbol&& that) | basic_symbol (basic_symbol&& that) | |||
: Base (std::move (that)) | : Base (std::move (that)) | |||
, value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([ | , value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([ | |||
, location (std::move (that.location))])[ | , location (std::move (that.location))])[ | |||
skipping to change at line 329 | skipping to change at line 332 | |||
basic_symbol (typename Base::kind_type t, | basic_symbol (typename Base::kind_type t, | |||
YY_RVREF (value_type) v]b4_locations_if([, | YY_RVREF (value_type) v]b4_locations_if([, | |||
YY_RVREF (location_type) l])[); | YY_RVREF (location_type) l])[); | |||
]])[ | ]])[ | |||
/// Destroy the symbol. | /// Destroy the symbol. | |||
~basic_symbol () | ~basic_symbol () | |||
{ | { | |||
clear (); | clear (); | |||
} | } | |||
]b4_glr2_cc_if([[ | ||||
/// Copy assignment. | ||||
basic_symbol& operator= (const basic_symbol& that) | ||||
{ | ||||
Base::operator= (that);]b4_variant_if([[ | ||||
]b4_symbol_variant([this->kind ()], [value], [copy], | ||||
[that.value])], [[ | ||||
value = that.value]])[;]b4_locations_if([[ | ||||
location = that.location;]])[ | ||||
return *this; | ||||
} | ||||
/// Move assignment. | ||||
basic_symbol& operator= (basic_symbol&& that) | ||||
{ | ||||
Base::operator= (std::move (that));]b4_variant_if([[ | ||||
]b4_symbol_variant([this->kind ()], [value], [move], | ||||
[std::move (that.value)])], [[ | ||||
value = std::move (that.value)]])[;]b4_locations_if([[ | ||||
location = std::move (that.location);]])[ | ||||
return *this; | ||||
} | ||||
]])[ | ||||
/// Destroy contents, and record that is empty. | /// Destroy contents, and record that is empty. | |||
void clear () YY_NOEXCEPT | void clear () YY_NOEXCEPT | |||
{]b4_variant_if([[ | {]b4_variant_if([[ | |||
// User destructor. | // User destructor. | |||
symbol_kind_type yykind = this->kind (); | symbol_kind_type yykind = this->kind (); | |||
basic_symbol<Base>& yysym = *this; | basic_symbol<Base>& yysym = *this; | |||
(void) yysym; | (void) yysym; | |||
switch (yykind) | switch (yykind) | |||
{ | { | |||
]b4_symbol_foreach([b4_symbol_destructor])dnl | ]b4_symbol_foreach([b4_symbol_destructor])dnl | |||
skipping to change at line 369 | skipping to change at line 396 | |||
{ | { | |||
return ]b4_parser_class[::symbol_name (this->kind ()); | return ]b4_parser_class[::symbol_name (this->kind ()); | |||
} | } | |||
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ | #endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[ | |||
]], | ]], | |||
[verbose], | [verbose], | |||
[[ /// The user-facing name of this symbol. | [[ /// The user-facing name of this symbol. | |||
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 ()); | |||
}]])[ | }]])[]b4_glr2_cc_if([], [[ | |||
/// 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; | |||
/// Destructive move, \a s is emptied into this. | /// Destructive move, \a s is emptied into this. | |||
void move (basic_symbol& s); | void move (basic_symbol& s); | |||
/// The semantic value. | /// The semantic value. | |||
value_type value;]b4_locations_if([ | value_type value;]b4_locations_if([ | |||
skipping to change at line 396 | skipping to change at line 423 | |||
private: | private: | |||
#if YY_CPLUSPLUS < 201103L | #if YY_CPLUSPLUS < 201103L | |||
/// Assignment operator. | /// Assignment operator. | |||
basic_symbol& operator= (const basic_symbol& that); | basic_symbol& operator= (const basic_symbol& that); | |||
#endif | #endif | |||
}; | }; | |||
/// Type access provider for token (enum) based symbols. | /// Type access provider for token (enum) based symbols. | |||
struct by_kind | struct by_kind | |||
{ | { | |||
/// The symbol kind as needed by the constructor. | ||||
typedef token_kind_type kind_type; | ||||
/// Default constructor. | /// Default constructor. | |||
by_kind (); | by_kind () YY_NOEXCEPT; | |||
#if 201103L <= YY_CPLUSPLUS | #if 201103L <= YY_CPLUSPLUS | |||
/// Move constructor. | /// Move constructor. | |||
by_kind (by_kind&& that); | by_kind (by_kind&& that) YY_NOEXCEPT; | |||
#endif | #endif | |||
/// Copy constructor. | /// Copy constructor. | |||
by_kind (const by_kind& that); | by_kind (const by_kind& that) YY_NOEXCEPT; | |||
/// The symbol kind as needed by the constructor. | ||||
typedef token_kind_type kind_type; | ||||
/// Constructor from (external) token numbers. | /// Constructor from (external) token numbers. | |||
by_kind (kind_type t); | by_kind (kind_type t) YY_NOEXCEPT; | |||
]b4_glr2_cc_if([[ | ||||
/// Copy assignment. | ||||
by_kind& operator= (const by_kind& that); | ||||
/// Move assignment. | ||||
by_kind& operator= (by_kind&& that); | ||||
]])[ | ||||
/// Record that this symbol is empty. | /// Record that this symbol is empty. | |||
void clear () YY_NOEXCEPT; | void clear () YY_NOEXCEPT; | |||
/// Steal the symbol kind from \a that. | /// Steal the symbol kind from \a that. | |||
void move (by_kind& that); | void move (by_kind& that); | |||
/// 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;]b4_glr2_cc_if([], [[ | |||
/// 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_; | |||
}; | };]b4_glr2_cc_if([], [[ | |||
/// 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> | |||
{]b4_variant_if([[ | {]b4_variant_if([[ | |||
/// Superclass. | /// Superclass. | |||
typedef basic_symbol<by_kind> super_type; | typedef basic_symbol<by_kind> super_type; | |||
/// Empty symbol. | /// Empty symbol. | |||
symbol_type () {} | symbol_type () YY_NOEXCEPT {} | |||
/// Constructor for valueless symbols, and symbols from each type. | /// Constructor for valueless symbols, and symbols from each type. | |||
]b4_type_foreach([_b4_symbol_constructor_define])dnl | ]b4_type_foreach([_b4_symbol_constructor_define])dnl | |||
])[}; | ])[}; | |||
]]) | ]]) | |||
# b4_public_types_define(hh|cc) | # b4_public_types_define(hh|cc) | |||
# ----------------------------- | # ----------------------------- | |||
# Provide the implementation needed by the public types. | # Provide the implementation needed by the public types. | |||
m4_define([b4_public_types_define], | m4_define([b4_public_types_define], | |||
skipping to change at line 486 | skipping to change at line 521 | |||
[typename Base::kind_type t], | [typename Base::kind_type t], | |||
[YY_RVREF (value_type) v], | [YY_RVREF (value_type) v], | |||
b4_locations_if([YY_RVREF (location_type) l]))[) | b4_locations_if([YY_RVREF (location_type) l]))[) | |||
: Base (t) | : Base (t) | |||
, value (]b4_variant_if([], [YY_MOVE (v)])[)]b4_locations_if([ | , value (]b4_variant_if([], [YY_MOVE (v)])[)]b4_locations_if([ | |||
, location (YY_MOVE (l))])[ | , location (YY_MOVE (l))])[ | |||
{]b4_variant_if([[ | {]b4_variant_if([[ | |||
(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) ])])[}]])[ | |||
]b4_glr2_cc_if([], [[ | ||||
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 | |||
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT | ]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT | |||
{ | { | |||
return this->kind () == ]b4_symbol(empty, kind)[; | return this->kind () == ]b4_symbol(empty, kind)[; | |||
} | } | |||
template <typename Base> | template <typename Base> | |||
void | void | |||
]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s) | ]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s) | |||
{ | { | |||
super_type::move (s); | super_type::move (s); | |||
]b4_variant_if([b4_symbol_variant([this->kind ()], [value], [move], | ]b4_variant_if([b4_symbol_variant([this->kind ()], [value], [move], | |||
[YY_MOVE (s.value)])], | [YY_MOVE (s.value)])], | |||
[value = YY_MOVE (s.value);])[]b4_locations_if([ | [value = YY_MOVE (s.value);])[]b4_locations_if([ | |||
location = YY_MOVE (s.location);])[ | location = YY_MOVE (s.location);])[ | |||
} | } | |||
// by_kind. | // by_kind. | |||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind () | ]b4_inline([$1])b4_parser_class[::by_kind::by_kind () YY_NOEXCEPT | |||
: kind_ (]b4_symbol(empty, kind)[) | : kind_ (]b4_symbol(empty, kind)[) | |||
{} | {} | |||
#if 201103L <= YY_CPLUSPLUS | #if 201103L <= YY_CPLUSPLUS | |||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that) | ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that) YY_NOEXCEP T | |||
: kind_ (that.kind_) | : kind_ (that.kind_) | |||
{ | { | |||
that.clear (); | that.clear (); | |||
} | } | |||
#endif | #endif | |||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that) | ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that) YY_NO EXCEPT | |||
: kind_ (that.kind_) | : kind_ (that.kind_) | |||
{} | {} | |||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t) | ]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t) YY_NOEX CEPT | |||
: kind_ (yytranslate_ (t)) | : kind_ (yytranslate_ (t)) | |||
{} | {} | |||
]b4_glr2_cc_if([[ | ||||
]b4_inline([$1])]b4_parser_class[::by_kind& | ||||
b4_parser_class[::by_kind::by_kind::operator= (const by_kind& that) | ||||
{ | ||||
kind_ = that.kind_; | ||||
return *this; | ||||
} | ||||
]b4_inline([$1])]b4_parser_class[::by_kind& | ||||
b4_parser_class[::by_kind::by_kind::operator= (by_kind&& that) | ||||
{ | ||||
kind_ = that.kind_; | ||||
that.clear (); | ||||
return *this; | ||||
} | ||||
]])[ | ||||
]b4_inline([$1])[void | ]b4_inline([$1])[void | |||
]b4_parser_class[::by_kind::clear () YY_NOEXCEPT | ]b4_parser_class[::by_kind::clear () YY_NOEXCEPT | |||
{ | { | |||
kind_ = ]b4_symbol(empty, kind)[; | kind_ = ]b4_symbol(empty, kind)[; | |||
} | } | |||
]b4_inline([$1])[void | ]b4_inline([$1])[void | |||
]b4_parser_class[::by_kind::move (by_kind& that) | ]b4_parser_class[::by_kind::move (by_kind& that) | |||
{ | { | |||
kind_ = that.kind_; | kind_ = that.kind_; | |||
that.clear (); | that.clear (); | |||
} | } | |||
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type | ]b4_inline([$1])[]b4_parser_class[::symbol_kind_type | |||
]b4_parser_class[::by_kind::kind () const YY_NOEXCEPT | ]b4_parser_class[::by_kind::kind () const YY_NOEXCEPT | |||
{ | { | |||
return kind_; | return kind_; | |||
} | } | |||
]b4_glr2_cc_if([], [[ | ||||
]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 (); | |||
} | } | |||
]])[ | ||||
]]) | ]]) | |||
# b4_token_constructor_define | # b4_token_constructor_define | |||
# ---------------------------- | # ---------------------------- | |||
# Define make_FOO for all the token kinds. | # Define make_FOO for all the token kinds. | |||
# Use at class-level. Redefined in variant.hh. | # Use at class-level. Redefined in variant.hh. | |||
m4_define([b4_token_constructor_define], []) | m4_define([b4_token_constructor_define], []) | |||
# b4_yytranslate_define(cc|hh) | # b4_yytranslate_define(cc|hh) | |||
# ---------------------------- | # ---------------------------- | |||
# Define yytranslate_. Sometimes used in the header file ($1=hh), | # Define yytranslate_. Sometimes used in the header file ($1=hh), | |||
# sometimes in the cc file. | # sometimes in the cc file. | |||
m4_define([b4_yytranslate_define], | m4_define([b4_yytranslate_define], | |||
[ b4_inline([$1])b4_parser_class[::symbol_kind_type | [ b4_inline([$1])b4_parser_class[::symbol_kind_type | |||
]b4_parser_class[::yytranslate_ (int t) | ]b4_parser_class[::yytranslate_ (int t) YY_NOEXCEPT | |||
{ | { | |||
]b4_api_token_raw_if( | ]b4_api_token_raw_if( | |||
[[ return static_cast<symbol_kind_type> (t);]], | [[ return static_cast<symbol_kind_type> (t);]], | |||
[[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to | [[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to | |||
// TOKEN-NUM as returned by yylex. | // TOKEN-NUM as returned by yylex. | |||
static | static | |||
const ]b4_int_type_for([b4_translate])[ | const ]b4_int_type_for([b4_translate])[ | |||
translate_table[] = | translate_table[] = | |||
{ | { | |||
]b4_translate[ | ]b4_translate[ | |||
End of changes. 30 change blocks. | ||||
25 lines changed or deleted | 81 lines changed or added |