/[bison]/bison/src/print.c
ViewVC logotype

Diff of /bison/src/print.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.85 by akim, Thu Jul 25 21:21:02 2002 UTC revision 1.86 by akim, Mon Jul 29 17:31:46 2002 UTC
# Line 152  print_transitions (state_t *state, FILE Line 152  print_transitions (state_t *state, FILE
152        {        {
153          symbol_t *symbol = symbols[TRANSITION_SYMBOL (transitions, i)];          symbol_t *symbol = symbols[TRANSITION_SYMBOL (transitions, i)];
154          const char *tag = symbol->tag;          const char *tag = symbol->tag;
155          state_number_t state1 = transitions->states[i];          state_t *state1 = transitions->states[i];
156          int j;          int j;
157    
158          fprintf (out, "    %s", tag);          fprintf (out, "    %s", tag);
159          for (j = width - strlen (tag); j > 0; --j)          for (j = width - strlen (tag); j > 0; --j)
160            fputc (' ', out);            fputc (' ', out);
161          if (display_transitions_p)          if (display_transitions_p)
162            fprintf (out, _("shift, and go to state %d\n"), state1);            fprintf (out, _("shift, and go to state %d\n"), state1->number);
163          else          else
164            fprintf (out, _("go to state %d\n"), state1);            fprintf (out, _("go to state %d\n"), state1->number);
165        }        }
166  }  }
167    
# Line 180  print_errs (FILE *out, state_t *state) Line 180  print_errs (FILE *out, state_t *state)
180    /* Compute the width of the lookaheads column.  */    /* Compute the width of the lookaheads column.  */
181    for (i = 0; i < errp->num; ++i)    for (i = 0; i < errp->num; ++i)
182      if (errp->symbols[i])      if (errp->symbols[i])
183        max_length (&width, symbols[errp->symbols[i]]->tag);        max_length (&width, errp->symbols[i]->tag);
184    
185    /* Nothing to report. */    /* Nothing to report. */
186    if (!width)    if (!width)
# Line 193  print_errs (FILE *out, state_t *state) Line 193  print_errs (FILE *out, state_t *state)
193    for (i = 0; i < errp->num; ++i)    for (i = 0; i < errp->num; ++i)
194      if (errp->symbols[i])      if (errp->symbols[i])
195        {        {
196          const char *tag = symbols[errp->symbols[i]]->tag;          const char *tag = errp->symbols[i]->tag;
197          int j;          int j;
198          fprintf (out, "    %s", tag);          fprintf (out, "    %s", tag);
199          for (j = width - strlen (tag); j > 0; --j)          for (j = width - strlen (tag); j > 0; --j)
# Line 218  state_default_rule (state_t *state) Line 218  state_default_rule (state_t *state)
218    
219    /* No need for a lookahead.  */    /* No need for a lookahead.  */
220    if (state->consistent)    if (state->consistent)
221      return &rules[redp->rules[0]];      return redp->rules[0];
222    
223    /* 1. Each reduction is possibly masked by the lookaheads on which    /* 1. Each reduction is possibly masked by the lookaheads on which
224       we shift (S/R conflicts)...  */       we shift (S/R conflicts)...  */
225    bitset_zero (shiftset);    bitset_zero (shiftset);
226    {    {
227      transitions_t *transitions = state->transitions;      transitions_t *transitions = state->transitions;
228      for (i = 0; i < transitions->num && TRANSITION_IS_SHIFT (transitions, i); i++)      FOR_EACH_SHIFT (transitions, i)
229        if (!TRANSITION_IS_DISABLED (transitions, i))        {
230          {          /* If this state has a shift for the error token, don't use a
           /* If this state has a shift for the error token, don't use a  
231               default rule.  */               default rule.  */
232            if (TRANSITION_IS_ERROR (transitions, i))          if (TRANSITION_IS_ERROR (transitions, i))
233              return NULL;            return NULL;
234            bitset_set (shiftset, TRANSITION_SYMBOL (transitions, i));          bitset_set (shiftset, TRANSITION_SYMBOL (transitions, i));
235          }        }
236    }    }
237    
238    /* 2. Each reduction is possibly masked by the lookaheads on which    /* 2. Each reduction is possibly masked by the lookaheads on which
# Line 242  state_default_rule (state_t *state) Line 241  state_default_rule (state_t *state)
241      errs_t *errp = state->errs;      errs_t *errp = state->errs;
242      for (i = 0; i < errp->num; i++)      for (i = 0; i < errp->num; i++)
243        if (errp->symbols[i])        if (errp->symbols[i])
244          bitset_set (shiftset, errp->symbols[i]);          bitset_set (shiftset, errp->symbols[i]->number);
245    }    }
246    
247    for (i = 0; i < state->nlookaheads; ++i)    for (i = 0; i < state->nlookaheads; ++i)
# Line 314  print_reductions (FILE *out, state_t *st Line 313  print_reductions (FILE *out, state_t *st
313    default_rule = state_default_rule (state);    default_rule = state_default_rule (state);
314    
315    bitset_zero (shiftset);    bitset_zero (shiftset);
316    for (i = 0; i < transitions->num && TRANSITION_IS_SHIFT (transitions, i); i++)    FOR_EACH_SHIFT (transitions, i)
317      if (!TRANSITION_IS_DISABLED (transitions, i))      bitset_set (shiftset, TRANSITION_SYMBOL (transitions, i));
       bitset_set (shiftset, TRANSITION_SYMBOL (transitions, i));  
318    
319    /* Compute the width of the lookaheads column.  */    /* Compute the width of the lookaheads column.  */
320    if (default_rule)    if (default_rule)

Legend:
Removed from v.1.85  
changed lines
  Added in v.1.86

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26