Source code of Windows XP (NT5)
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.

84 lines
2.2 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #include "y3.h"
  3. void
  4. output( void )
  5. {
  6. /* print the output for the states */
  7. int i, k;
  8. SSIZE_T c;
  9. register struct wset *u, *v;
  10. fprintf( ftable, "short %syyexca[] ={\n", pszPrefix ? pszPrefix : "" );
  11. SLOOP(i)
  12. {
  13. /* output the stuff for state i */
  14. nolook = !(tystate[i]==MUSTLOOKAHEAD);
  15. closure(i);
  16. /* output actions */
  17. nolook = 1;
  18. aryfil( temp1, ntokens+nnonter+1, 0 );
  19. WSLOOP(wsets,u)
  20. {
  21. c = *( u->pitem );
  22. if( c>1 && c<NTBASE && temp1[c]==0 )
  23. {
  24. WSLOOP(u,v)
  25. {
  26. if( c == *(v->pitem) ) putitem( v->pitem+1, (struct looksets *)0 );
  27. }
  28. temp1[c] = state(c);
  29. }
  30. else if( c > NTBASE && temp1[ (c -= NTBASE) + ntokens ] == 0 )
  31. {
  32. temp1[ c+ntokens ] = amem[indgo[i]+c];
  33. }
  34. }
  35. if( i == 1 ) temp1[1] = ACCEPTCODE;
  36. /* now, we have the shifts; look at the reductions */
  37. lastred = 0;
  38. WSLOOP(wsets,u)
  39. {
  40. c = *( u->pitem );
  41. if( c<=0 )
  42. {
  43. /* reduction */
  44. lastred = -c;
  45. TLOOP(k)
  46. {
  47. if( BIT(u->ws.lset,k) )
  48. {
  49. if( temp1[k] == 0 ) temp1[k] = c;
  50. else if( temp1[k]<0 )
  51. {
  52. /* reduce/reduce conflict */
  53. if( foutput!=NULL )
  54. fprintf( foutput,
  55. "\n%d: reduce/reduce conflict (red'ns %d and %d ) on %s",
  56. i, -temp1[k], lastred, symnam(k) );
  57. if( -temp1[k] > lastred ) temp1[k] = -lastred;
  58. ++zzrrconf;
  59. }
  60. else
  61. {
  62. /* potential shift/reduce conflict */
  63. precftn( lastred, k, i );
  64. }
  65. }
  66. }
  67. }
  68. }
  69. wract(i);
  70. }
  71. fprintf( ftable, "\t};\n" );
  72. wdef( "YYNPROD", nprod );
  73. }