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

  1.  
  2. # include "y1.h"     
  3. # include <stdlib.h> 
  4. /*
  5.  * 12-Apr-83 (RBD) Add symbolic exit status
  6.  */
  7. extern int * pyield[ NPROD ];
  8.  
  9. void cpres( )
  10. {
  11.   /* compute an array with the beginnings of  productions yielding given nonterminals
  12.        The array pres points to these lists */
  13.   /* the array pyield has the lists: the total size is only NPROD+1 */
  14.   register * * pmem;
  15.   register     c,
  16.                j,
  17.                i;
  18.  
  19.   pmem      = pyield;
  20.  
  21.   NTLOOP( i )
  22.     {
  23.       c     = i + NTBASE;
  24.       pres[ i ] = pmem;
  25.       fatfl = 0; /* make undefined  symbols  nonfatal */
  26.       PLOOP( 0, j )
  27.         {
  28.           if ( *prdptr[ j ] == c )
  29.             *pmem++ = prdptr[ j ] + 1;
  30.         }
  31.       if ( pres[ i ] == pmem )
  32.         {
  33.           error( "nonterminal %s not defined!", nontrst[ i ].name );
  34.         }
  35.     }
  36.   pres[ i ] = pmem;
  37.   fatfl     = 1;
  38.   if ( nerrors )
  39.     {
  40.       summary( );
  41.       exit( EX_ERR );
  42.     }
  43.   if ( pmem != &pyield[ nprod ] )
  44.     error( "internal Yacc error: pyield %d", pmem - &pyield[ nprod ] );
  45. }
  46.