[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/16] c++: make valid to print the empty symbol
From: |
Akim Demaille |
Subject: |
[PATCH 09/16] c++: make valid to print the empty symbol |
Date: |
Sun, 26 Apr 2020 16:40:44 +0200 |
* data/skeletons/lalr1.cc (yy_print_): here.
---
data/skeletons/lalr1.cc | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index a7c5d684..99c64331 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -795,23 +795,21 @@ m4_if(b4_prefix, [yy], [],
#if ]b4_api_PREFIX[DEBUG
template <typename Base>
void
- ]b4_parser_class[::yy_print_ (std::ostream& yyo,
- const basic_symbol<Base>& yysym) const
+ ]b4_parser_class[::yy_print_ (std::ostream& yyo, const basic_symbol<Base>&
yysym) const
{
std::ostream& yyoutput = yyo;
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 ())
- std::abort ();
-#endif
- yyo << (yykind < YYNTOKENS ? "token" : "nterm")
- << ' ' << symbol_name (yykind) << " ("]b4_locations_if([
- << yysym.location << ": "])[;
- ]b4_symbol_actions([printer])[
- yyo << ')';
+ yyo << "empty symbol";
+ else
+ {
+ symbol_kind_type yykind = yysym.kind ();
+ yyo << (yykind < YYNTOKENS ? "token" : "nterm")
+ << ' ' << symbol_name (yykind) << " ("]b4_locations_if([
+ << yysym.location << ": "])[;
+ ]b4_symbol_actions([printer])[
+ yyo << ')';
+ }
}
#endif
--
2.26.2
- [PATCH 00/16] Returning the error token from the scanner does not trigger an error message, Akim Demaille, 2020/04/26
- [PATCH 07/16] c++: fix a few style issues, Akim Demaille, 2020/04/26
- [PATCH 03/16] style: glr.c: fix indentation issue, Akim Demaille, 2020/04/26
- [PATCH 04/16] style: prefer b4_has_translations_if, Akim Demaille, 2020/04/26
- [PATCH 02/16] style: fix a few remaining 'type' instead of 'kind', Akim Demaille, 2020/04/26
- [PATCH 01/16] skeletons: make the warning about implementation details clearer, Akim Demaille, 2020/04/26
- [PATCH 06/16] all: prefer YYERRCODE to YYERROR, Akim Demaille, 2020/04/26
- [PATCH 08/16] c++: always define symbol_name, Akim Demaille, 2020/04/26
- [PATCH 09/16] c++: make valid to print the empty symbol,
Akim Demaille <=
- [PATCH 11/16] examples: bistromathic: comment changes, Akim Demaille, 2020/04/26
- [PATCH 10/16] doc: hacking tricks, Akim Demaille, 2020/04/26
- [PATCH 05/16] style: glr.c: clarify, Akim Demaille, 2020/04/26
- [PATCH 13/16] examples: bistromathic: demonstrate error recovery, Akim Demaille, 2020/04/26
- [PATCH 12/16] examples: bistromathic: when quitting, close the current line, Akim Demaille, 2020/04/26
- [PATCH 15/16] all: don't emit an error message when the scanner returns YYERRCODE, Akim Demaille, 2020/04/26
- [PATCH 16/16] todo: update, Akim Demaille, 2020/04/26
- [PATCH 14/16] c: don't emit an error message when the scanner returns YYERRCODE, Akim Demaille, 2020/04/26