bug-bison
[Top][All Lists]
Advanced

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

Re: problem with groff's pic.y grammar


From: Paul Hilfinger
Subject: Re: problem with groff's pic.y grammar
Date: Thu, 17 Apr 2003 16:10:01 -0700

> With byacc, I get a clean
> run.  With bison 1.875, I get 8 shift/reduce conflicts, and the
> resulting output doesn't work at all.  How is this possible?

Unless I am greatly mistaken, the problem here is in set_conflicts 
(conflicts.c), where there is a loop:

  /* Loop over all rules which require lookahead in this state.  First
     check for shift-reduce conflict, and try to resolve using
     precedence.  */
  for (i = 0; i < reds->num; ++i)
    if (reds->rules[i]->prec && reds->rules[i]->prec->prec
        && !bitset_disjoint_p (reds->lookaheads[i], lookaheadset))
      {
        resolve_sr_conflict (s, i, errors);
        break;
      }

which should probably be something like

  /* Loop over all rules which require lookahead in this state.  First
     check for shift-reduce conflict, and try to resolve using
     precedence.  */
  for (i = 0; i < reds->num; ++i)
    if (reds->rules[i]->prec && reds->rules[i]->prec->prec
        && !bitset_disjoint_p (reds->lookaheads[i], lookaheadset))
      resolve_sr_conflict (s, i, errors);

to judge from the code that used to be here, viz.:

  for (i = state_table[state].lookaheads;
       i < state_table[state + 1].lookaheads;
       ++i)
    if (rule_table[LAruleno[i]].prec)
      for (j = 0; j < tokensetsize; ++j)
        if (LA (i)[j] & lookaheadset[j])
          {
            resolve_sr_conflict (state, i);
            break;
          }


Alas, I do not have the leisure to test this thoroughly at the moment,
but perhaps this will be of use to those who do.

Paul Hilfinger




reply via email to

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