[BACK]Return to output.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / yacc

Diff for /src/usr.bin/yacc/output.c between version 1.21 and 1.22

version 1.21, 2014/03/07 19:34:49 version 1.22, 2014/03/07 19:44:07
Line 185 
Line 185 
                         j = 1;                          j = 1;
                 } else                  } else
                         ++j;                          ++j;
   
                 fprintf(output_file, "%5d,", symbol_value[rlhs[i]]);                  fprintf(output_file, "%5d,", symbol_value[rlhs[i]]);
         }          }
         if (!rflag)          if (!rflag)
Line 205 
Line 204 
                         j = 1;                          j = 1;
                 } else                  } else
                         j++;                          j++;
   
                 fprintf(output_file, "%5d,", rrhs[i + 1] - rrhs[i] - 1);                  fprintf(output_file, "%5d,", rrhs[i + 1] - rrhs[i] - 1);
         }          }
         if (!rflag)          if (!rflag)
Line 234 
Line 232 
                         putc('\n', output_file);                          putc('\n', output_file);
                         j = 1;                          j = 1;
                 }                  }
   
                 fprintf(output_file, "%5d,", (defred[i] ? defred[i] - 2 : 0));                  fprintf(output_file, "%5d,", (defred[i] ? defred[i] - 2 : 0));
         }          }
   
Line 287 
Line 284 
         if (parser[i]) {          if (parser[i]) {
                 for (j = 0; j < 2 * ntokens; ++j)                  for (j = 0; j < 2 * ntokens; ++j)
                         actionrow[j] = 0;                          actionrow[j] = 0;
   
                         shiftcount = 0;                          shiftcount = 0;
                         reducecount = 0;                          reducecount = 0;
                         for (p = parser[i]; p; p = p->next) {                          for (p = parser[i]; p; p = p->next) {
Line 354 
Line 350 
         state_count = NEW2(nstates, short);          state_count = NEW2(nstates, short);
   
         k = default_goto(start_symbol + 1);          k = default_goto(start_symbol + 1);
         fprintf(output_file,          fprintf(output_file, "const short %sdgoto[] =\n"
         "const short %sdgoto[] =\n"              "\t{%40d,", symbol_prefix, k);
         "\t{%40d,", symbol_prefix, k);  
         save_column(start_symbol + 1, k);          save_column(start_symbol + 1, k);
   
         j = 10;          j = 10;
Line 392 
Line 387 
         m = goto_map[symbol];          m = goto_map[symbol];
         n = goto_map[symbol + 1];          n = goto_map[symbol + 1];
   
         if (m == n) return (0);          if (m == n)
                   return (0);
   
         memset(state_count, 0, nstates * sizeof(short));          memset(state_count, 0, nstates * sizeof(short));
   
         for (i = m; i < n; i++)          for (i = m; i < n; i++)
         state_count[to_state[i]]++;                  state_count[to_state[i]]++;
   
         max = 0;          max = 0;
         default_state = 0;          default_state = 0;
Line 620 
Line 616 
                                         fatal("maximum table size exceeded");                                          fatal("maximum table size exceeded");
   
                                 newmax = maxtable;                                  newmax = maxtable;
                                 do { newmax += 200; } while (newmax <= loc);                                  do {
                                 table = (short *) realloc(table, newmax*sizeof(short));                                          newmax += 200;
                                 if (table == 0) no_space();                                  } while (newmax <= loc);
                                 check = (short *) realloc(check, newmax*sizeof(short));                                  table = realloc(table, newmax*sizeof(short));
                                 if (check == 0) no_space();                                  if (table == 0)
                                           no_space();
                                   check = realloc(check, newmax*sizeof(short));
                                   if (check == 0)
                                           no_space();
                                 for (l  = maxtable; l < newmax; ++l) {                                  for (l  = maxtable; l < newmax; ++l) {
                                         table[l] = 0;                                          table[l] = 0;
                                         check[l] = -1;                                          check[l] = -1;
Line 663 
Line 663 
 {  {
         int i, j;          int i, j;
   
         fprintf(output_file,          fprintf(output_file, "const short %ssindex[] =\n"
         "const short %ssindex[] =\n"              "\t{%39d,", symbol_prefix, base[0]);
         "\t{%39d,", symbol_prefix, base[0]);  
   
         j = 10;          j = 10;
         for (i = 1; i < nstates; i++) {          for (i = 1; i < nstates; i++) {
Line 676 
Line 675 
                         j = 1;                          j = 1;
                 } else                  } else
                         ++j;                          ++j;
   
                 fprintf(output_file, "%5d,", base[i]);                  fprintf(output_file, "%5d,", base[i]);
         }          }
   
         if (!rflag)          if (!rflag)
                 outline += 2;                  outline += 2;
         fprintf(output_file,          fprintf(output_file, "};\n"
             "};\n"  
             "const short %srindex[] =\n"              "const short %srindex[] =\n"
             "\t{%39d,", symbol_prefix, base[nstates]);              "\t{%39d,", symbol_prefix, base[nstates]);
   
Line 696 
Line 693 
                         j = 1;                          j = 1;
                 } else                  } else
                         ++j;                          ++j;
   
                 fprintf(output_file, "%5d,", base[i]);                  fprintf(output_file, "%5d,", base[i]);
         }          }
   
         if (!rflag)          if (!rflag)
                 outline += 2;                  outline += 2;
         fprintf(output_file,          fprintf(output_file, "};\n"
             "};\n"  
             "const short %sgindex[] =\n"              "const short %sgindex[] =\n"
             "\t{%39d,", symbol_prefix, base[2*nstates]);              "\t{%39d,", symbol_prefix, base[2*nstates]);
   
Line 716 
Line 711 
                         j = 1;                          j = 1;
                 } else                  } else
                         ++j;                          ++j;
   
                 fprintf(output_file, "%5d,", base[i]);                  fprintf(output_file, "%5d,", base[i]);
         }          }
   
Line 735 
Line 729 
   
         ++outline;          ++outline;
         fprintf(code_file, "#define YYTABLESIZE %d\n", high);          fprintf(code_file, "#define YYTABLESIZE %d\n", high);
         fprintf(output_file,          fprintf(output_file, "const short %stable[] =\n"
         "const short %stable[] =\n"              "\t{%40d,", symbol_prefix, table[0]);
         "\t{%40d,", symbol_prefix, table[0]);  
   
         j = 10;          j = 10;
         for (i = 1; i <= high; i++) {          for (i = 1; i <= high; i++) {
Line 748 
Line 741 
                         j = 1;                          j = 1;
                 } else                  } else
                         ++j;                          ++j;
   
                 fprintf(output_file, "%5d,", table[i]);                  fprintf(output_file, "%5d,", table[i]);
         }          }
   
Line 765 
Line 757 
         int i;          int i;
         int j;          int j;
   
         fprintf(output_file,          fprintf(output_file, "const short %scheck[] =\n"
         "const short %scheck[] =\n"              "\t{%40d,", symbol_prefix, check[0]);
         "\t{%40d,", symbol_prefix, check[0]);  
   
         j = 10;          j = 10;
         for (i = 1; i <= high; i++) {          for (i = 1; i <= high; i++) {
Line 778 
Line 769 
                         j = 1;                          j = 1;
                 } else                  } else
                         ++j;                          ++j;
   
                 fprintf(output_file, "%5d,", check[i]);                  fprintf(output_file, "%5d,", check[i]);
         }          }
   
Line 834 
Line 824 
                         if (c == '"') {                          if (c == '"') {
                                 while ((c = (unsigned char)*++s) != '"') {                                  while ((c = (unsigned char)*++s) != '"') {
                                         putc(c, code_file);                                          putc(c, code_file);
                                         if (dflag) putc(c, defines_file);                                          if (dflag)
                                                   putc(c, defines_file);
                                 }                                  }
                         } else {                          } else {
                                 do {                                  do {
                                         putc(c, code_file);                                          putc(c, code_file);
                                         if (dflag) putc(c, defines_file);                                          if (dflag)
                                                   putc(c, defines_file);
                                 } while ((c = (unsigned char)*++s));                                  } while ((c = (unsigned char)*++s));
                         }                          }
                         ++outline;                          ++outline;
Line 944 
Line 936 
                                 }                                  }
                                 j += k;                                  j += k;
                                 if (j > 80) {                                  if (j > 80) {
                                         if (!rflag) ++outline;                                          if (!rflag)
                                                   ++outline;
                                         putc('\n', output_file);                                          putc('\n', output_file);
                                         j = k;                                          j = k;
                                 }                                  }
Line 964 
Line 957 
                         } else if (s[0] == '\'') {                          } else if (s[0] == '\'') {
                                 if (s[1] == '"') {                                  if (s[1] == '"') {
                                         j += 7;                                          j += 7;
                                         if (j > 80)                                          if (j > 80) {
                                         {                                                  if (!rflag)
                                         if (!rflag) ++outline;                                                          ++outline;
                                         putc('\n', output_file);                                                  putc('\n', output_file);
                                         j = 7;                                                  j = 7;
                                         }                                          }
                                         fprintf(output_file, "\"'\\\"'\",");                                          fprintf(output_file, "\"'\\\"'\",");
                                 } else {                                  } else {
Line 978 
Line 971 
                                                 if (*s == '\\') {                                                  if (*s == '\\') {
                                                         k += 2;                                                          k += 2;
                                                         if (*++s == '\\')                                                          if (*++s == '\\')
                                                         ++k;                                                                  ++k;
                                                 }                                                  }
                                         }                                          }
                                         j += k;                                          j += k;
                                         if (j > 80) {                                          if (j > 80) {
                                                 if (!rflag) ++outline;                                                  if (!rflag)
                                                           ++outline;
                                                 putc('\n', output_file);                                                  putc('\n', output_file);
                                                 j = k;                                                  j = k;
                                         }                                          }
Line 1005 
Line 999 
                                 k = strlen(s) + 3;                                  k = strlen(s) + 3;
                                 j += k;                                  j += k;
                                 if (j > 80) {                                  if (j > 80) {
                                         if (!rflag) ++outline;                                          if (!rflag)
                                                   ++outline;
                                         putc('\n', output_file);                                          putc('\n', output_file);
                                         j = k;                                          j = k;
                                 }                                  }
                                 putc('"', output_file);                                  putc('"', output_file);
                                 do { putc(*s, output_file); } while (*++s);                                  do {
                                           putc(*s, output_file);
                                   } while (*++s);
                                 fprintf(output_file, "\",");                                  fprintf(output_file, "\",");
                         }                          }
                 } else {                  } else {
                         j += 2;                          j += 2;
                         if (j > 80) {                          if (j > 80) {
                                 if (!rflag) ++outline;                                  if (!rflag)
                                           ++outline;
                                 putc('\n', output_file);                                  putc('\n', output_file);
                                 j = 2;                                  j = 2;
                         }                          }
Line 1041 
Line 1039 
                                 fprintf(output_file, " \\\"");                                  fprintf(output_file, " \\\"");
                                 while (*++s != '"') {                                  while (*++s != '"') {
                                         if (*s == '\\') {                                          if (*s == '\\') {
                                         if (s[1] == '\\')                                                  if (s[1] == '\\')
                                                 fprintf(output_file, "\\\\\\\\");                                                          fprintf(output_file, "\\\\\\\\");
                                         else                                                  else
                                                 fprintf(output_file, "\\\\%c", s[1]);                                                          fprintf(output_file, "\\\\%c", s[1]);
                                         ++s;                                                  ++s;
                                         } else                                          } else
                                         putc(*s, output_file);                                                  putc(*s, output_file);
                                 }                                  }
                                 fprintf(output_file, "\\\"");                                  fprintf(output_file, "\\\"");
                         } else if (s[0] == '\'') {                          } else if (s[0] == '\'') {
Line 1183 
Line 1181 
         core *cp, *next;          core *cp, *next;
   
         free(state_table);          free(state_table);
         for (cp = first_state; cp; cp = next)          for (cp = first_state; cp; cp = next) {
         {                  next = cp->next;
         next = cp->next;                  free(cp);
         free(cp);  
         }          }
 }  }
   

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22