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.

57 lines
1.1 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #include "y4.h"
  3. void
  4. gin(SSIZE_T i)
  5. {
  6. SSIZE_T *p, *r, *s, *q1, *q2;
  7. /* enter gotos on nonterminal i into array a */
  8. ggreed[i] = 0;
  9. q2 = mem0+ yypgo[i+1] - 1;
  10. q1 = mem0 + yypgo[i];
  11. /* now, find a place for it */
  12. for( p=a; p < &a[ACTSIZE]; ++p )
  13. {
  14. if( *p ) continue;
  15. for( r=q1; r<q2; r+=2 )
  16. {
  17. s = p + *r +1;
  18. if( *s ) goto nextgp;
  19. if( s > maxa )
  20. {
  21. if( (maxa=s) > &a[ACTSIZE] ) error( "a array overflow" );
  22. }
  23. }
  24. /* we have found a spot */
  25. *p = *q2;
  26. if( p > maxa )
  27. {
  28. if( (maxa=p) > &a[ACTSIZE] ) error( "a array overflow" );
  29. }
  30. for( r=q1; r<q2; r+=2 )
  31. {
  32. s = p + *r + 1;
  33. *s = r[1];
  34. }
  35. pgo[i] = p-a;
  36. if( adb>1 ) fprintf( ftable, "Nonterminal %d, entry at %d\n" , i, pgo[i] );
  37. goto nextgi;
  38. nextgp:
  39. ;
  40. }
  41. error( "cannot place goto %d\n", i );
  42. nextgi:
  43. ;
  44. }