home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / c / yaccsrc2 / ygin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-19  |  1.2 KB  |  63 lines

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