[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 8/9] glr2.cc: get rid of the C indirection for yy_symbol_print
From: |
Akim Demaille |
Subject: |
[PATCH 8/9] glr2.cc: get rid of the C indirection for yy_symbol_print |
Date: |
Sat, 12 Sep 2020 16:51:54 +0200 |
* data/skeletons/glr2.cc (yy_symbol_print): Remove.
Just use yyparser.yy_symbol_print_ directly.
---
data/skeletons/glr2.cc | 46 ++++++++----------------------------------
1 file changed, 8 insertions(+), 38 deletions(-)
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 363f3509..8e29bf0b 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -62,25 +62,6 @@ m4_define([b4_parser_class],
# Save the parse parameters.
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
-# b4_yy_symbol_print_define
-# -------------------------
-# Bypass the default implementation to generate the "yy_symbol_print"
-# and "yy_symbol_value_print" functions.
-m4_define([b4_yy_symbol_print_define],
-[[/*--------------------.
-| Print this symbol. |
-`--------------------*/
-
-static void
-yy_symbol_print (FILE *, ]b4_namespace_ref[::]b4_parser_class[& yyparser,
]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[::location_type
*yylocationp]])[]b4_user_formals[)
-{
-]b4_parse_param_use[]dnl
-[ yyparser.yy_symbol_print_ (yytoken, yyvaluep]b4_locations_if([,
yylocationp])[);
-}
-]])[
-
# Hijack the initial action to initialize the locations.
]b4_bison_locations_if([m4_define([b4_initial_action],
[yylloc.initialize ();]m4_ifdef([b4_initial_action], [
@@ -719,14 +700,12 @@ typedef enum { yyok, yyaccept, yyabort, yyerr }
YYRESULTTAG;
#define YY_DEBUG_STREAM if (!yydebug) {} else std::cerr
-]b4_yy_symbol_print_define[
-
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
std::cerr << Title << ' '; \
- yy_symbol_print (stderr, yyparser, Type,
Value]b4_locuser_args([Location])[);\
+ yyparser.yy_symbol_print_ (Type, Value]b4_locuser_args([Location])[);\
std::cerr << '\n'; \
} \
} while (0)
@@ -1348,16 +1327,8 @@ void glr_state::destroy (char const *yymsg,
]b4_namespace_ref[::]b4_parser_class
&semanticVal()]b4_locations_if([, &yyloc])[);
else
{
-#if ]b4_api_PREFIX[DEBUG
- if (yydebug)
- {
- if (firstVal() != YY_NULLPTR)
- std::cerr << yymsg << " unresolved";
- else
- std::cerr << yymsg << " incomplete";
- YY_SYMBOL_PRINT ("",
static_cast<]b4_namespace_ref::b4_parser_class[::symbol_kind_type>(yystos[yylrState]),
YY_NULLPTR, &yyloc);
- }
-#endif
+ YY_SYMBOL_PRINT (yymsg << (firstVal() ? " unresolved" : " incomplete"),
+
static_cast<]b4_namespace_ref::b4_parser_class[::symbol_kind_type>(yystos[yylrState]),
YY_NULLPTR, &yyloc);
if (firstVal() != YY_NULLPTR)
{
@@ -1649,12 +1620,11 @@ class state_stack {
for (yyi = 0; yyi < yynrhs; yyi++)
{
std::cerr << " $" << yyi + 1 << " = ";
- yy_symbol_print (stderr,
- yyparser,
-
static_cast<]b4_namespace_ref::b4_parser_class[::symbol_kind_type>(yystos[yyvsp[yyi
- yynrhs + 1].getState().yylrState]),
- &yyvsp[yyi - yynrhs +
1].getState().semanticVal()]b4_locations_if([,
- &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
- b4_user_args[);
+ yyparser.yy_symbol_print_
+
(static_cast<]b4_namespace_ref::b4_parser_class[::symbol_kind_type>(yystos[yyvsp[yyi
- yynrhs + 1].getState().yylrState]),
+ &yyvsp[yyi - yynrhs + 1].getState().semanticVal()]b4_locations_if([,
+ &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
+ b4_user_args[);
if (!yyvsp[yyi - yynrhs + 1].getState().yyresolved)
std::cerr << " (unresolved)";
std::cerr << '\n';
--
2.28.0
- [PATCH 0/9] glr2.cc: warnings and style, Akim Demaille, 2020/09/12
- [PATCH 1/9] glr2.cc: add copy constructor to yyGLRStackItem, Akim Demaille, 2020/09/12
- [PATCH 2/9] glr2.cc: remove C-style casts, Akim Demaille, 2020/09/12
- [PATCH 3/9] glr2.cc: remove usage of PTRDIFF_MAX, Akim Demaille, 2020/09/12
- [PATCH 4/9] glr2.cc: move StrongIndexAlias into the namespace, Akim Demaille, 2020/09/12
- [PATCH 5/9] glr2.cc: coding style changes, Akim Demaille, 2020/09/12
- [PATCH 6/9] glr2.cc: fix GCC10 warning, Akim Demaille, 2020/09/12
- [PATCH 7/9] glr2.cc: formatting changes, Akim Demaille, 2020/09/12
- [PATCH 8/9] glr2.cc: get rid of the C indirection for yy_symbol_print,
Akim Demaille <=
- [PATCH 9/9] glr2.cc: address warnings with G++ 4.8, Akim Demaille, 2020/09/12