bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

yacc.c: improve formatting of the generated code


From: Akim Demaille
Subject: yacc.c: improve formatting of the generated code
Date: Sat, 2 May 2020 10:16:46 +0200

commit 953d6106d73d6c73b4bd66ca60d3538acb5f9027
Author: Akim Demaille <address@hidden>
Date:   Sat May 2 10:03:29 2020 +0200

    yacc.c: improve formatting of the generated code
    
    * data/skeletons/yacc.c (yy_reduce_print): here.

diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index b6b2672c..cbdd3f30 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -132,6 +132,7 @@ m4_define([b4_rhs_value],
 # b4_lhs_location()
 # -----------------
 # Expansion of @$.
+# Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
 m4_define([b4_lhs_location],
 [(yyloc)])
 
@@ -140,6 +141,7 @@ m4_define([b4_lhs_location],
 # ---------------------------------
 # Expansion of @POS, where the current rule has RULE-LENGTH symbols
 # on RHS.
+# Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
 m4_define([b4_rhs_location],
 [(yylsp@{b4_subtract([$2], [$1])@})])
 
@@ -826,9 +828,8 @@ yy_reduce_print (yy_state_t *yyssp, YYSTYPE 
*yyvsp,]b4_locations_if([[ YYLTYPE *
       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
       yy_symbol_print (stderr,
                        YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
-                       &]b4_rhs_value(yynrhs, yyi + 1)[
-                       ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 
1))[]dnl
-                       b4_user_args[);
+                       &]b4_rhs_value(yynrhs, yyi + 1)[]b4_locations_if([,
+                       &]b4_rhs_location(yynrhs, yyi + 1))[]b4_user_args[);
       YYFPRINTF (stderr, "\n");
     }
 }
diff --git a/src/parse-gram.c b/src/parse-gram.c
index f2a4eb91..dbd1cc83 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.5.90.  */
+/* A Bison parser, made by GNU Bison 3.5.91.  */
 
 /* Bison implementation for Yacc-like parsers in C
 
@@ -49,7 +49,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "3.5.90"
+#define YYBISON_VERSION "3.5.91"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -1304,8 +1304,8 @@ yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, 
YYLTYPE *yylsp,
       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
       yy_symbol_print (stderr,
                        YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
-                       &yyvsp[(yyi + 1) - (yynrhs)]
-                       , &(yylsp[(yyi + 1) - (yynrhs)])                       
);
+                       &yyvsp[(yyi + 1) - (yynrhs)],
+                       &(yylsp[(yyi + 1) - (yynrhs)]));
       YYFPRINTF (stderr, "\n");
     }
 }
@@ -2738,10 +2738,8 @@ yyerrlab1:
   YY_IGNORE_MAYBE_UNINITIALIZED_END
 
   yyerror_range[2] = yylloc;
-  /* Using YYLLOC is tempting, but would change the location of
-     the lookahead.  YYLOC is available though.  */
-  YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
-  *++yylsp = yyloc;
+  ++yylsp;
+  YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);
 
   /* Shift the error token.  */
   YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
diff --git a/src/parse-gram.h b/src/parse-gram.h
index ecda432d..25cb1c57 100644
--- a/src/parse-gram.h
+++ b/src/parse-gram.h
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.5.90.  */
+/* A Bison parser, made by GNU Bison 3.5.91.  */
 
 /* Bison interface for Yacc-like parsers in C
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]