/[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.171 by akim, Fri Jun 28 09:05:11 2002 UTC revision 1.172 by akim, Sun Jun 30 17:27:34 2002 UTC
# Line 225  GENERATE_MUSCLE_INSERT_TABLE(muscle_inse Line 225  GENERATE_MUSCLE_INSERT_TABLE(muscle_inse
225  GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_short_table, short)  GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_short_table, short)
226  GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_symbol_number_table, symbol_number_t)  GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_symbol_number_table, symbol_number_t)
227  GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_item_number_table, item_number_t)  GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_item_number_table, item_number_t)
228    GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number_t)
229    
230    
231  /*-----------------------------------------------------------------.  /*-----------------------------------------------------------------.
# Line 350  prepare_rules (void) Line 351  prepare_rules (void)
351  static void  static void
352  prepare_states (void)  prepare_states (void)
353  {  {
354    size_t i;    state_number_t i;
355    symbol_number_t *values =    symbol_number_t *values =
356      (symbol_number_t *) alloca (sizeof (symbol_number_t) * nstates);      (symbol_number_t *) alloca (sizeof (symbol_number_t) * nstates);
357    for (i = 0; i < nstates; ++i)    for (i = 0; i < nstates; ++i)
358      values[i] = states[i]->accessing_symbol;      values[i] = states[i]->accessing_symbol;
359    muscle_insert_symbol_number_table ("stos", values,    muscle_insert_symbol_number_table ("stos", values,
360                                      0, 1, nstates);                                       0, 1, nstates);
361  }  }
362    
363    
# Line 463  action_row (state_t *state) Line 464  action_row (state_t *state)
464    for (i = 0; i < shiftp->nshifts; i++)    for (i = 0; i < shiftp->nshifts; i++)
465      {      {
466        symbol_number_t symbol;        symbol_number_t symbol;
467        int shift_state = shiftp->shifts[i];        state_number_t shift_state = shiftp->shifts[i];
468        if (!shift_state)        if (!shift_state)
469          continue;          continue;
470    
# Line 474  action_row (state_t *state) Line 475  action_row (state_t *state)
475    
476        if (actrow[symbol] != 0)        if (actrow[symbol] != 0)
477          conflicted = conflrow[symbol] = 1;          conflicted = conflrow[symbol] = 1;
478        actrow[symbol] = shift_state;        actrow[symbol] = state_number_as_int (shift_state);
479    
480        /* Do not use any default reduction if there is a shift for        /* Do not use any default reduction if there is a shift for
481           error */           error */
# Line 550  action_row (state_t *state) Line 551  action_row (state_t *state)
551    
552    
553  static void  static void
554  save_row (int state)  save_row (state_number_t state)
555  {  {
556    int i;    symbol_number_t i;
557    int count;    int count;
558    short *sp = NULL;    short *sp = NULL;
559    short *sp1 = NULL;    short *sp1 = NULL;
# Line 599  save_row (int state) Line 600  save_row (int state)
600  static void  static void
601  token_actions (void)  token_actions (void)
602  {  {
603    size_t i;    state_number_t i;
604    int nconflict = conflicts_total_count ();    int nconflict = conflicts_total_count ();
605    
606    short *yydefact = XCALLOC (short, nstates);    short *yydefact = XCALLOC (short, nstates);
# Line 796  symbol_printers_output (FILE *out) Line 797  symbol_printers_output (FILE *out)
797    
798    
799  static void  static void
800  save_column (int symbol, int default_state)  save_column (symbol_number_t symbol, state_number_t default_state)
801  {  {
802    int i;    int i;
803    short *sp;    short *sp;
804    short *sp1;    short *sp1;
805    short *sp2;    short *sp2;
806    int count;    int count;
807    int symno = symbol - ntokens + nstates;    int symno = symbol - ntokens + state_number_as_int (nstates);
808    
809    short begin = goto_map[symbol];    int begin = goto_map[symbol];
810    short end = goto_map[symbol + 1];    int end = goto_map[symbol + 1];
811    
812    count = 0;    count = 0;
813    for (i = begin; i < end; i++)    for (i = begin; i < end; i++)
# Line 830  save_column (int symbol, int default_sta Line 831  save_column (int symbol, int default_sta
831    width[symno] = sp1[-1] - sp[0] + 1;    width[symno] = sp1[-1] - sp[0] + 1;
832  }  }
833    
834  static int  
835  default_goto (int symbol)  static state_number_t
836    default_goto (symbol_number_t symbol)
837  {  {
838    size_t i;    state_number_t s;
839    size_t m = goto_map[symbol];    int i;
840    size_t n = goto_map[symbol + 1];    int m = goto_map[symbol];
841    int default_state = -1;    int n = goto_map[symbol + 1];
842      state_number_t default_state = (state_number_t) -1;
843    int max = 0;    int max = 0;
844    
845    if (m == n)    if (m == n)
846      return -1;      return (state_number_t) -1;
847    
848    for (i = 0; i < nstates; i++)    for (s = 0; s < nstates; s++)
849      state_count[i] = 0;      state_count[s] = 0;
850    
851    for (i = m; i < n; i++)    for (i = m; i < n; i++)
852      state_count[to_state[i]]++;      state_count[to_state[i]]++;
853    
854    for (i = 0; i < nstates; i++)    for (s = 0; s < nstates; s++)
855      if (state_count[i] > max)      if (state_count[s] > max)
856        {        {
857          max = state_count[i];          max = state_count[s];
858          default_state = i;          default_state = s;
859        }        }
860    
861    return default_state;    return default_state;
# Line 871  default_goto (int symbol) Line 874  default_goto (int symbol)
874  static void  static void
875  goto_actions (void)  goto_actions (void)
876  {  {
877    int i;    symbol_number_t i;
878    short *yydefgoto = XMALLOC (short, nsyms - ntokens);    state_number_t *yydefgoto = XMALLOC (state_number_t, nsyms - ntokens);
879    
880    state_count = XCALLOC (short, nstates);    state_count = XCALLOC (short, nstates);
881    for (i = ntokens; i < nsyms; ++i)    for (i = ntokens; i < nsyms; ++i)
882      {      {
883        int default_state = default_goto (i);        state_number_t default_state = default_goto (i);
884        save_column (i, default_state);        save_column (i, default_state);
885        yydefgoto[i - ntokens] = default_state;        yydefgoto[i - ntokens] = default_state;
886      }      }
887    
888    muscle_insert_short_table ("defgoto", yydefgoto,    muscle_insert_state_number_table ("defgoto", yydefgoto,
889                               yydefgoto[0], 1, nsyms - ntokens);                                      yydefgoto[0], 1, nsyms - ntokens);
890    XFREE (state_count);    XFREE (state_count);
891    XFREE (yydefgoto);    XFREE (yydefgoto);
892  }  }
# Line 978  pack_vector (int vector) Line 981  pack_vector (int vector)
981    
982        for (k = 0; ok && k < t; k++)        for (k = 0; ok && k < t; k++)
983          {          {
984            loc = j + from[k];            loc = j + state_number_as_int (from[k]);
985            if (loc > (int) table_size)            if (loc > (int) table_size)
986              table_grow (loc);              table_grow (loc);
987    
# Line 994  pack_vector (int vector) Line 997  pack_vector (int vector)
997          {          {
998            for (k = 0; k < t; k++)            for (k = 0; k < t; k++)
999              {              {
1000                loc = j + from[k];                loc = j + state_number_as_int (from[k]);
1001                table[loc] = to[k];                table[loc] = state_number_as_int (to[k]);
1002                if (glr_parser && conflict_to != NULL)                if (glr_parser && conflict_to != NULL)
1003                  conflict_table[loc] = conflict_to[k];                  conflict_table[loc] = conflict_to[k];
1004                check[loc] = from[k];                check[loc] = state_number_as_int (from[k]);
1005              }              }
1006    
1007            while (table[lowzero] != 0)            while (table[lowzero] != 0)
# Line 1129  output_check (void) Line 1132  output_check (void)
1132  static void  static void
1133  output_actions (void)  output_actions (void)
1134  {  {
1135    size_t i;    state_number_t i;
1136    nvectors = nstates + nvars;  
1137      /* That's a poor way to make sure the sizes are properly corelated,
1138         in particular the signedness is not taking into account, but it's
1139         not useless.  */
1140      assert (sizeof (nvectors) >= sizeof (nstates));
1141      assert (sizeof (nvectors) >= sizeof (nvars));
1142    
1143      nvectors = state_number_as_int (nstates) + nvars;
1144    
1145    froms = XCALLOC (short *, nvectors);    froms = XCALLOC (short *, nvectors);
1146    tos = XCALLOC (short *, nvectors);    tos = XCALLOC (short *, nvectors);
# Line 1266  prepare (void) Line 1276  prepare (void)
1276    MUSCLE_INSERT_INT ("pure", pure_parser);    MUSCLE_INSERT_INT ("pure", pure_parser);
1277    MUSCLE_INSERT_INT ("nsym", nsyms);    MUSCLE_INSERT_INT ("nsym", nsyms);
1278    MUSCLE_INSERT_INT ("debug", debug_flag);    MUSCLE_INSERT_INT ("debug", debug_flag);
1279    MUSCLE_INSERT_INT ("final", final_state);    MUSCLE_INSERT_INT ("final", final_state->number);
1280    MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);    MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
1281    MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);    MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);
1282    MUSCLE_INSERT_INT ("error_verbose", error_verbose);    MUSCLE_INSERT_INT ("error_verbose", error_verbose);

Legend:
Removed from v.1.171  
changed lines
  Added in v.1.172

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