home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OS2-YACC.ZIP / YCPRES.1C < prev    next >
Text File  |  1989-09-29  |  2KB  |  58 lines

  1. /*
  2.   HEADER: CUG     nnn.nn;
  3.   TITLE:     YACC - Yet Another Compilier-Compilier
  4.   VERSION:     1.0 for IBM-PC
  5.   DATE:      JAN 28, 1985
  6.   DESCRIPTION:     LALR(1) Parser Generator. From UNIX
  7.   KEYWORDS:     Parser Generator Compilier-Compilier YACC
  8.   SYSTEM:     IBM-PC and Compatiables
  9.   FILENAME:      YCPRES.1C
  10.   WARNINGS:     This program is not for the casual user. It will
  11.          be useful primarily to expert developers.
  12.   CRC:         N/A
  13.   SEE-ALSO:     LEX and PREP
  14.   AUTHORS:     Scott Guthery 11100 leafwood lane Austin, TX 78750
  15.   COMPILERS:     DESMET-C
  16.   REFERENCES:     UNIX Systems Manuals
  17. */
  18.  
  19. #include "y1.h"
  20. /*
  21.  * 12-Apr-83 (RBD) Add symbolic exit status
  22.  */
  23. extern int * pyield[NPROD];
  24.  
  25. void cpres( void )
  26.    {
  27.    /* compute an array with the beginnings of  productions yielding given nonterminals
  28.         The array pres points to these lists */
  29.    /* the array pyield has the lists: the total size is only NPROD+1 */
  30.    register **pmem;
  31.    register c, j, i;
  32.  
  33.    pmem = pyield;
  34.  
  35.    NTLOOP(i)
  36.       {
  37.       c = i+NTBASE;
  38.       pres[i] = pmem;
  39.       fatfl = 0;  /* make undefined  symbols  nonfatal */
  40.       PLOOP(0,j)
  41.          {
  42.          if (*prdptr[j] == c) *pmem++ =  prdptr[j]+1;
  43.          }
  44.       if(pres[i] == pmem)
  45.          {
  46.          error("nonterminal %s not defined!", nontrst[i].name);
  47.          }
  48.       }
  49.    pres[i] = pmem;
  50.    fatfl = 1;
  51.    if( nerrors )
  52.       {
  53.       summary();
  54.       exit(EX_ERR);
  55.       }
  56.    if( pmem != &pyield[nprod] ) error( "internal Yacc error: pyield %d", pmem-&pyield[nprod] );
  57.    }
  58.