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.

87 lines
2.0 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #include "y3.h"
  3. void
  4. wract( int i)
  5. {
  6. /* output state i */
  7. /* temp1 has the actions, lastred the default */
  8. int p, p0;
  9. SSIZE_T p1;
  10. int ntimes, count, j;
  11. SSIZE_T tred;
  12. int flag;
  13. /* find the best choice for lastred */
  14. lastred = 0;
  15. ntimes = 0;
  16. TLOOP(j)
  17. {
  18. if( temp1[j] >= 0 ) continue;
  19. if( temp1[j]+lastred == 0 ) continue;
  20. /* count the number of appearances of temp1[j] */
  21. count = 0;
  22. tred = -temp1[j];
  23. levprd[tred] |= REDFLAG;
  24. TLOOP(p)
  25. {
  26. if( temp1[p]+tred == 0 ) ++count;
  27. }
  28. if( count >ntimes )
  29. {
  30. lastred = tred;
  31. ntimes = count;
  32. }
  33. }
  34. /* for error recovery, arrange that, if there is a shift on the
  35. /* error recovery token, `error', that the default be the error action */
  36. if( temp1[1] > 0 ) lastred = 0;
  37. /* clear out entries in temp1 which equal lastred */
  38. TLOOP(p) if( temp1[p]+lastred == 0 )temp1[p]=0;
  39. wrstate(i);
  40. defact[i] = lastred;
  41. flag = 0;
  42. TLOOP(p0)
  43. {
  44. if( (p1=temp1[p0])!=0 )
  45. {
  46. if( p1 < 0 )
  47. {
  48. p1 = -p1;
  49. goto exc;
  50. }
  51. else if( p1 == ACCEPTCODE )
  52. {
  53. p1 = -1;
  54. goto exc;
  55. }
  56. else if( p1 == ERRCODE )
  57. {
  58. p1 = 0;
  59. goto exc;
  60. exc:
  61. if( flag++ == 0 ) fprintf( ftable, "-1, %d,\n", i );
  62. fprintf( ftable, "\t%d, %d,\n", tokset[p0].value, p1 );
  63. ++zzexcp;
  64. }
  65. else
  66. {
  67. fprintf( ftemp, "%d,%d,", tokset[p0].value, p1 );
  68. ++zzacent;
  69. }
  70. }
  71. }
  72. if( flag )
  73. {
  74. defact[i] = -2;
  75. fprintf( ftable, "\t-2, %d,\n", lastred );
  76. }
  77. fprintf( ftemp, "\n" );
  78. return;
  79. }