bison-patches
[Top][All Lists]
Advanced

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

printing problem in yacc.c, glr.c (more than INT_MAX rules)


From: Paul Eggert
Subject: printing problem in yacc.c, glr.c (more than INT_MAX rules)
Date: Fri, 6 Dec 2002 21:49:38 -0800 (PST)

I installed the following patch, to correct one bug for grammars that
have more than INT_MAX rules.  I'm sure there are other such bugs, but
this one is easy to fix.

2002-12-06  Paul Eggert  <address@hidden>
        
        * data/glr.c (yy_reduce_print): Don't assume that yyrline[yyrule]
        promotes to int; it might be unsigned int.
        * data/yacc.c (yy_reduce_print): Likewise.

Index: data/glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.42
diff -p -u -r1.42 glr.c
--- data/glr.c  21 Nov 2002 05:11:29 -0000      1.42
+++ data/glr.c  7 Dec 2002 05:41:55 -0000
@@ -1103,8 +1103,9 @@ static inline void
 yy_reduce_print (size_t yyk, yyRuleNum yyrule)
 {
   int yyi;
-  YYFPRINTF (stderr, "Reducing stack %d by rule %d (line %d), ",
-            yyk, yyrule - 1, yyrline[yyrule]);
+  unsigned int yylineno = yyrline[yyrule];
+  YYFPRINTF (stderr, "Reducing stack %d by rule %d (line %u), ",
+            yyk, yyrule - 1, yylineno);
   /* Print the symbols being reduced, and their result.  */
   for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
     YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi]));
Index: data/yacc.c
===================================================================
RCS file: /cvsroot/bison/bison/data/yacc.c,v
retrieving revision 1.39
diff -p -u -r1.39 yacc.c
--- data/yacc.c 25 Nov 2002 06:42:10 -0000      1.39
+++ data/yacc.c 7 Dec 2002 05:41:55 -0000
@@ -577,8 +577,9 @@ do {                                                        
        \
                    [[int yyrule], [yyrule]])[
 {
   int yyi;
-  YYFPRINTF (stderr, "Reducing stack by rule %d (line %d), ",
-             yyrule - 1, yyrline[yyrule]);
+  unsigned int yylineno = yyrline[yyrule];
+  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
+             yyrule - 1, yylineno);
   /* Print the symbols being reduced, and their result.  */
   for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
     YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);




reply via email to

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