Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.3 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #include "y3.h"
  3. void
  4. go2out( void )
  5. {
  6. /* output the gotos for the nontermninals */
  7. int i, j, k, count, times;
  8. SSIZE_T best, cbest;
  9. fprintf( ftemp, "$\n" ); /* mark begining of gotos */
  10. for( i=1; i<=nnonter; ++i )
  11. {
  12. go2gen(i);
  13. /* find the best one to make default */
  14. best = -1;
  15. times = 0;
  16. for( j=0; j<=nstate; ++j )
  17. {
  18. /* is j the most frequent */
  19. if( tystate[j] == 0 ) continue;
  20. if( tystate[j] == best ) continue;
  21. /* is tystate[j] the most frequent */
  22. count = 0;
  23. cbest = tystate[j];
  24. for( k=j; k<=nstate; ++k ) if( tystate[k]==cbest ) ++count;
  25. if( count > times )
  26. {
  27. best = cbest;
  28. times = count;
  29. }
  30. }
  31. /* best is now the default entry */
  32. zzgobest += (times-1);
  33. for( j=0; j<=nstate; ++j )
  34. {
  35. if( tystate[j] != 0 && tystate[j]!=best )
  36. {
  37. fprintf( ftemp, "%d,%d,", j, tystate[j] );
  38. zzgoent += 1;
  39. }
  40. }
  41. /* now, the default */
  42. zzgoent += 1;
  43. fprintf( ftemp, "%d\n", best );
  44. }
  45. }