home *** CD-ROM | disk | FTP | other *** search
- /*
- HEADER: CUG nnn.nn;
- TITLE: YACC - Yet Another Compilier-Compilier
- VERSION: 1.0 for IBM-PC
- DATE: JAN 28, 1985
- DESCRIPTION: LALR(1) Parser Generator. From UNIX
- KEYWORDS: Parser Generator Compilier-Compilier YACC
- SYSTEM: IBM-PC and Compatiables
- FILENAME: YCPRES.1C
- WARNINGS: This program is not for the casual user. It will
- be useful primarily to expert developers.
- CRC: N/A
- SEE-ALSO: LEX and PREP
- AUTHORS: Scott Guthery 11100 leafwood lane Austin, TX 78750
- COMPILERS: DESMET-C
- REFERENCES: UNIX Systems Manuals
- */
-
- #include "y1.h"
- /*
- * 12-Apr-83 (RBD) Add symbolic exit status
- */
- extern int * pyield[NPROD];
-
- void cpres( void )
- {
- /* compute an array with the beginnings of productions yielding given nonterminals
- The array pres points to these lists */
- /* the array pyield has the lists: the total size is only NPROD+1 */
- register **pmem;
- register c, j, i;
-
- pmem = pyield;
-
- NTLOOP(i)
- {
- c = i+NTBASE;
- pres[i] = pmem;
- fatfl = 0; /* make undefined symbols nonfatal */
- PLOOP(0,j)
- {
- if (*prdptr[j] == c) *pmem++ = prdptr[j]+1;
- }
- if(pres[i] == pmem)
- {
- error("nonterminal %s not defined!", nontrst[i].name);
- }
- }
- pres[i] = pmem;
- fatfl = 1;
- if( nerrors )
- {
- summary();
- exit(EX_ERR);
- }
- if( pmem != &pyield[nprod] ) error( "internal Yacc error: pyield %d", pmem-&pyield[nprod] );
- }
-