c++: make valid to print the empty symbol

* data/skeletons/lalr1.cc (yy_print_): here.
This commit is contained in:
Akim Demaille
2020-04-26 10:49:05 +02:00
parent 7fec669e42
commit 7eabe1c70b

View File

@@ -795,23 +795,21 @@ m4_if(b4_prefix, [yy], [],
#if ]b4_api_PREFIX[DEBUG #if ]b4_api_PREFIX[DEBUG
template <typename Base> template <typename Base>
void void
]b4_parser_class[::yy_print_ (std::ostream& yyo, ]b4_parser_class[::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const
const basic_symbol<Base>& yysym) const
{ {
std::ostream& yyoutput = yyo; std::ostream& yyoutput = yyo;
YYUSE (yyoutput); YYUSE (yyoutput);
symbol_kind_type yykind = yysym.kind ();
#if defined __GNUC__ && ! defined __clang__ && ! defined __ICC && __GNUC__ * 100 + __GNUC_MINOR__ <= 408
// Avoid a (spurious) G++ 4.8 warning about "array subscript is
// below array bounds".
if (yysym.empty ()) if (yysym.empty ())
std::abort (); yyo << "empty symbol";
#endif else
yyo << (yykind < YYNTOKENS ? "token" : "nterm") {
<< ' ' << symbol_name (yykind) << " ("]b4_locations_if([ symbol_kind_type yykind = yysym.kind ();
<< yysym.location << ": "])[; yyo << (yykind < YYNTOKENS ? "token" : "nterm")
]b4_symbol_actions([printer])[ << ' ' << symbol_name (yykind) << " ("]b4_locations_if([
yyo << ')'; << yysym.location << ": "])[;
]b4_symbol_actions([printer])[
yyo << ')';
}
} }
#endif #endif