/[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.80 by akim, Sun Jun 30 17:33:19 2002 UTC revision 1.81 by akim, Sun Jun 30 17:33:37 2002 UTC
# Line 123  print_core (FILE *out, state_t *state) Line 123  print_core (FILE *out, state_t *state)
123  `----------------------------------------------------------------*/  `----------------------------------------------------------------*/
124    
125  static void  static void
126  print_transitions (state_t *state, FILE *out, bool display_shifts_p)  print_transitions (state_t *state, FILE *out, bool display_transitions_p)
127  {  {
128    shifts_t *shiftp = state->shifts;    transitions_t *transitions = state->shifts;
129    size_t width = 0;    size_t width = 0;
130    int i;    int i;
131    
132    /* Compute the width of the lookaheads column.  */    /* Compute the width of the lookaheads column.  */
133    for (i = 0; i < shiftp->nshifts; i++)    for (i = 0; i < transitions->num; i++)
134      if (!SHIFT_IS_DISABLED (shiftp, i)      if (!TRANSITION_IS_DISABLED (transitions, i)
135          && SHIFT_IS_SHIFT (shiftp, i) == display_shifts_p)          && TRANSITION_IS_SHIFT (transitions, i) == display_transitions_p)
136        {        {
137          symbol_t *symbol = symbols[SHIFT_SYMBOL (shiftp, i)];          symbol_t *symbol = symbols[TRANSITION_SYMBOL (transitions, i)];
138          max_length (&width, symbol_tag_get (symbol));          max_length (&width, symbol_tag_get (symbol));
139        }        }
140    
# Line 146  print_transitions (state_t *state, FILE Line 146  print_transitions (state_t *state, FILE
146    width += 2;    width += 2;
147    
148    /* Report lookaheads and shifts.  */    /* Report lookaheads and shifts.  */
149    for (i = 0; i < shiftp->nshifts; i++)    for (i = 0; i < transitions->num; i++)
150      if (!SHIFT_IS_DISABLED (shiftp, i)      if (!TRANSITION_IS_DISABLED (transitions, i)
151          && SHIFT_IS_SHIFT (shiftp, i) == display_shifts_p)          && TRANSITION_IS_SHIFT (transitions, i) == display_transitions_p)
152        {        {
153          symbol_t *symbol = symbols[SHIFT_SYMBOL (shiftp, i)];          symbol_t *symbol = symbols[TRANSITION_SYMBOL (transitions, i)];
154          const char *tag = symbol_tag_get (symbol);          const char *tag = symbol_tag_get (symbol);
155          state_number_t state1 = shiftp->shifts[i];          state_number_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_shifts_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);
163          else          else
164            fprintf (out, _("go to state %d\n"), state1);            fprintf (out, _("go to state %d\n"), state1);
# Line 224  state_default_rule (state_t *state) Line 224  state_default_rule (state_t *state)
224       we shift (S/R conflicts)...  */       we shift (S/R conflicts)...  */
225    bitset_zero (shiftset);    bitset_zero (shiftset);
226    {    {
227      shifts_t *shiftp = state->shifts;      transitions_t *transitions = state->shifts;
228      for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)      for (i = 0; i < transitions->num && TRANSITION_IS_SHIFT (transitions, i); i++)
229        if (!SHIFT_IS_DISABLED (shiftp, i))        if (!TRANSITION_IS_DISABLED (transitions, i))
230          {          {
231            /* 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
232               default rule.  */               default rule.  */
233            if (SHIFT_IS_ERROR (shiftp, i))            if (TRANSITION_IS_ERROR (transitions, i))
234              return NULL;              return NULL;
235            bitset_set (shiftset, SHIFT_SYMBOL (shiftp, i));            bitset_set (shiftset, TRANSITION_SYMBOL (transitions, i));
236          }          }
237    }    }
238    
# Line 302  print_reduction (FILE *out, size_t width Line 302  print_reduction (FILE *out, size_t width
302  static void  static void
303  print_reductions (FILE *out, state_t *state)  print_reductions (FILE *out, state_t *state)
304  {  {
305    shifts_t *shiftp = state->shifts;    transitions_t *transitions = state->shifts;
306    reductions_t *redp = state->reductions;    reductions_t *redp = state->reductions;
307    rule_t *default_rule = NULL;    rule_t *default_rule = NULL;
308    size_t width = 0;    size_t width = 0;
# Line 314  print_reductions (FILE *out, state_t *st Line 314  print_reductions (FILE *out, state_t *st
314    default_rule = state_default_rule (state);    default_rule = state_default_rule (state);
315    
316    bitset_zero (shiftset);    bitset_zero (shiftset);
317    for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)    for (i = 0; i < transitions->num && TRANSITION_IS_SHIFT (transitions, i); i++)
318      if (!SHIFT_IS_DISABLED (shiftp, i))      if (!TRANSITION_IS_DISABLED (transitions, i))
319        bitset_set (shiftset, SHIFT_SYMBOL (shiftp, i));        bitset_set (shiftset, TRANSITION_SYMBOL (transitions, i));
320    
321    /* Compute the width of the lookaheads column.  */    /* Compute the width of the lookaheads column.  */
322    if (default_rule)    if (default_rule)
# Line 396  static void Line 396  static void
396  print_actions (FILE *out, state_t *state)  print_actions (FILE *out, state_t *state)
397  {  {
398    reductions_t *redp = state->reductions;    reductions_t *redp = state->reductions;
399    shifts_t *shiftp = state->shifts;    transitions_t *transitions = state->shifts;
400    
401    if (shiftp->nshifts == 0 && redp->nreds == 0)    if (transitions->num == 0 && redp->nreds == 0)
402      {      {
403        fputc ('\n', out);        fputc ('\n', out);
404        if (state->number == final_state->number)        if (state->number == final_state->number)

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.81

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