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.

82 lines
1.6 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #include "y1.h"
  3. /*
  4. * ycpfir.1c
  5. *
  6. * Modified to make debug code conditionally compile.
  7. * 28-Aug-81
  8. * Bob Denny
  9. */
  10. void
  11. cpfir( void )
  12. {
  13. /* compute an array with the first of nonterminals */
  14. SSIZE_T *p, **s, i, **t, ch, changes;
  15. zzcwp = &wsets[nnonter];
  16. NTLOOP(i)
  17. {
  18. aryfil( wsets[i].ws.lset, tbitset, 0 );
  19. t = pres[i+1];
  20. for( s=pres[i]; s<t; ++s )
  21. {
  22. /* initially fill the sets */
  23. for( p = *s; (ch = *p) > 0 ; ++p )
  24. {
  25. if( ch < NTBASE )
  26. {
  27. SETBIT( wsets[i].ws.lset, ch );
  28. break;
  29. }
  30. else if( !pempty[ch-NTBASE] ) break;
  31. }
  32. }
  33. }
  34. /* now, reflect transitivity */
  35. changes = 1;
  36. while( changes )
  37. {
  38. changes = 0;
  39. NTLOOP(i)
  40. {
  41. t = pres[i+1];
  42. for( s=pres[i]; s<t; ++s )
  43. {
  44. for( p = *s; ( ch = (*p-NTBASE) ) >= 0; ++p )
  45. {
  46. changes |= setunion( wsets[i].ws.lset, wsets[ch].ws.lset );
  47. if( !pempty[ch] ) break;
  48. }
  49. }
  50. }
  51. }
  52. NTLOOP(i) pfirst[i] = flset( &wsets[i].ws );
  53. #ifdef debug
  54. if( (foutput!=NULL) )
  55. {
  56. NTLOOP(i)
  57. {
  58. fprintf( foutput, "\n%s: ", nontrst[i].name );
  59. prlook( pfirst[i] );
  60. fprintf( foutput, " %d\n", pempty[i] );
  61. }
  62. }
  63. #endif
  64. }