--------------------------------- CUT HERE -----------------------------------
#! /bin/sh
# This is a shell archive (part 2 of 2), meaning:
# 1.  Remove everything above the #! /bin/sh line.
# 2.  Save the resulting text in a file.
# 3.  Execute the file with /bin/sh (not csh).
#
#     The following files will be created:
#		youtpt.c
#		y2imp.c
#		ydefin.c
#		ywract.c
#		yapack.c
#		yothrs.c
#		ywstat.c
#		ystin.c
#		system.h
#		ysumry.c
#		README
#		yg2gen.c
#		y4.h
#		ycpfir.c
#		yg2out.c
#		ycpres.c
#		y3.h
#		ygin.c
#		ymain.c
#		yprcft.c
#		ycpuni.c
#		ydfout.c
#		ywritm.c
#		yflset.c
#		yhdprd.c
#		yptitm.c
#		ycpycd.c
#		ygtnm.c
#		yskpcm.c
#		yosmry.c
#		y4imp.c
#		ynxti.c
#		ychfnd.c
#		yyless.c
#		yarout.c
#		yerror.c
#		ywarry.c
#		yfdtyp.c
#		yprlok.c
#		ystuni.c
#		yaoput.c
#		y3imp.c
#		ycstsh.c
#		ysmnam.c
#		yaryfl.c
#		ychcpy.c
#		yfnact.c
#
# Created by mark@ems (Mark H. Colburn) on Sun Feb  1 01:20:12 1987
#
if test -f 'youtpt.c'
then
echo shar: will not over-write existing "'youtpt.c'"
else
echo extracting "'youtpt.c'"
sed 's/^X//' >youtpt.c <<'SHAR_EOF'
X#include "y3.h"
X
Xoutput()
X{
X	/* print the output for the states */
X
X	int	i, k, c;
X	register struct wset *u, *v;
X
X	fprintf( ftable, "short yyexca[] ={\n" );
X
X	SLOOP(i)
X	 {
X		/* output the stuff for state i */
X		nolook = !(tystate[i] == MUSTLOOKAHEAD);
X		closure(i);
X		/* output actions */
X		nolook = 1;
X		aryfil( temp1, ntokens + nnonter + 1, 0 );
X		WSLOOP(wsets, u)
X		 {
X			c = *( u->pitem );
X			if ( c > 1 && c < NTBASE && temp1[c] == 0 ) {
X				WSLOOP(u, v)
X				 {
X					if ( c == *(v->pitem) ) 
X						putitem( v->pitem + 1, (struct looksets *)0 );
X				}
X				temp1[c] = state(c);
X			} else if ( c > NTBASE && temp1[ (c -= NTBASE) + ntokens ] == 0 ) {
X				temp1[ c+ntokens ] = amem[indgo[i]+c];
X			}
X		}
X
X		if ( i == 1 ) 
X			temp1[1] = ACCEPTCODE;
X
X		/* now, we have the shifts; look at the reductions */
X
X		lastred = 0;
X		WSLOOP(wsets, u)
X		 {
X			c = *( u->pitem );
X			if ( c <= 0 ) {
X				/* reduction */
X				lastred = -c;
X				TLOOP(k)
X				 {
X					if ( BIT(u->ws.lset, k) ) {
X						if ( temp1[k] == 0 ) 
X							temp1[k] = c;
X						else if ( temp1[k] < 0 ) {
X							/* reduce/reduce conflict */
X							if ( foutput != NULL )
X								fprintf( foutput,
X								    "\n%d: reduce/reduce conflict (red'ns %d and %d ) on %s",
X								                            i, -temp1[k], lastred, symnam(k) );
X							if ( -temp1[k] > lastred ) 
X								temp1[k] = -lastred;
X							++zzrrconf;
X						} else                     {
X							/* potential shift/reduce conflict */
X							precftn( lastred, k, i );
X						}
X					}
X				}
X			}
X		}
X		wract(i);
X	}
X
X	fprintf( ftable, "\t};\n" );
X
X	wdef( "YYNPROD", nprod );
X
X}
X
X
SHAR_EOF
if test 1597 -ne "`wc -c < 'youtpt.c'`"
then
echo shar: error transmitting "'youtpt.c'" '(should have been 1597 characters)'
fi
chmod 644 youtpt.c
fi
if test -f 'y2imp.c'
then
echo shar: will not over-write existing "'y2imp.c'"
else
echo extracting "'y2imp.c'"
sed 's/^X//' >y2imp.c <<'SHAR_EOF'
X/*
X * y2imp.c - impure date needed by routines pulled from y2.c
X *
X * HISTORY
X */
X
X#define y2imp YES
X#include "dtxtrn.h"
X
X
X/* communication variables between various I/O routines */
X
Xchar	*infile;			/* input file name */
Xint	numbval;		/* value of an input number */
Xchar	tokname[NAMESIZE];	/* input token name */
X
X
X/* storage of names */
X
Xchar	cnames[CNAMSZ];		/* token and nonterminal name storage */
Xint	cnamsz = CNAMSZ;	/* size of cnames */
Xchar	*cnamp = cnames;	/* place where next name is to be put in */
Xint	ndefout = 3;		/* number of defined symbols output */
X
X
X/* storage of types */
X
Xint	ntypes;			/* number of types defined */
Xchar	*typeset[NTYPES];	/* pointers to type tags */
X
X
X/* symbol tables for tokens and nonterminals */
X
Xint	ntokens = 0;
Xstruct toksymb tokset[NTERMS];
Xint	toklev[NTERMS];
Xint	nnonter = -1;
Xstruct ntsymb nontrst[NNONTERM];
Xint	start;			/* start symbol */
X
X
X/* assigned token type values */
X
Xint	extval = 0;
X
X
X/* input and output file descriptors */
X
XFILE   *finput;			/* yacc input file */
XFILE   *faction;		/* file for saving actions */
XFILE   *fdefine;		/* file for # defines */
XFILE   *ftable;			/* y.tab.c file */
XFILE   *ftemp;			/* tempfile to pass 2 */
XFILE   *foutput;		/* y.output file */
X
X
X/* storage for grammar rules */
X
Xint	mem0[MEMSIZE];		/* production storage */
Xint	*mem = mem0;
Xint	nprod = 1;		/* number of productions */
Xint	*prdptr[NPROD];		/* pointers to descriptions of productions */
Xint	levprd[NPROD];		/* precedence levels for the productions */
X
X
X/* Statics pulled from modules */
X
Xint	peekline;           /* from gettok() */
SHAR_EOF
if test 1586 -ne "`wc -c < 'y2imp.c'`"
then
echo shar: error transmitting "'y2imp.c'" '(should have been 1586 characters)'
fi
chmod 644 y2imp.c
fi
if test -f 'ydefin.c'
then
echo shar: will not over-write existing "'ydefin.c'"
else
echo extracting "'ydefin.c'"
sed 's/^X//' >ydefin.c <<'SHAR_EOF'
X#include "y2.h"
X
Xdefin( t, s ) 
Xregister char	*s;
X
X{
X	/*   define s to be a terminal if t=0
X        or a nonterminal if t=1         */
X
X	register val;
X
X	if (t) {
X		if ( ++nnonter >= NNONTERM ) 
X			error("too many nonterminals, limit %d", NNONTERM);
X		nontrst[nnonter].name = cstash(s);
X		return( NTBASE + nnonter );
X	}
X	/* must be a token */
X	if ( ++ntokens >= NTERMS ) 
X		error("too many terminals, limit %d", NTERMS );
X	tokset[ntokens].name = cstash(s);
X
X	/* establish value for token */
X
X	if ( s[0] == ' ' && s[2] == '\0' ) /* single character literal */
X		val = s[1];
X	else if ( s[0] == ' ' && s[1] == '\\' ) {
X		/* escape sequence */
X		if ( s[3] == '\0' ) {
X			/* single character escape sequence */
X			switch ( s[2] ) {
X				/* character which is escaped */
X			case 'n':
X				val = '\n';
X				break;
X			case 'r':
X				val = '\r';
X				break;
X			case 'b':
X				val = '\b';
X				break;
X			case 't':
X				val = '\t';
X				break;
X			case 'f':
X				val = '\f';
X				break;
X			case '\'':
X				val = '\'';
X				break;
X			case '"':
X				val = '"';
X				break;
X			case '\\':
X				val = '\\';
X				break;
X			default:
X				error( "invalid escape" );
X			}
X		} else if ( s[2] <= '7' && s[2] >= '0' ) {
X			/* \nnn sequence */
X			if ( s[3] < '0' || s[3] > '7' || s[4] < '0' || 
X			    s[4] > '7' || s[5] != '\0' ) 
X				error("illegal \\nnn construction" );
X			val = 64 * s[2] + 8 * s[3] + s[4] - 73 * '0';
X			if ( val == 0 ) 
X				error( "'\\000' is illegal" );
X		}
X	} else      {
X		val = extval++;
X	}
X	tokset[ntokens].value = val;
X	toklev[ntokens] = 0;
X	return( ntokens );
X}
X
X
SHAR_EOF
if test 1550 -ne "`wc -c < 'ydefin.c'`"
then
echo shar: error transmitting "'ydefin.c'" '(should have been 1550 characters)'
fi
chmod 644 ydefin.c
fi
if test -f 'ywract.c'
then
echo shar: will not over-write existing "'ywract.c'"
else
echo extracting "'ywract.c'"
sed 's/^X//' >ywract.c <<'SHAR_EOF'
X#include "y3.h"
X
Xwract(i)
X{
X	/* output state i */
X	/* temp1 has the actions, lastred the default */
X	int	p, p0, p1;
X	int	ntimes, tred, count, j;
X	int	flag;
X
X	/* find the best choice for lastred */
X
X	lastred = 0;
X	ntimes = 0;
X	TLOOP(j)
X	 {
X		if ( temp1[j] >= 0 ) 
X			continue;
X		if ( temp1[j] + lastred == 0 ) 
X			continue;
X		/* count the number of appearances of temp1[j] */
X		count = 0;
X		tred = -temp1[j];
X		levprd[tred] |= REDFLAG;
X		TLOOP(p)
X		 {
X			if ( temp1[p] + tred == 0 ) 
X				++count;
X		}
X		if ( count > ntimes ) {
X			lastred = tred;
X			ntimes = count;
X		}
X	}
X
X	/* for error recovery, arrange that, if there is a shift on the
X        /* error recovery token, `error', that the default be the error action */
X	if ( temp1[1] > 0 ) 
X		lastred = 0;
X
X	/* clear out entries in temp1 which equal lastred */
X	TLOOP(p) if ( temp1[p] + lastred == 0 )
X		temp1[p] = 0;
X
X	wrstate(i);
X	defact[i] = lastred;
X
X	flag = 0;
X	TLOOP(p0)
X	 {
X		if ( (p1 = temp1[p0]) != 0 ) {
X			if ( p1 < 0 ) {
X				p1 = -p1;
X				goto exc;
X			} else if ( p1 == ACCEPTCODE ) {
X				p1 = -1;
X				goto exc;
X			} else if ( p1 == ERRCODE ) {
X				p1 = 0;
X				goto exc;
Xexc:
X				if ( flag++ == 0 ) 
X					fprintf( ftable, "-1, %d,\n", i );
X				fprintf( ftable, "\t%d, %d,\n", tokset[p0].value, p1 );
X				++zzexcp;
X			} else            {
X				fprintf( ftemp, "%d,%d,", tokset[p0].value, p1 );
X				++zzacent;
X			}
X		}
X	}
X	if ( flag ) {
X		defact[i] = -2;
X		fprintf( ftable, "\t-2, %d,\n", lastred );
X	}
X	fprintf( ftemp, "\n" );
X	return;
X}
X
X
SHAR_EOF
if test 1499 -ne "`wc -c < 'ywract.c'`"
then
echo shar: error transmitting "'ywract.c'" '(should have been 1499 characters)'
fi
chmod 644 ywract.c
fi
if test -f 'yapack.c'
then
echo shar: will not over-write existing "'yapack.c'"
else
echo extracting "'yapack.c'"
sed 's/^X//' >yapack.c <<'SHAR_EOF'
X/*
X * yapack.c -
X *
X * HISTORY
X * {1}	28-Aug-81  Bob Denny
X * 	Modified to make debug code conditionally compile.
X */
X
X#include "y3.h"
X
X
Xint	apack(p, n )
Xint	*p;
X{
X	/* pack state i from temp1 into amem */
X	int	off;
X	register *pp, *qq, *rr;
X	int	*q, *r;
X
X	/*
X	 * we don't need to worry about checking because we we will only
X	 * look entries known to be there... 
X	 */
X
X	/* eliminate leading and trailing 0's */
X
X	q = p + n;
X	for (pp = p, off = 0; *pp == 0 && pp <= q; ++pp, --off)	
X		/* VOID */;
X	if (pp > q)
X		return (0);	/* no actions */
X	p = pp;
X
X	/* now, find a place for the elements from p to q, inclusive */
X
X	r = &amem[ACTSIZE - 1];
X	for (rr = amem; rr <= r; ++rr, ++off) {
X		/* try rr */
X		for (qq = rr, pp = p; pp <= q; ++pp, ++qq) {
X			if (*pp != 0) {
X				if (*pp != *qq && *qq != 0)
X					goto nextk;
X			}
X		}
X
X		/* we have found an acceptable k */
X
X#ifdef debug
X		if (foutput != NULL)
X			fprintf(foutput, "off = %d, k = %d\n", off, rr - amem);
X#endif
X		for (qq = rr, pp = p; pp <= q; ++pp, ++qq) {
X			if (*pp) {
X				if (qq > r)
X					error("action table overflow");
X				if (qq > memp)
X					memp = qq;
X				*qq = *pp;
X			}
X		}
X#ifdef debug
X		if (foutput != NULL) {
X			for (pp = amem; pp <= memp; pp += 10) {
X				fprintf(foutput, "\t");
X				for (qq = pp; qq <= pp + 9; ++qq)
X					fprintf(foutput, "%d ", *qq);
X				fprintf(foutput, "\n");
X			}
X		}
X#endif
X		return (off);
Xnextk:
X		;
X	}
X	error("no space in action table");
X	/* NOTREACHED */
X}
X
X
SHAR_EOF
if test 1450 -ne "`wc -c < 'yapack.c'`"
then
echo shar: error transmitting "'yapack.c'" '(should have been 1450 characters)'
fi
chmod 644 yapack.c
fi
if test -f 'yothrs.c'
then
echo shar: will not over-write existing "'yothrs.c'"
else
echo extracting "'yothrs.c'"
sed 's/^X//' >yothrs.c <<'SHAR_EOF'
X/* Edits:
X *      06-Dec-80 Original code broken out of y1.c.
X *      18-Dec-80 Add conditional code for Decus for tempfile deletion.
X */
X
X#include "y1.h"
X
Xint	others()
X{
X	/* put out other arrays, copy the parsers */
X	register c, i, j;
X
X	finput = (FILE * )fopen(PARSER, "r");
X	if (finput == (FILE * )NULL)
X		error("cannot find parser %s", PARSER);
X
X	warray("yyr1", levprd, nprod);
X
X	aryfil(temp1, nprod, 0);
X	PLOOP(1, i) temp1[i] = prdptr[i + 1] - prdptr[i] - 2;
X	warray("yyr2", temp1, nprod);
X
X	aryfil(temp1, nstate, -1000);
X	TLOOP(i) {
X		for (j = tstates[i]; j != 0; j = mstates[j]) {
X			temp1[j] = tokset[i].value;
X		}
X	}
X	NTLOOP(i) {
X		for (j = ntstates[i]; j != 0; j = mstates[j]) {
X			temp1[j] = -i;
X		}
X	}
X	warray("yychk", temp1, nstate);
X
X	warray("yydef", defact, nstate);
X
X	/* copy parser text */
X
X	while ((c = unix_getc(finput)) != EOF) {
X		if (c == '$') {
X			if ((c = unix_getc(finput)) != 'A')
X				putc('$', ftable);
X			else {
X				/* copy actions */
X				faction = fopen(ACTNAME, "r");
X				if (faction == NULL)
X					error("cannot reopen action tempfile");
X				while ((c = unix_getc(faction)) != EOF)
X					putc(c, ftable);
X				fclose(faction);
X				ZAPFILE(ACTNAME);
X				c = unix_getc(finput);
X			}
X		}
X		putc(c, ftable);
X	}
X	fclose(ftable);
X}
X
X
Xint	unix_getc(iop)
XFILE	*iop;
X{
X	int	c;
X
X	c = getc(iop);
X	/* Stop on Control-Z */
X	if (c == '\032')
X		return (EOF);
X	else
X		return (c);
X}
X
X
SHAR_EOF
if test 1395 -ne "`wc -c < 'yothrs.c'`"
then
echo shar: error transmitting "'yothrs.c'" '(should have been 1395 characters)'
fi
chmod 644 yothrs.c
fi
if test -f 'ywstat.c'
then
echo shar: will not over-write existing "'ywstat.c'"
else
echo extracting "'ywstat.c'"
sed 's/^X//' >ywstat.c <<'SHAR_EOF'
X#include "y3.h"
X
Xwrstate(i)
X{
X	/* writes state i */
X	register j0, j1;
X	register struct item *pp, *qq;
X	register struct wset *u;
X
X	if ( foutput == NULL ) 
X		return;
X	fprintf( foutput, "\nstate %d\n", i);
X	ITMLOOP(i, pp, qq) fprintf( foutput, "\t%s\n", writem(pp->pitem));
X	if ( tystate[i] == MUSTLOOKAHEAD ) {
X		/* print out empty productions in closure */
X		WSLOOP( wsets + (pstate[i+1] - pstate[i]), u )
X		 {
X			if ( *(u->pitem) < 0 ) 
X				fprintf( foutput, "\t%s\n", writem(u->pitem) );
X		}
X	}
X
X	/* check for state equal to another */
X
X	TLOOP(j0) if ( (j1 = temp1[j0]) != 0 ) {
X		fprintf( foutput, "\n\t%s  ", symnam(j0) );
X		if ( j1 > 0 ) {
X			/* shift, error, or accept */
X			if ( j1 == ACCEPTCODE ) 
X				fprintf( foutput,  "accept" );
X			else if ( j1 == ERRCODE ) 
X				fprintf( foutput, "error" );
X			else 
X				fprintf( foutput,  "shift %d", j1 );
X		} else 
X			fprintf( foutput, "reduce %d", -j1 );
X	}
X
X	/* output the final production */
X
X	if ( lastred ) 
X		fprintf( foutput, "\n\t.  reduce %d\n\n", lastred );
X	else 
X		fprintf( foutput, "\n\t.  error\n\n" );
X
X	/* now, output nonterminal actions */
X
X	j1 = ntokens;
X	for ( j0 = 1; j0 <= nnonter; ++j0 ) {
X		if ( temp1[++j1] ) 
X			fprintf( foutput, "\t%s  goto %d\n", symnam( j0 + NTBASE), temp1[j1] );
X	}
X
X}
X
X
Xwdef( s, n ) 
Xchar	*s;
X
X{
X	/* output a definition of s to the value n */
X	fprintf( ftable, "# define %s %d\n", s, n );
X}
X
X
SHAR_EOF
if test 1388 -ne "`wc -c < 'ywstat.c'`"
then
echo shar: error transmitting "'ywstat.c'" '(should have been 1388 characters)'
fi
chmod 644 ywstat.c
fi
if test -f 'ystin.c'
then
echo shar: will not over-write existing "'ystin.c'"
else
echo extracting "'ystin.c'"
sed 's/^X//' >ystin.c <<'SHAR_EOF'
X#include "y4.h"
X
Xstin(i)
X{
X	register *r, *s, n, flag, j, *q1, *q2;
X
X	greed[i] = 0;
X
X	/* enter state i into the a array */
X
X	q2 = mem0 + yypact[i+1];
X	q1 = mem0 + yypact[i];
X	/* find an acceptable place */
X
X	for ( n = -maxoff; n < ACTSIZE; ++n ) {
X
X		flag = 0;
X		for ( r = q1; r < q2; r += 2 ) {
X			if ( (s = *r + n + a ) < a ) 
X				goto nextn;
X			if ( *s == 0 ) 
X				++flag;
X			else if ( *s != r[1] ) 
X				goto nextn;
X		}
X
X		/* check that the position equals another only if the states are identical */
X
X		for ( j = 0; j < nstate; ++j ) {
X			if ( pa[j] == n ) {
X				if ( flag ) 
X					goto nextn;  /* we have some disagreement */
X				if ( yypact[j+1] + yypact[i] == yypact[j] + yypact[i+1] ) {
X					/* states are equal */
X					pa[i] = n;
X					if ( adb > 1 ) 
X						fprintf( ftable, "State %d: entry at %d equals state %d\n",
X						    i, n, j );
X					return;
X				}
X				goto nextn;  /* we have some disagreement */
X			}
X		}
X
X		for ( r = q1; r < q2; r += 2 ) {
X			if ( (s = *r + n + a ) >= &a[ACTSIZE] ) 
X				error( "out of space in optimizer a array" );
X			if ( s > maxa ) 
X				maxa = s;
X			if ( *s != 0 && *s != r[1] ) 
X				error( "clobber of a array, pos'n %d, by %d", s - a, r[1] );
X			*s = r[1];
X		}
X		pa[i] = n;
X		if ( adb > 1 ) 
X			fprintf( ftable, "State %d: entry at %d\n", i, pa[i] );
X		return;
X
Xnextn:
X		;
X	}
X
X	error( "Error; failure to place state %d\n", i );
X}
X
X
SHAR_EOF
if test 1373 -ne "`wc -c < 'ystin.c'`"
then
echo shar: error transmitting "'ystin.c'" '(should have been 1373 characters)'
fi
chmod 644 ystin.c
fi
if test -f 'system.h'
then
echo shar: will not over-write existing "'system.h'"
else
echo extracting "'system.h'"
sed 's/^X//' >system.h <<'SHAR_EOF'
X/*                             *********************
X *                             *  S Y S T E M . H  *
X *                             *********************
X *
X * This file replaces the original "files." header file. It defines, for
X * the IBM PC/XT version, the target parser function source file, overriding
X * file name string defines, and other system-specific definitions and
X * parameters. 
X *
X * Bob Denny    06-Dec-80
X *
X * Edits:
X *              18-Dec-80  ZAPFILE no longer used in Decus Yacc.
X *                         Parser file renamed yypars.c
X *
X *              28-Aug-81  Temp files for RSX have specific version
X *                         numbers of 1 to avoid multi-versions. Rename
X *                         parser info file ".i".
X *
X *              12-Apr-83  Add FNAMESIZE & EX_xxx parameters.
X *
X *Scott Guthery 23-Dec-83  Adapt for the IBM PC/XT & DeSmet C compiler.
X *
X */
X
X/* Define WORD32 if target machine is a 32 bitter */
X#define WORD32
X
X/*
X * Target parser source file
X */
X# define PARSER "yypars.c"
X
X/*
X * basic size of the Yacc implementation
X */
X# define MEDIUM
X
X/*
X * Table size for this Yacc
X */
X# define HUGETAB YES
X
X/*
X * Filespec definitions
X */
X# define ACTNAME "yacc2.tmp"
X# define TEMPNAME "yacc1.tmp"
X# define FNAMESIZE 24
X
X/*
X * Exit status values
X */
X#define EX_SUC 1
X#define EX_WAR 0
X#define EX_ERR 2
X#define EX_SEV 4
SHAR_EOF
if test 1368 -ne "`wc -c < 'system.h'`"
then
echo shar: error transmitting "'system.h'" '(should have been 1368 characters)'
fi
chmod 644 system.h
fi
if test -f 'ysumry.c'
then
echo shar: will not over-write existing "'ysumry.c'"
else
echo extracting "'ysumry.c'"
sed 's/^X//' >ysumry.c <<'SHAR_EOF'
X#include "y1.h"
X
Xsummary()
X{
X	/* output the summary on the tty */
X
X	if ( foutput != NULL ) {
X		fprintf( foutput, "\n%d/%d terminals, %d/%d nonterminals\n", ntokens, NTERMS,
X		    nnonter, NNONTERM );
X		fprintf( foutput, "%d/%d grammar rules, %d/%d states\n", nprod, NPROD, nstate, NSTATES );
X		fprintf( foutput, "%d shift/reduce, %d reduce/reduce conflicts reported\n", zzsrconf, zzrrconf );
X		fprintf( foutput, "%d/%d working sets used\n", zzcwp - wsets,  WSETSIZE );
X		fprintf( foutput, "memory: states,etc. %d/%d, parser %d/%d\n", zzmemsz - mem0, MEMSIZE,
X		    memp - amem, ACTSIZE );
X		fprintf( foutput, "%d/%d distinct lookahead sets\n", nlset, LSETSIZE );
X		fprintf( foutput, "%d extra closures\n", zzclose - 2 * nstate );
X		fprintf( foutput, "%d shift entries, %d exceptions\n", zzacent, zzexcp );
X		fprintf( foutput, "%d goto entries\n", zzgoent );
X		fprintf( foutput, "%d entries saved by goto default\n", zzgobest );
X	}
X	if ( zzsrconf != 0 || zzrrconf != 0 ) {
X		fprintf( stdout, "\nconflicts: ");
X		if ( zzsrconf )
X			fprintf( stdout, "%d shift/reduce" , zzsrconf );
X		if ( zzsrconf && zzrrconf )
X			fprintf( stdout, ", " );
X		if ( zzrrconf )
X			fprintf( stdout, "%d reduce/reduce" , zzrrconf );
X		fprintf( stdout, "\n" );
X	}
X
X	fclose( ftemp );
X	if ( fdefine != NULL ) 
X		fclose( fdefine );
X}
X
X
SHAR_EOF
if test 1307 -ne "`wc -c < 'ysumry.c'`"
then
echo shar: error transmitting "'ysumry.c'" '(should have been 1307 characters)'
fi
chmod 644 ysumry.c
fi
if test -f 'README'
then
echo shar: will not over-write existing "'README'"
else
echo extracting "'README'"
sed 's/^X//' >README <<'SHAR_EOF'
X                                                Sun Feb  1 00:52:01 CST 1987
X
X                                UNIX/MS-DOS YACC
X
X	Here is a copy of a public domain version of YACC.  This version
X	is a derivative of the DECUS yacc (at lease some where along the
X	it come from there anyways).  When I got it it had been modified
X	to run under MS-DOS on IBM-PC's.  I have modified it to, (once
X	again) run under UNIX, as well as PC-DOS.
X
X	It runs fine under System V.2 on an Arete 1200, as well as PC-DOS
X	3.1.  I do not have access to a Berkley machine, so I have not
X	been able to test it in that environment.
X
X	I will post updates and patches to this version of YACC as I work 
X	with it more, and as I get comments from other people who use it.
X	If you have any enhancements, portability problems or comments,
X	please let me know and I will put them in.
X
X	For those of you who have been wanting YACC on a PC, here it is.
X
X	In order to install the package, look at the #defines in system.h
X	and dtxtrn.h and modify them to match you machine configuration
X	and needs/desires.  Then type make.
X
X
X	Mark H. Colburn          m...@ems.uucp      
X	EMS/McGraw-Hill          {rutgers|amdahl|ihnp4}!meccts!ems!mark
X	9855 West 78th Street     
X	Eden Prairie, MN 55344   (612) 829-8200 x235
SHAR_EOF
if test 1277 -ne "`wc -c < 'README'`"
then
echo shar: error transmitting "'README'" '(should have been 1277 characters)'
fi
chmod 644 README
fi
if test -f 'yg2gen.c'
then
echo shar: will not over-write existing "'yg2gen.c'"
else
echo extracting "'yg2gen.c'"
sed 's/^X//' >yg2gen.c <<'SHAR_EOF'
X#include "y3.h"
X
X/*
X * yg2gen.3c
X *
X * Modified to make debug code conditionally compile.
X * 28-Aug-81
X * Bob Denny
X */
X
Xgo2gen(c)
X
X{
X	/* output the gotos for nonterminal c */
X
X	int	i, work, cc;
X	struct item *p, *q;
X
X
X	/* first, find nonterminals with gotos on c */
X
X	aryfil( temp1, nnonter + 1, 0 );
X	temp1[c] = 1;
X
X	work = 1;
X	while ( work ) {
X
X		work = 0;
X		PLOOP(0, i)
X
X		 {
X			if ( (cc = prdptr[i][1] - NTBASE) >= 0 ) {
X
X				/* cc is a nonterminal */
X				if ( temp1[cc] != 0 ) {
X
X					/* cc has a goto on c */
X					cc = *prdptr[i] - NTBASE; /* thus, the left side of production i does too */
X					if ( temp1[cc] == 0 ) {
X
X						work = 1;
X						temp1[cc] = 1;
X					}
X				}
X			}
X		}
X	}
X
X	/* now, we have temp1[c] = 1 if a goto on c in closure of cc */
X
X#ifdef debug
X	if ( foutput != NULL ) {
X
X		fprintf( foutput, "%s: gotos on ", nontrst[c].name );
X		NTLOOP(i) if ( temp1[i] ) 
X			fprintf( foutput, "%s ", nontrst[i].name);
X		fprintf( foutput, "\n");
X	}
X#endif
X	/* now, go through and put gotos into tystate */
X
X	aryfil( tystate, nstate, 0 );
X	SLOOP(i)
X
X	 {
X		ITMLOOP(i, p, q)
X
X		 {
X			if ( (cc = *p->pitem) >= NTBASE ) {
X
X				if ( temp1[cc -= NTBASE] ) {
X
X					/* goto on c is possible */
X					tystate[i] = amem[indgo[i]+c];
X					break;
X				}
X			}
X		}
X	}
X}
X
X
SHAR_EOF
if test 1263 -ne "`wc -c < 'yg2gen.c'`"
then
echo shar: error transmitting "'yg2gen.c'" '(should have been 1263 characters)'
fi
chmod 644 yg2gen.c
fi
if test -f 'y4.h'
then
echo shar: will not over-write existing "'y4.h'"
else
echo extracting "'y4.h'"
sed 's/^X//' >y4.h <<'SHAR_EOF'
X/*****************************************************************************/
X/*                             *************                                 */
X/*                             *  Y 4 . H  *                                 */
X/*                             *************                                 */
X/*                                                                           */
X/* This file contains the external declarations needed to hook Yacc modules  */
X/* which were originally in Y4.C to their impure data in Y4IMP.4C. Also does */
X/* the include of the original data/external file DTXTRN.H.                  */
X/*                                                                           */
X/*****************************************************************************/
X
X# include "dtxtrn.h"
X
X# define a amem
X# define pa indgo
X# define yypact temp1
X# define greed tystate
X
X# define NOMORE -1000
X
Xextern int	*ggreed;
Xextern int	*pgo;
Xextern int	*yypgo;
X
Xextern int	maxspr;              /* maximum spread of any entry */
Xextern int	maxoff;              /* maximum offset into a array */
Xextern int	*pmem;
Xextern int	*maxa;
Xextern int	nxdb;
Xextern int	adb;
SHAR_EOF
if test 1184 -ne "`wc -c < 'y4.h'`"
then
echo shar: error transmitting "'y4.h'" '(should have been 1184 characters)'
fi
chmod 644 y4.h
fi
if test -f 'ycpfir.c'
then
echo shar: will not over-write existing "'ycpfir.c'"
else
echo extracting "'ycpfir.c'"
sed 's/^X//' >ycpfir.c <<'SHAR_EOF'
X/*
X * ycpfir.c - compute an array with the first of nonterminals
X *
X * HISTORY
X * {1}	28-Aug-81  Bob Denny
X * 	Modified to make debug code conditionally compile.
X * 
X */
X
X#include "y1.h"
X
X
X
Xint	cpfir()
X{
X	/* compute an array with the first of nonterminals */
X	register *p, **s, i, **t, ch, changes;
X
X	zzcwp = &wsets[nnonter];
X	NTLOOP(i) {
X		aryfil(wsets[i].ws.lset, tbitset, 0);
X		t = pres[i + 1];
X		for (s = pres[i]; s < t; ++s) {
X			/* initially fill the sets */
X			for (p = *s; (ch = *p) > 0; ++p) {
X				if (ch < NTBASE) {
X					SETBIT(wsets[i].ws.lset, ch);
X					break;
X				} else if (!pempty[ch - NTBASE])
X					break;
X			}
X		}
X	}
X
X	/* now, reflect transitivity */
X
X	changes = 1;
X	while (changes) {
X		changes = 0;
X		NTLOOP(i) {
X			t = pres[i + 1];
X			for (s = pres[i]; s < t; ++s) {
X				for (p = *s; (ch = (*p - NTBASE)) >= 0; ++p) {
X					changes |= setunion(wsets[i].ws.lset, wsets[ch].ws.lset);
X					if (!pempty[ch])
X						break;
X				}
X			}
X		}
X	}
X
X	NTLOOP(i) pfirst[i] = flset(&wsets[i].ws);
X#ifdef debug
X	if ((foutput != NULL)) {
X		NTLOOP(i) {
X			fprintf(foutput, "\n%s: ", nontrst[i].name);
X			prlook(pfirst[i]);
X			fprintf(foutput, " %d\n", pempty[i]);
X		}
X	}
X#endif
X}
X
X
SHAR_EOF
if test 1180 -ne "`wc -c < 'ycpfir.c'`"
then
echo shar: error transmitting "'ycpfir.c'" '(should have been 1180 characters)'
fi
chmod 644 ycpfir.c
fi
if test -f 'yg2out.c'
then
echo shar: will not over-write existing "'yg2out.c'"
else
echo extracting "'yg2out.c'"
sed 's/^X//' >yg2out.c <<'SHAR_EOF'
X#include "y3.h"
X
Xgo2out()
X{
X	/* output the gotos for the nontermninals */
X	int	i, j, k, best, count, cbest, times;
X
X	fprintf( ftemp, "$\n" );  /* mark begining of gotos */
X
X	for ( i = 1; i <= nnonter; ++i ) {
X		go2gen(i);
X
X		/* find the best one to make default */
X
X		best = -1;
X		times = 0;
X
X		for ( j = 0; j <= nstate; ++j ) {
X			/* is j the most frequent */
X			if ( tystate[j] == 0 ) 
X				continue;
X			if ( tystate[j] == best ) 
X				continue;
X
X			/* is tystate[j] the most frequent */
X
X			count = 0;
X			cbest = tystate[j];
X
X			for ( k = j; k <= nstate; ++k ) 
X				if ( tystate[k] == cbest ) 
X					++count;
X
X			if ( count > times ) {
X				best = cbest;
X				times = count;
X			}
X		}
X
X		/* best is now the default entry */
X
X		zzgobest += (times - 1);
X		for ( j = 0; j <= nstate; ++j ) {
X			if ( tystate[j] != 0 && tystate[j] != best ) {
X				fprintf( ftemp, "%d,%d,", j, tystate[j] );
X				zzgoent += 1;
X			}
X		}
X
X		/* now, the default */
X
X		zzgoent += 1;
X		fprintf( ftemp, "%d\n", best );
X
X	}
X}
X
X
SHAR_EOF
if test 994 -ne "`wc -c < 'yg2out.c'`"
then
echo shar: error transmitting "'yg2out.c'" '(should have been 994 characters)'
fi
chmod 644 yg2out.c
fi
if test -f 'ycpres.c'
then
echo shar: will not over-write existing "'ycpres.c'"
else
echo extracting "'ycpres.c'"
sed 's/^X//' >ycpres.c <<'SHAR_EOF'
X/*
X * ycpres.c - compute an array with the beginnings of productions
X *
X * compute an array with the beginnings of productions yielding given
X * nonterminals The array pres points to these lists the array pyield has
X * the lists:  the total size is only NPROD+1 
X *
X * HISTORY 
X * {1}  12-Apr-83 Bob Denny 
X *      Add symbol exit status.
X * 
X */
X
X#include "y1.h"
X
X
Xextern int	*pyield[NPROD];
X
X
Xint	cpres()
X{
X	register **pmem;
X	register c, j, i;
X
X	pmem = pyield;
X
X	NTLOOP(i) {
X		c = i + NTBASE;
X		pres[i] = pmem;
X		fatfl = 0;	/* make undefined  symbols  nonfatal */
X		PLOOP(0, j) {
X			if (*prdptr[j] == c)
X				*pmem++ = prdptr[j] + 1;
X		}
X		if (pres[i] == pmem) {
X			error("nonterminal %s not defined!", nontrst[i].name);
X		}
X	}
X	pres[i] = pmem;
X	fatfl = 1;
X	if (nerrors) {
X		summary();
X		exit(EX_ERR);
X	}
X	if (pmem != &pyield[nprod])
X		error("internal Yacc error: pyield %d", pmem - &pyield[nprod]);
X}
X
X
SHAR_EOF
if test 905 -ne "`wc -c < 'ycpres.c'`"
then
echo shar: error transmitting "'ycpres.c'" '(should have been 905 characters)'
fi
chmod 644 ycpres.c
fi
if test -f 'y3.h'
then
echo shar: will not over-write existing "'y3.h'"
else
echo extracting "'y3.h'"
sed 's/^X//' >y3.h <<'SHAR_EOF'
X/*****************************************************************************/
X/*                             *************                                 */
X/*                             *  Y 3 . H  *                                 */
X/*                             *************                                 */
X/*                                                                           */
X/* This file contains the external declarations needed to hook Yacc modules  */
X/* which were originally in Y3.C to their impure data in Y3IMP.3C. Also does */
X/* the include of the original data/external file DTXTRN.H.                  */
X/*                                                                           */
X/*****************************************************************************/
X
X#include "dtxtrn.h"
X
Xextern int	lastred;   /* the number of the last reduction of a state */
SHAR_EOF
if test 894 -ne "`wc -c < 'y3.h'`"
then
echo shar: error transmitting "'y3.h'" '(should have been 894 characters)'
fi
chmod 644 y3.h
fi
if test -f 'ygin.c'
then
echo shar: will not over-write existing "'ygin.c'"
else
echo extracting "'ygin.c'"
sed 's/^X//' >ygin.c <<'SHAR_EOF'
X#include "y4.h"
X
Xgin(i)
X{
X
X	register *p, *r, *s, *q1, *q2;
X
X	/* enter gotos on nonterminal i into array a */
X
X	ggreed[i] = 0;
X
X	q2 = mem0 + yypgo[i+1] - 1;
X	q1 = mem0 + yypgo[i];
X
X	/* now, find a place for it */
X
X	for ( p = a; p < &a[ACTSIZE]; ++p ) {
X		if ( *p ) 
X			continue;
X		for ( r = q1; r < q2; r += 2 ) {
X			s = p + *r + 1;
X			if ( *s ) 
X				goto nextgp;
X			if ( s > maxa ) {
X				if ( (maxa = s) > &a[ACTSIZE] ) 
X					error( "a array overflow" );
X			}
X		}
X		/* we have found a spot */
X
X		*p = *q2;
X		if ( p > maxa ) {
X			if ( (maxa = p) > &a[ACTSIZE] ) 
X				error( "a array overflow" );
X		}
X		for ( r = q1; r < q2; r += 2 ) {
X			s = p + *r + 1;
X			*s = r[1];
X		}
X
X		pgo[i] = p - a;
X		if ( adb > 1 ) 
X			fprintf( ftable, "Nonterminal %d, entry at %d\n" , i, pgo[i] );
X		goto nextgi;
X
Xnextgp:
X		;
X	}
X
X	error( "cannot place goto %d\n", i );
X
Xnextgi:
X	;
X}
X
X
SHAR_EOF
if test 862 -ne "`wc -c < 'ygin.c'`"
then
echo shar: error transmitting "'ygin.c'" '(should have been 862 characters)'
fi
chmod 644 ygin.c
fi
if test -f 'ymain.c'
then
echo shar: will not over-write existing "'ymain.c'"
else
echo extracting "'ymain.c'"
sed 's/^X//' >ymain.c <<'SHAR_EOF'
X#include "y1.h"
X/*
X * 12-Apr-83 (RBD) Add symbolic exit status
X */
Xmain(argc, argv) 
Xint	argc;
Xchar	*argv[];
X
X{
X
X	puts("Setup...");
X	setup(argc, argv); /* initialize and read productions */
X	puts("cpres ...");
X	tbitset = NWORDS(ntokens);
X	cpres(); /* make table of which productions yield a given nonterminal */
X	puts("cempty ...");
X	cempty(); /* make a table of which nonterminals can match the empty string */
X	puts("cpfir ...");
X	cpfir(); /* make a table of firsts of nonterminals */
X	puts("stagen ...");
X	stagen(); /* generate the states */
X	puts("output ...");
X	output();  /* write the states and the tables */
X	puts("go2out ...");
X	go2out();
X	puts("hideprod ...");
X	hideprod();
X	puts("summary ...");
X	summary();
X	puts("callopt ...");
X	callopt();
X	puts("others ...");
X	others();
X	puts("DONE !!!");
X	exit(EX_SUC);
X}
X
X
SHAR_EOF
if test 822 -ne "`wc -c < 'ymain.c'`"
then
echo shar: error transmitting "'ymain.c'" '(should have been 822 characters)'
fi
chmod 644 ymain.c
fi
if test -f 'yprcft.c'
then
echo shar: will not over-write existing "'yprcft.c'"
else
echo extracting "'yprcft.c'"
sed 's/^X//' >yprcft.c <<'SHAR_EOF'
X#include "y3.h"
X
Xprecftn(r, t, s)
X{
X	/* decide a shift/reduce conflict by precedence.*/
X	/* r is a rule number, t a token number */
X	/* the conflict is in state s */
X	/* temp1[t] is changed to reflect the action */
X
X	int	lp, lt, action;
X
X	lp = levprd[r];
X	lt = toklev[t];
X	if ( PLEVEL(lt) == 0 || PLEVEL(lp) == 0 ) {
X		/* conflict */
X		if ( foutput != NULL ) 
X			fprintf( foutput, "\n%d: shift/reduce conflict (shift %d, red'n %d) on %s",
X			    s, temp1[t], r, symnam(t) );
X		++zzsrconf;
X		return;
X	}
X	if ( PLEVEL(lt) == PLEVEL(lp) ) 
X		action = ASSOC(lt);
X	else if ( PLEVEL(lt) > PLEVEL(lp) ) 
X		action = RASC;  /* shift */
X	else 
X		action = LASC;  /* reduce */
X
X	switch ( action ) {
X
X	case BASC:  /* error action */
X		temp1[t] = ERRCODE;
X		return;
X
X	case LASC:  /* reduce */
X		temp1[t] = -r;
X		return;
X
X	}
X}
X
X
SHAR_EOF
if test 813 -ne "`wc -c < 'yprcft.c'`"
then
echo shar: error transmitting "'yprcft.c'" '(should have been 813 characters)'
fi
chmod 644 yprcft.c
fi
if test -f 'ycpuni.c'
then
echo shar: will not over-write existing "'ycpuni.c'"
else
echo extracting "'ycpuni.c'"
sed 's/^X//' >ycpuni.c <<'SHAR_EOF'
X/*
X * ycpuni.c - copy the union declaration & define file (if present) to output
X *
X * HISTORY
X */
X
X#include "y2.h"
X
Xint	cpyunion()
X{
X	int	level, c;
X	fprintf(ftable, "\n# line %d\n", lineno);
X	fprintf(ftable, "\n#define UNION 1\n");
X	fprintf(ftable, "typedef union ");
X	if (fdefine)
X		fprintf(fdefine, "\ntypedef union ");
X
X	level = 0;
X	for (; ; ) {
X		if ((c = unix_getc(finput)) < 0)
X			error("EOF encountered while processing %%union");
X		putc(c, ftable);
X		if (fdefine)
X			putc(c, fdefine);
X
X		switch (c) {
X
X		case '\n':
X			++lineno;
X			break;
X
X		case '{':
X			++level;
X			break;
X
X		case '}':
X			--level;
X			if (level == 0) {
X				/* we are finished copying */
X				fprintf(ftable, " YYSTYPE;\n");
X				if (fdefine)
X					fprintf(fdefine, " YYSTYPE;\nextern YYSTYPE yylval;\n");
X				return;
X			}
X		}
X	}
X}
X
X
SHAR_EOF
if test 805 -ne "`wc -c < 'ycpuni.c'`"
then
echo shar: error transmitting "'ycpuni.c'" '(should have been 805 characters)'
fi
chmod 644 ycpuni.c
fi
if test -f 'ydfout.c'
then
echo shar: will not over-write existing "'ydfout.c'"
else
echo extracting "'ydfout.c'"
sed 's/^X//' >ydfout.c <<'SHAR_EOF'
X/*
X * ydfout.c -
X *
X * HISTORY
X */
X
X#include <ctype.h>
X#include "y2.h"
X
Xint	defout()
X{
X	/* write out the defines (at the end of the declaration section) */
X
X	register int	i, c;
X	register char	*cp;
X
X	for (i = ndefout; i <= ntokens; ++i) {
X
X		cp = tokset[i].name;
X		if (*cp == ' ')
X			++cp;	/* literals */
X
X		for (; (c = *cp) != '\0'; ++cp) {
X
X			if (islower(c) || isupper(c) || isdigit(c) || c == '_')
X				;	/* VOID */
X			else
X				goto nodef;
X		}
X
X		fprintf(ftable, "# define %s %d\n", tokset[i].name, tokset[i].value);
X		if (fdefine != NULL)
X			fprintf(fdefine, "# define %s %d\n", tokset[i].name, tokset[i].value);
X
Xnodef:
X		;
X	}
X
X	ndefout = ntokens + 1;
X
X}
X
X
SHAR_EOF
if test 661 -ne "`wc -c < 'ydfout.c'`"
then
echo shar: error transmitting "'ydfout.c'" '(should have been 661 characters)'
fi
chmod 644 ydfout.c
fi
if test -f 'ywritm.c'
then
echo shar: will not over-write existing "'ywritm.c'"
else
echo extracting "'ywritm.c'"
sed 's/^X//' >ywritm.c <<'SHAR_EOF'
X/*
X * ywritm.c -
X *
X * HISTORY
X */
X
X#include "y1.h"
X
Xextern char	sarr[ISIZE];
X
Xchar	*chcopy();
X
Xchar	*writem(pp)
Xint	*pp;
X{
X	/* creates output string for item pointed to by pp */
X	int	i, *p;
X	char	*q;
X
X	for (p = pp; *p > 0; ++p)
X		;
X	p = prdptr[-*p];
X	q = chcopy(sarr, nontrst[*p - NTBASE].name);
X	q = chcopy(q, " : ");
X
X	for (; ; ) {
X		*q++ = ++p == pp ? '_' : ' ';
X		*q = '\0';
X		if ((i = *p) <= 0)
X			break;
X		q = chcopy(q, symnam(i));
X		if (q > &sarr[ISIZE - 30])
X			error("item too big");
X	}
X
X	if ((i = *pp) < 0) {
X		/* an item calling for a reduction */
X		q = chcopy(q, "    (");
X		sprintf(q, "%d)", -i);
X	}
X	return (sarr);
X}
X
X
SHAR_EOF
if test 634 -ne "`wc -c < 'ywritm.c'`"
then
echo shar: error transmitting "'ywritm.c'" '(should have been 634 characters)'
fi
chmod 644 ywritm.c
fi
if test -f 'yflset.c'
then
echo shar: will not over-write existing "'yflset.c'"
else
echo extracting "'yflset.c'"
sed 's/^X//' >yflset.c <<'SHAR_EOF'
X#include "y1.h"
X
Xstruct looksets *flset( p )   
Xstruct looksets *p;
X
X{
X	/* decide if the lookahead set pointed to by p is known */
X	/* return pointer to a perminent location for the set */
X
X	register struct looksets *q;
X	int	j, *w;
X	register *u, *v;
X
X	for ( q = &lkst[nlset]; q-- > lkst; ) {
X		u = p->lset;
X		v = q->lset;
X		w = &v[tbitset];
X		while ( v < w) 
X			if ( *u++ != *v++) 
X				goto more;
X		/* we have matched */
X		return( q );
Xmore:
X		;
X	}
X	/* add a new one */
X	q = &lkst[nlset++];
X	if ( nlset >= LSETSIZE )
X		error("too many lookahead sets" );
X	SETLOOP(j)
X	 {
X		q->lset[j] = p->lset[j];
X	}
X	return( q );
X}
X
X
SHAR_EOF
if test 618 -ne "`wc -c < 'yflset.c'`"
then
echo shar: error transmitting "'yflset.c'" '(should have been 618 characters)'
fi
chmod 644 yflset.c
fi
if test -f 'yhdprd.c'
then
echo shar: will not over-write existing "'yhdprd.c'"
else
echo extracting "'yhdprd.c'"
sed 's/^X//' >yhdprd.c <<'SHAR_EOF'
X#include "y3.h"
X
Xhideprod()
X{
X	/* in order to free up the mem and amem arrays for the optimizer,
X        /* and still be able to output yyr1, etc., after the sizes of
X        /* the action array is known, we hide the nonterminals
X        /* derived by productions in levprd.
X        */
X
X	register i, j;
X
X	j = 0;
X	levprd[0] = 0;
X	PLOOP(1, i)
X	 {
X		if ( !(levprd[i] & REDFLAG) ) {
X			++j;
X			if ( foutput != NULL ) {
X				fprintf( foutput, "Rule not reduced:   %s\n", writem( prdptr[i] ) );
X			}
X		}
X		levprd[i] = *prdptr[i] - NTBASE;
X	}
X	if ( j ) 
X		fprintf( stdout, "%d rules never reduced\n", j );
X}
X
X
SHAR_EOF
if test 602 -ne "`wc -c < 'yhdprd.c'`"
then
echo shar: error transmitting "'yhdprd.c'" '(should have been 602 characters)'
fi
chmod 644 yhdprd.c
fi
if test -f 'yptitm.c'
then
echo shar: will not over-write existing "'yptitm.c'"
else
echo extracting "'yptitm.c'"
sed 's/^X//' >yptitm.c <<'SHAR_EOF'
X#include "y1.h"
X
X/*
X * yptitm.1c
X *
X * Modified to make debug code conditionally compile.
X * 28-Aug-81
X * Bob Denny
X */
X
Xputitem( ptr, lptr )  
Xint	*ptr;
Xstruct looksets *lptr;
X
X
X{
X	register struct item *j;
X
X#ifdef debug
X	if ( foutput != NULL ) {
X
X		fprintf( foutput, "putitem(%s), state %d\n", writem(ptr), nstate );
X	}
X#endif
X	j = pstate[nstate+1];
X	j->pitem = ptr;
X	if ( !nolook ) 
X		j->look = flset( lptr );
X	pstate[nstate+1] = ++j;
X	if ( (int *)j > zzmemsz ) {
X
X		zzmemsz = (int *)j;
X		if ( zzmemsz >=  &mem0[MEMSIZE] ) 
X			error( "out of state space" );
X	}
X}
X
X
SHAR_EOF
if test 567 -ne "`wc -c < 'yptitm.c'`"
then
echo shar: error transmitting "'yptitm.c'" '(should have been 567 characters)'
fi
chmod 644 yptitm.c
fi
if test -f 'ycpycd.c'
then
echo shar: will not over-write existing "'ycpycd.c'"
else
echo extracting "'ycpycd.c'"
sed 's/^X//' >ycpycd.c <<'SHAR_EOF'
X/*
X * ycpycd.c - copies code between \{ and \}
X *
X * HISTORY
X */
X
X#include "y2.h"
X
X
Xint	cpycode()
X{
X	int	c;
X
X	c = unix_getc(finput);
X	if (c == '\n') {
X		c = unix_getc(finput);
X		lineno++;
X	}
X	fprintf(ftable, "\n# line %d\n", lineno);
X	while (c >= 0) {
X		if (c == '\\')
X			if ((c = unix_getc(finput)) == '}')
X				return;
X			else
X				putc('\\', ftable);
X		if (c == '%')
X			if ((c = unix_getc(finput)) == '}')
X				return;
X			else
X				putc('%', ftable);
X		putc(c, ftable);
X		if (c == '\n')
X			++lineno;
X		c = unix_getc(finput);
X	}
X	error("eof before %%}");
X}
X
X
SHAR_EOF
if test 557 -ne "`wc -c < 'ycpycd.c'`"
then
echo shar: error transmitting "'ycpycd.c'" '(should have been 557 characters)'
fi
chmod 644 ycpycd.c
fi
if test -f 'ygtnm.c'
then
echo shar: will not over-write existing "'ygtnm.c'"
else
echo extracting "'ygtnm.c'"
sed 's/^X//' >ygtnm.c <<'SHAR_EOF'
X/*
X * ygtnm.c -
X *
X * HISTORY
X */
X
X#include <ctype.h>
X#include "y4.h"
X
Xint	gtnm()
X{
X
X	register s, val, c;
X
X	/* read and convert an integer from the standard input */
X	/* return the terminating character */
X	/* blanks, tabs, and newlines are ignored */
X
X	s = 1;
X	val = 0;
X
X	while ((c = unix_getc(finput)) != EOF) {
X		if (isdigit(c)) {
X			val = val * 10 + c - '0';
X		} else if (c == '-')
X			s = -1;
X		else if (c == '\r')
X			continue;
X		else
X			break;
X	}
X	*pmem++ = s * val;
X	if (pmem > &mem0[MEMSIZE])
X		error("out of space");
X	return (c);
X}
X
X
SHAR_EOF
if test 542 -ne "`wc -c < 'ygtnm.c'`"
then
echo shar: error transmitting "'ygtnm.c'" '(should have been 542 characters)'
fi
chmod 644 ygtnm.c
fi
if test -f 'yskpcm.c'
then
echo shar: will not over-write existing "'yskpcm.c'"
else
echo extracting "'yskpcm.c'"
sed 's/^X//' >yskpcm.c <<'SHAR_EOF'
X#include "y2.h"
X
Xskipcom()
X{
X	/* skip over comments */
X	register c, i;  /* i is the number of lines skipped */
X	i = 0;                                                         /*01*/
X	/* skipcom is called after reading a / */
X
X	if ( unix_getc(finput) != '*' ) 
X		error( "illegal comment" );
X	c = unix_getc(finput);
X	while ( c != EOF ) {
X		while ( c == '*' ) {
X			if ( (c = unix_getc(finput)) == '/' ) 
X				return( i );
X		}
X		if ( c == '\n' ) 
X			++i;
X		c = unix_getc(finput);
X	}
X	error( "EOF inside comment" );
X	/* NOTREACHED */
X}
X
X
SHAR_EOF
if test 532 -ne "`wc -c < 'yskpcm.c'`"
then
echo shar: error transmitting "'yskpcm.c'" '(should have been 532 characters)'
fi
chmod 644 yskpcm.c
fi
if test -f 'yosmry.c'
then
echo shar: will not over-write existing "'yosmry.c'"
else
echo extracting "'yosmry.c'"
sed 's/^X//' >yosmry.c <<'SHAR_EOF'
X#include "y4.h"
X
X/*
X * Write summary.
X */
X
Xosummary()
X
X{
X	register int	i, *p;
X
X	if (foutput == NULL) 
X		return;
X
X	i = 0;
X	for (p = maxa; p >= a; --p) {
X
X		if (*p == 0) 
X			++i;
X	}
X	fprintf(foutput, "Optimizer space used: input %d/%d, output %d/%d\n",
X	    pmem - mem0 + 1, MEMSIZE, maxa - a + 1, ACTSIZE);
X	fprintf(foutput, "%d table entries, %d zero\n", (maxa - a) + 1, i);
X	fprintf(foutput, "maximum spread: %d, maximum offset: %d\n", maxspr, maxoff);
X	fclose(foutput);
X}
X
X
SHAR_EOF
if test 476 -ne "`wc -c < 'yosmry.c'`"
then
echo shar: error transmitting "'yosmry.c'" '(should have been 476 characters)'
fi
chmod 644 yosmry.c
fi
if test -f 'y4imp.c'
then
echo shar: will not over-write existing "'y4imp.c'"
else
echo extracting "'y4imp.c'"
sed 's/^X//' >y4imp.c <<'SHAR_EOF'
X/* 
X * y4imp.c - impure data from y4.c modules
X *
X * HISTORY
X */
X
X# include "dtxtrn.h"
X
X# define a amem
X# define pa indgo
X# define yypact temp1
X# define greed tystate
X
X# define NOMORE -1000
X
Xint	*ggreed = lkst[0].lset;
Xint	*pgo = wsets[0].ws.lset;
Xint	*yypgo = &nontrst[0].tvalue;
X
Xint	maxspr = 0;		/* maximum spread of any entry */
Xint	maxoff = 0;		/* maximum offset into a array */
Xint	*pmem = mem0;
Xint	*maxa;
Xint	nxdb = 0;
Xint	adb = 0;
SHAR_EOF
if test 440 -ne "`wc -c < 'y4imp.c'`"
then
echo shar: error transmitting "'y4imp.c'" '(should have been 440 characters)'
fi
chmod 644 y4imp.c
fi
if test -f 'ynxti.c'
then
echo shar: will not over-write existing "'ynxti.c'"
else
echo extracting "'ynxti.c'"
sed 's/^X//' >ynxti.c <<'SHAR_EOF'
X#include "y4.h"
X
Xnxti()
X{
X	/* finds the next i */
X	register i, max, maxi;
X
X	max = 0;
X
X	for ( i = 1; i <= nnonter; ++i ) 
X		if ( ggreed[i] >= max ) {
X			max = ggreed[i];
X			maxi = -i;
X		}
X
X	for ( i = 0; i < nstate; ++i ) 
X		if ( greed[i] >= max ) {
X			max = greed[i];
X			maxi = i;
X		}
X
X	if ( nxdb ) 
X		fprintf( ftable, "nxti = %d, max = %d\n", maxi, max );
X	if ( max == 0 ) 
X		return( NOMORE );
X	else 
X		return( maxi );
X}
X
X
SHAR_EOF
if test 423 -ne "`wc -c < 'ynxti.c'`"
then
echo shar: error transmitting "'ynxti.c'" '(should have been 423 characters)'
fi
chmod 644 ynxti.c
fi
if test -f 'ychfnd.c'
then
echo shar: will not over-write existing "'ychfnd.c'"
else
echo extracting "'ychfnd.c'"
sed 's/^X//' >ychfnd.c <<'SHAR_EOF'
X/*
X * ychfnd.c -
X *
X * HISTORY
X */
X
X#include "y2.h"
X
X
Xint	chfind( t, s )
Xregister char	*s;
X{
X	int	i;
X
X	if (s[0] == ' ')
X		t = 0;
X	TLOOP(i) {
X		if (!strcmp(s, tokset[i].name)) {
X			return (i);
X		}
X	}
X	NTLOOP(i) {
X		if (!strcmp(s, nontrst[i].name)) {
X			return (i + NTBASE);
X		}
X	}
X	/* cannot find name */
X	if (t > 1)
X		error("%s should have been defined earlier", s);
X	return (defin(t, s));
X}
X
X
SHAR_EOF
if test 394 -ne "`wc -c < 'ychfnd.c'`"
then
echo shar: error transmitting "'ychfnd.c'" '(should have been 394 characters)'
fi
chmod 644 ychfnd.c
fi
if test -f 'yyless.c'
then
echo shar: will not over-write existing "'yyless.c'"
else
echo extracting "'yyless.c'"
sed 's/^X//' >yyless.c <<'SHAR_EOF'
Xyyless(x)
X
X{
X	extern char	yytext[];
X	register char	*lastch, *ptr;
X	extern int	yyleng;
X	extern int	yyprevious;
X	lastch = yytext + yyleng;
X	if (x >= 0 && x <= yyleng)
X		ptr = x + yytext;
X	else
X		ptr = x;
X	while (lastch > ptr)
X		yyunput(*--lastch);
X	*lastch = 0;
X	if (ptr > yytext)
X		yyprevious = *--lastch;
X	yyleng = ptr - yytext;
X}
X
X
SHAR_EOF
if test 333 -ne "`wc -c < 'yyless.c'`"
then
echo shar: error transmitting "'yyless.c'" '(should have been 333 characters)'
fi
chmod 644 yyless.c
fi
if test -f 'yarout.c'
then
echo shar: will not over-write existing "'yarout.c'"
else
echo extracting "'yarout.c'"
sed 's/^X//' >yarout.c <<'SHAR_EOF'
X/*
X * yarout.c - 
X *
X * HISTORY
X */
X
X#include "y4.h"
X
Xint	arout(s, v, n)
Xchar	*s;
Xint	*v, n;
X{
X	register i;
X
X	fprintf(ftable, "short %s[]={\n", s);
X	for (i = 0; i < n; ) {
X		if (i % 10 == 0)
X			fprintf(ftable, "\n");
X		fprintf(ftable, "%4d", v[i]);
X		if (++i == n)
X			fprintf(ftable, " };\n");
X		else
X			fprintf(ftable, ",");
X	}
X}
X
X
SHAR_EOF
if test 333 -ne "`wc -c < 'yarout.c'`"
then
echo shar: error transmitting "'yarout.c'" '(should have been 333 characters)'
fi
chmod 644 yarout.c
fi
if test -f 'yerror.c'
then
echo shar: will not over-write existing "'yerror.c'"
else
echo extracting "'yerror.c'"
sed 's/^X//' >yerror.c <<'SHAR_EOF'
X#include "y1.h"
X
X/*
X * 12-Apr-83 (RBD) Add symbolic exit status
X */
X/* VARARGS1 */
Xerror(s, a1) 
Xchar	*s;
X
X{
X	/* write out error comment */
X
X	++nerrors;
X	fprintf( stderr, "\n fatal error: ");
X	fprintf( stderr, s, a1);
X	fprintf( stderr, ", line %d\n", lineno );
X	if ( !fatfl ) 
X		return;
X	summary();
X	exit(EX_ERR);
X}
X
X
SHAR_EOF
if test 318 -ne "`wc -c < 'yerror.c'`"
then
echo shar: error transmitting "'yerror.c'" '(should have been 318 characters)'
fi
chmod 644 yerror.c
fi
if test -f 'ywarry.c'
then
echo shar: will not over-write existing "'ywarry.c'"
else
echo extracting "'ywarry.c'"
sed 's/^X//' >ywarry.c <<'SHAR_EOF'
X#include "y3.h"
X
Xwarray( s, v, n ) 
Xchar	*s;
Xint	*v, n;
X
X{
X
X	register i;
X
X	fprintf( ftable, "short %s[]={\n", s );
X	for ( i = 0; i < n; ) {
X		if ( i % 10 == 0 ) 
X			fprintf( ftable, "\n" );
X		fprintf( ftable, "%4d", v[i] );
X		if ( ++i == n ) 
X			fprintf( ftable, " };\n" );
X		else 
X			fprintf( ftable, "," );
X	}
X}
X
X
SHAR_EOF
if test 316 -ne "`wc -c < 'ywarry.c'`"
then
echo shar: error transmitting "'ywarry.c'" '(should have been 316 characters)'
fi
chmod 644 ywarry.c
fi
if test -f 'yfdtyp.c'
then
echo shar: will not over-write existing "'yfdtyp.c'"
else
echo extracting "'yfdtyp.c'"
sed 's/^X//' >yfdtyp.c <<'SHAR_EOF'
X#include "y2.h"
X
Xfdtype( t )
X{
X	/* determine the type of a symbol */
X	register v;
X	if ( t >= NTBASE ) 
X		v = nontrst[t-NTBASE].tvalue;
X	else 
X		v = TYPE( toklev[t] );
X	if ( v <= 0 ) 
X		error( "must specify type for %s", (t >= NTBASE) ? nontrst[t-NTBASE].name : 
X		    tokset[t].name );
X	return( v );
X}
X
X
SHAR_EOF
if test 304 -ne "`wc -c < 'yfdtyp.c'`"
then
echo shar: error transmitting "'yfdtyp.c'" '(should have been 304 characters)'
fi
chmod 644 yfdtyp.c
fi
if test -f 'yprlok.c'
then
echo shar: will not over-write existing "'yprlok.c'"
else
echo extracting "'yprlok.c'"
sed 's/^X//' >yprlok.c <<'SHAR_EOF'
X#include "y1.h"
X
Xprlook( p ) 
Xstruct looksets *p;
X
X{
X	register j, *pp;
X	pp = p->lset;
X	if ( pp == 0 ) 
X		fprintf( foutput, "\tNULL");
X	else      {
X		fprintf( foutput, " { " );
X		TLOOP(j)
X		 {
X			if ( BIT(pp, j) ) 
X				fprintf( foutput,  "%s ", symnam(j) );
X		}
X		fprintf( foutput,  "}" );
X	}
X}
X
X
SHAR_EOF
if test 296 -ne "`wc -c < 'yprlok.c'`"
then
echo shar: error transmitting "'yprlok.c'" '(should have been 296 characters)'
fi
chmod 644 yprlok.c
fi
if test -f 'ystuni.c'
then
echo shar: will not over-write existing "'ystuni.c'"
else
echo extracting "'ystuni.c'"
sed 's/^X//' >ystuni.c <<'SHAR_EOF'
X#include "y1.h"
X
Xsetunion( a, b ) 
Xregister *a, *b;
X
X{
X	/* set a to the union of a and b */
X	/* return 1 if b is not a subset of a, 0 otherwise */
X	register i, x, sub;
X
X	sub = 0;
X	SETLOOP(i)
X	 {
X		*a = (x = *a) | *b++;
X		if ( *a++ != x ) 
X			sub = 1;
X	}
X	return( sub );
X}
X
X
SHAR_EOF
if test 274 -ne "`wc -c < 'ystuni.c'`"
then
echo shar: error transmitting "'ystuni.c'" '(should have been 274 characters)'
fi
chmod 644 ystuni.c
fi
if test -f 'yaoput.c'
then
echo shar: will not over-write existing "'yaoput.c'"
else
echo extracting "'yaoput.c'"
sed 's/^X//' >yaoput.c <<'SHAR_EOF'
X/*
X * yaoput.c - write out the optimized parser
X *
X * HISTORY
X */
X
X#include "y4.h"
X
Xint	aoutput()
X{
X	fprintf(ftable, "# define YYLAST %d\n", maxa - a + 1);
X	arout("yyact", a, (maxa - a) + 1);
X	arout("yypact", pa, nstate);
X	arout("yypgo", pgo, nnonter + 1);
X}
X
X
SHAR_EOF
if test 261 -ne "`wc -c < 'yaoput.c'`"
then
echo shar: error transmitting "'yaoput.c'" '(should have been 261 characters)'
fi
chmod 644 yaoput.c
fi
if test -f 'y3imp.c'
then
echo shar: will not over-write existing "'y3imp.c'"
else
echo extracting "'y3imp.c'"
sed 's/^X//' >y3imp.c <<'SHAR_EOF'
X/* 
X * y3imp.c - impure data from modules split from y3.c 
X *
X * HISTORY
X */
X
X#define y3imp YES
X
X#include "dtxtrn.h"
X
Xint	lastred;            /* the number of the last reduction of a state */
X
Xint	defact[NSTATES];    /* the default actions of states */
SHAR_EOF
if test 253 -ne "`wc -c < 'y3imp.c'`"
then
echo shar: error transmitting "'y3imp.c'" '(should have been 253 characters)'
fi
chmod 644 y3imp.c
fi
if test -f 'ycstsh.c'
then
echo shar: will not over-write existing "'ycstsh.c'"
else
echo extracting "'ycstsh.c'"
sed 's/^X//' >ycstsh.c <<'SHAR_EOF'
X#include "y2.h"
Xchar	*
Xcstash( s ) 
Xregister char	*s;
X
X{
X	char	*temp;
X
X	temp = cnamp;
X	do 
X	 {
X		if ( cnamp >= &cnames[cnamsz] ) 
X			error("too many characters in id's and literals" );
X		else 
X			*cnamp++ = *s;
X	} while ( *s++);
X	return( temp );
X}
X
X
SHAR_EOF
if test 250 -ne "`wc -c < 'ycstsh.c'`"
then
echo shar: error transmitting "'ycstsh.c'" '(should have been 250 characters)'
fi
chmod 644 ycstsh.c
fi
if test -f 'ysmnam.c'
then
echo shar: will not over-write existing "'ysmnam.c'"
else
echo extracting "'ysmnam.c'"
sed 's/^X//' >ysmnam.c <<'SHAR_EOF'
X#include "y1.h"
X
Xchar	*symnam(i)
X{
X	/* return a pointer to the name of symbol i */
X	char	*cp;
X
X	cp = (i >= NTBASE) ? nontrst[i-NTBASE].name : tokset[i].name ;
X	if ( *cp == ' ' ) 
X		++cp;
X	return( cp );
X}
X
X
SHAR_EOF
if test 206 -ne "`wc -c < 'ysmnam.c'`"
then
echo shar: error transmitting "'ysmnam.c'" '(should have been 206 characters)'
fi
chmod 644 ysmnam.c
fi
if test -f 'yaryfl.c'
then
echo shar: will not over-write existing "'yaryfl.c'"
else
echo extracting "'yaryfl.c'"
sed 's/^X//' >yaryfl.c <<'SHAR_EOF'
X/*
X * yaryfl.c  - set elements 0 through n-1 to c
X *
X * HISTORY
X */
X
X#include "y1.h"
X
X
Xint	aryfil(v, n, c)
Xint	*v, n, c;
X{
X	register int	i;
X
X	for (i = 0; i < n; ++i)
X		v[i] = c;
X}
X
X
SHAR_EOF
if test 182 -ne "`wc -c < 'yaryfl.c'`"
then
echo shar: error transmitting "'yaryfl.c'" '(should have been 182 characters)'
fi
chmod 644 yaryfl.c
fi
if test -f 'ychcpy.c'
then
echo shar: will not over-write existing "'ychcpy.c'"
else
echo extracting "'ychcpy.c'"
sed 's/^X//' >ychcpy.c <<'SHAR_EOF'
X/*
X * ychcpy.c - copies string q into p, return next free char ptr
X *
X * HISTORY
X */
X
X#include "y1.h"
X
Xchar	*chcopy(p, q)
Xchar	*p, *q;
X{
X	while (*p = *q++)
X		++p;
X	return (p);
X}
X
X
SHAR_EOF
if test 180 -ne "`wc -c < 'ychcpy.c'`"
then
echo shar: error transmitting "'ychcpy.c'" '(should have been 180 characters)'
fi
chmod 644 ychcpy.c
fi
if test -f 'yfnact.c'
then
echo shar: will not over-write existing "'yfnact.c'"
else
echo extracting "'yfnact.c'"
sed 's/^X//' >yfnact.c <<'SHAR_EOF'
X#include "y2.h"
X
Xfinact()
X{
X	/* finish action routine */
X
X	fclose(faction);
X
X	fprintf( ftable, "# define YYERRCODE %d\n", tokset[2].value );
X
X}
X
X
SHAR_EOF
if test 146 -ne "`wc -c < 'yfnact.c'`"
then
echo shar: error transmitting "'yfnact.c'" '(should have been 146 characters)'
fi
chmod 644 yfnact.c
fi
# end of shell archive
exit 0