bison-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Implement %define lr.default_rules.


From: Joel E. Denny
Subject: Re: [PATCH] Implement %define lr.default_rules.
Date: Fri, 24 Jul 2009 10:17:11 -0400 (EDT)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

On Thu, 23 Apr 2009, Joel E. Denny wrote:

> > > > +  /* We need a lookahead either to distinguish different reductions
> > > > +     (i.e., there are two or more), or to distinguish a reduction from 
> > > > a
> > > > +     shift.  Otherwise, it is straightforward, and the state is
> > > > +     `consistent'.  However, for states that have any rules, treat only
> > > 
> > > I don't understand "states that have any rules".
> > 
> > It's been a couple of years since I wrote that, but I believe I was trying 
> > to be consistent with "default rules".  I agree it's ugly for many 
> > reasons.  I will change it to "states that have any reductions".
> 
> I realize now that the sentence is clearer if the phrase is completely 
> removed, so I removed it.  That's probably what you were telling me.  Let 
> me know if it's still not clear.

The sentence is wrong when that phrase is removed.  I'm not sure what I 
was thinking.

The following patch, pushed to branch-2.5 and master, fixes that.  It 
still might not be as well written as it could be, but at least it's 
correct.

>From 2de160e12ea0b0313a3a4f2120b30a3eeaad0c76 Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Fri, 24 Jul 2009 09:59:42 -0400
Subject: [PATCH] * src/lalr.c (state_lookahead_tokens_count): Correct comment.

diff --git a/src/lalr.c b/src/lalr.c
index 4aa05b9..8742b4e 100644
--- a/src/lalr.c
+++ b/src/lalr.c
@@ -344,10 +344,11 @@ state_lookahead_tokens_count (state *s, bool 
default_reduction_only_for_accept)
   /* We need a lookahead either to distinguish different reductions
      (i.e., there are two or more), or to distinguish a reduction from a
      shift.  Otherwise, it is straightforward, and the state is
-     `consistent'.  However, treat only the accepting state as
-     consistent (because there is never a lookahead token that makes
-     sense there, and so no lookahead token should be read) if the user
-     has otherwise disabled default reductions.  */
+     `consistent'.  However, do not treat a state with any reductions as
+     consistent unless it is the accepting state (because there is never
+     a lookahead token that makes sense there, and so no lookahead token
+     should be read) if the user has otherwise disabled default
+     reductions.  */
   if (rp->num > 1
       || (rp->num == 1 && sp->num && TRANSITION_IS_SHIFT (sp, 0))
       || (rp->num == 1 && rp->rules[0]->number != 0
-- 
1.5.4.3





reply via email to

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