bison-patches
[Top][All Lists]
Advanced

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

[PATCH] Clean up recent patches a little.


From: Joel E. Denny
Subject: [PATCH] Clean up recent patches a little.
Date: Fri, 24 Apr 2009 02:58:34 -0400 (EDT)

On Tue, 21 Apr 2009, Joel E. Denny wrote:

> On Tue, 21 Apr 2009, Akim Demaille wrote:
> 
> > Le 20 avr. 09 ? 07:48, Joel E. Denny a ?crit :

> > > @@ -244,6 +245,7 @@ print_reductions (FILE *out, state *s)
> > >   rule *default_rule = NULL;
> > >   size_t width = 0;
> > >   int i, j;
> > > +  bool non_default_action = false;
> > 
> > I'm not fond of negated Boolean variables.  Especially seems it seems used
> > only negated itself :)  But then, I can understand "false" as "not known 
> > yet"
> > and "true" as "known".
> 
> I'll change it to the opposite, default_reduction_only.

On Tue, 21 Apr 2009, Akim Demaille wrote:

> Le 21 avr. 09 ? 12:32, Joel E. Denny a ?crit :
> 
> > @@ -7205,7 +7354,8 @@ useless: STR;
> > @command{bison} reports:
> > 
> > @example
> > -calc.y: warning: 1 nonterminal and 1 rule useless in grammar
> > +tmp.y: warning: 1 nonterminal useless in grammar
> > +tmp.y: warning: 1 rule useless in grammar
> > calc.y:11.1-7: warning: nonterminal useless in grammar: useless
> > calc.y:11.10-12: warning: rule useless in grammar: useless: STR
> > calc.y: conflicts: 7 shift/reduce
> 
> tmp.y?

Thanks for catching that.

I pushed the following patch to branch-2.5 and master to fix all the 
above.

From 379261b3fd4e799c37bda6d354e7b8fe582357a6 Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Fri, 24 Apr 2009 02:13:26 -0400
Subject: [PATCH] Clean up recent patches a little.

Reported by Akim Demaille.
* doc/bison.texinfo (Understanding): Fix typos.
* src/print.c (print_reductions): Don't use negated variable.

diff --git a/doc/bison.texinfo b/doc/bison.texinfo
index 8e3ca22..c52d7b8 100644
--- a/doc/bison.texinfo
+++ b/doc/bison.texinfo
@@ -7355,8 +7355,8 @@ useless: STR;
 @command{bison} reports:
 
 @example
-tmp.y: warning: 1 nonterminal useless in grammar
-tmp.y: warning: 1 rule useless in grammar
+calc.y: warning: 1 nonterminal useless in grammar
+calc.y: warning: 1 rule useless in grammar
 calc.y:11.1-7: warning: nonterminal useless in grammar: useless
 calc.y:11.10-12: warning: rule useless in grammar: useless: STR
 calc.y: conflicts: 7 shift/reduce
diff --git a/src/print.c b/src/print.c
index 7fc577c..e307329 100644
--- a/src/print.c
+++ b/src/print.c
@@ -245,7 +245,7 @@ print_reductions (FILE *out, state *s)
   rule *default_reduction = NULL;
   size_t width = 0;
   int i, j;
-  bool non_default_action = false;
+  bool default_reduction_only = true;
 
   if (reds->num == 0)
     return;
@@ -299,7 +299,7 @@ print_reductions (FILE *out, state *s)
        bool defaulted = false;
        bool count = bitset_test (no_reduce_set, i);
         if (count)
-          non_default_action = true;
+          default_reduction_only = false;
 
        for (j = 0; j < reds->num; ++j)
          if (bitset_test (reds->lookahead_tokens[j], i))
@@ -308,7 +308,7 @@ print_reductions (FILE *out, state *s)
                {
                  if (reds->rules[j] != default_reduction)
                     {
-                      non_default_action = true;
+                      default_reduction_only = false;
                       print_reduction (out, width,
                                        symbols[i]->tag,
                                        reds->rules[j], true);
@@ -319,7 +319,7 @@ print_reductions (FILE *out, state *s)
                }
              else
                {
-                  non_default_action = true;
+                  default_reduction_only = false;
                  if (defaulted)
                    print_reduction (out, width,
                                     symbols[i]->tag,
@@ -339,7 +339,7 @@ print_reductions (FILE *out, state *s)
       print_reduction (out, width, _("$default"), default_reduction, true);
       aver (0 == strcmp (default_reductions, "all")
             || (0 == strcmp (default_reductions, "consistent")
-                && !non_default_action)
+                && default_reduction_only)
             || (reds->num == 1 && reds->rules[0]->number == 0));
       free (default_reductions);
     }
-- 
1.5.4.3

reply via email to

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