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

Diff of /bison/src/output.c

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

revision 1.186 by akim, Thu Jul 25 17:30:44 2002 UTC revision 1.187 by akim, Thu Jul 25 21:21:02 2002 UTC
# Line 365  prepare_rules (void) Line 365  prepare_rules (void)
365    rule_number_t r;    rule_number_t r;
366    unsigned int i = 0;    unsigned int i = 0;
367    item_number_t *rhs = XMALLOC (item_number_t, nritems);    item_number_t *rhs = XMALLOC (item_number_t, nritems);
368    unsigned int *prhs = XMALLOC (unsigned int, nrules + 1);    unsigned int *prhs = XMALLOC (unsigned int, nrules);
369    unsigned int *rline = XMALLOC (unsigned int, nrules + 1);    unsigned int *rline = XMALLOC (unsigned int, nrules);
370    symbol_number_t *r1 = XMALLOC (symbol_number_t, nrules + 1);    symbol_number_t *r1 = XMALLOC (symbol_number_t, nrules);
371    unsigned int *r2 = XMALLOC (unsigned int, nrules + 1);    unsigned int *r2 = XMALLOC (unsigned int, nrules);
372    short *dprec = XMALLOC (short, nrules + 1);    short *dprec = XMALLOC (short, nrules);
373    short *merger = XMALLOC (short, nrules + 1);    short *merger = XMALLOC (short, nrules);
374    
375    for (r = 1; r < nrules + 1; ++r)    for (r = 0; r < nrules; ++r)
376      {      {
377        item_number_t *rhsp = NULL;        item_number_t *rhsp = NULL;
378        /* Index of rule R in RHS. */        /* Index of rule R in RHS. */
# Line 396  prepare_rules (void) Line 396  prepare_rules (void)
396    assert (i == nritems);    assert (i == nritems);
397    
398    muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems);    muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems);
399    muscle_insert_unsigned_int_table ("prhs", prhs, 0, 1, nrules + 1);    muscle_insert_unsigned_int_table ("prhs", prhs, 0, 0, nrules);
400    muscle_insert_unsigned_int_table ("rline", rline, 0, 1, nrules + 1);    muscle_insert_unsigned_int_table ("rline", rline, 0, 0, nrules);
401    muscle_insert_symbol_number_table ("r1", r1, 0, 1, nrules + 1);    muscle_insert_symbol_number_table ("r1", r1, 0, 0, nrules);
402    muscle_insert_unsigned_int_table ("r2", r2, 0, 1, nrules + 1);    muscle_insert_unsigned_int_table ("r2", r2, 0, 0, nrules);
403    muscle_insert_short_table ("dprec", dprec, 0, 1, nrules + 1);    muscle_insert_short_table ("dprec", dprec, 0, 0, nrules);
404    muscle_insert_short_table ("merger", merger, 0, 1, nrules + 1);    muscle_insert_short_table ("merger", merger, 0, 0, nrules);
405    
406    free (rhs);    free (rhs);
407    free (prhs);    free (prhs);
# Line 434  prepare_states (void) Line 434  prepare_states (void)
434  | by non-zero entries in CONFLROW, create a list of possible         |  | by non-zero entries in CONFLROW, create a list of possible         |
435  | reductions that are alternatives to the shift or reduction         |  | reductions that are alternatives to the shift or reduction         |
436  | currently recorded for that token in STATE.  Store the alternative |  | currently recorded for that token in STATE.  Store the alternative |
437  | reductions followed by a 0 in conflict_list, updating              |  | reductions followed by a 0 in CONFLICT_LIST, updating              |
438  | conflict_list_cnt, and storing an index to the start of the list   |  | CONFLICT_LIST_CNT, and storing an index to the start of the list   |
439  | back into CONFLROW.                                                |  | back into CONFLROW.                                                |
440  `-------------------------------------------------------------------*/  `-------------------------------------------------------------------*/
441    
# Line 461  conflict_row (state_t *state) Line 461  conflict_row (state_t *state)
461              {              {
462                assert (conflict_list_free > 0);                assert (conflict_list_free > 0);
463                conflict_list[conflict_list_cnt]                conflict_list[conflict_list_cnt]
464                  = state->lookaheads_rule[i]->number;                  = state->lookaheads_rule[i]->number + 1;
465                conflict_list_cnt += 1;                conflict_list_cnt += 1;
466                conflict_list_free -= 1;                conflict_list_free -= 1;
467              }              }
# Line 488  conflict_row (state_t *state) Line 488  conflict_row (state_t *state)
488  | considered that likes a token gets to handle it.                  |  | considered that likes a token gets to handle it.                  |
489  |                                                                   |  |                                                                   |
490  | For GLR parsers, also sets CONFLROW[SYM] to an index into         |  | For GLR parsers, also sets CONFLROW[SYM] to an index into         |
491  | conflict_list iff there is an unresolved conflict (s/r or r/r)    |  | CONFLICT_LIST iff there is an unresolved conflict (s/r or r/r)    |
492  | with symbol SYM. The default reduction is not used for a symbol   |  | with symbol SYM. The default reduction is not used for a symbol   |
493  | that has any such conflicts.                                      |  | that has any such conflicts.                                      |
494  `------------------------------------------------------------------*/  `------------------------------------------------------------------*/
# Line 497  static rule_number_t Line 497  static rule_number_t
497  action_row (state_t *state)  action_row (state_t *state)
498  {  {
499    int i;    int i;
500    rule_number_t default_rule = 0;    rule_number_t default_rule = -1;
501    reductions_t *redp = state->reductions;    reductions_t *redp = state->reductions;
502    transitions_t *transitions = state->transitions;    transitions_t *transitions = state->transitions;
503    errs_t *errp = state->errs;    errs_t *errp = state->errs;
# Line 601  action_row (state_t *state) Line 601  action_row (state_t *state)
601    /* If have no default rule, the default is an error.    /* If have no default rule, the default is an error.
602       So replace any action which says "error" with "use default".  */       So replace any action which says "error" with "use default".  */
603    
604    if (default_rule == 0)    if (default_rule == -1)
605      for (i = 0; i < ntokens; i++)      for (i = 0; i < ntokens; i++)
606        if (actrow[i] == ACTION_MIN)        if (actrow[i] == ACTION_MIN)
607          actrow[i] = 0;          actrow[i] = 0;
# Line 689  token_actions (void) Line 689  token_actions (void)
689    
690    for (i = 0; i < nstates; ++i)    for (i = 0; i < nstates; ++i)
691      {      {
692        yydefact[i] = action_row (states[i]);        yydefact[i] = action_row (states[i]) + 1;
693        save_row (i);        save_row (i);
694      }      }
695    
# Line 711  actions_output (FILE *out) Line 711  actions_output (FILE *out)
711    rule_number_t r;    rule_number_t r;
712    
713    fputs ("m4_define([b4_actions], \n[[", out);    fputs ("m4_define([b4_actions], \n[[", out);
714    for (r = 1; r < nrules + 1; ++r)    for (r = 0; r < nrules; ++r)
715      if (rules[r].action)      if (rules[r].action)
716        {        {
717          fprintf (out, "  case %d:\n", r);          fprintf (out, "  case %d:\n", r + 1);
718    
719          if (!no_lines_flag)          if (!no_lines_flag)
720            fprintf (out, muscle_find ("linef"),            fprintf (out, muscle_find ("linef"),

Legend:
Removed from v.1.186  
changed lines
  Added in v.1.187

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