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.

90 lines
1.7 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #include "y3.h"
  3. /*
  4. * yg2gen.3c
  5. *
  6. * Modified to make debug code conditionally compile.
  7. * 28-Aug-81
  8. * Bob Denny
  9. */
  10. void
  11. go2gen(int c)
  12. {
  13. /* output the gotos for nonterminal c */
  14. int i, work;
  15. SSIZE_T cc;
  16. struct item *p, *q;
  17. /* first, find nonterminals with gotos on c */
  18. aryfil( temp1, nnonter+1, 0 );
  19. temp1[c] = 1;
  20. work = 1;
  21. while( work )
  22. {
  23. work = 0;
  24. PLOOP(0,i)
  25. {
  26. if( (cc=prdptr[i][1]-NTBASE) >= 0 )
  27. {
  28. /* cc is a nonterminal */
  29. if( temp1[cc] != 0 )
  30. {
  31. /* cc has a goto on c */
  32. cc = *prdptr[i]-NTBASE; /* thus, the left side of production i does too */
  33. if( temp1[cc] == 0 )
  34. {
  35. work = 1;
  36. temp1[cc] = 1;
  37. }
  38. }
  39. }
  40. }
  41. }
  42. /* now, we have temp1[c] = 1 if a goto on c in closure of cc */
  43. #ifdef debug
  44. if( foutput!=NULL )
  45. {
  46. fprintf( foutput, "%s: gotos on ", nontrst[c].name );
  47. NTLOOP(i) if( temp1[i] ) fprintf( foutput, "%s ", nontrst[i].name);
  48. fprintf( foutput, "\n");
  49. }
  50. #endif
  51. /* now, go through and put gotos into tystate */
  52. aryfil( tystate, nstate, 0 );
  53. SLOOP(i)
  54. {
  55. ITMLOOP(i,p,q)
  56. {
  57. if( (cc= *p->pitem) >= NTBASE )
  58. {
  59. if( temp1[cc -= NTBASE] )
  60. {
  61. /* goto on c is possible */
  62. tystate[i] = amem[indgo[i]+c];
  63. break;
  64. }
  65. }
  66. }
  67. }
  68. }