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: YOTHRS.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
- */
-
- /* Edits:
- * 06-Dec-80 Original code broken out of y1.c.
- * 18-Dec-80 Add conditional code for Decus for tempfile deletion.
- */
-
- #include "y1.h"
- #include "y3.h"
-
- void others( void )
- {
- /* put out other arrays, copy the parsers */
- register c, i, j;
-
- finput = fopen( PARSER, "r" );
- if( finput == NULL ) error( "cannot find parser %s", PARSER );
-
- warray( "yyr1", levprd, nprod );
-
- aryfil( temp1, nprod, 0 );
- PLOOP(1,i)temp1[i] = prdptr[i+1]-prdptr[i]-2;
- warray( "yyr2", temp1, nprod );
-
- aryfil( temp1, nstate, -1000 );
- TLOOP(i)
- {
- for( j=tstates[i]; j!=0; j=mstates[j] )
- {
- temp1[j] = tokset[i].value;
- }
- }
- NTLOOP(i)
- {
- for( j=ntstates[i]; j!=0; j=mstates[j] )
- {
- temp1[j] = -i;
- }
- }
- warray( "yychk", temp1, nstate );
-
- warray( "yydef", defact, nstate );
-
- /* copy parser text */
-
- while( (c=unix_getc(finput) ) != EOF )
- {
- if( c == '$' )
- {
- if( (c=unix_getc(finput)) != 'A' ) putc( '$', ftable );
- else
- {
- /* copy actions */
- faction = fopen( ACTNAME, "r" );
- if( faction == NULL ) error( "cannot reopen action tempfile" );
- while( (c=unix_getc(faction) ) != EOF ) putc( c, ftable );
- fclose(faction);
- ZAPFILE(ACTNAME);
- c = unix_getc(finput);
- }
- }
-
- putc( c, ftable );
- }
-
- fclose( ftable );
- }
-
- static char getbuf[30], *getbufptr = getbuf;
-
- int unix_getc(FILE *iop)
- {
- if(getbufptr == getbuf)
- return(getc(iop));
- else
- return(*--getbufptr);
- }
-
- void uungetc( char c, FILE *iop )
- /* WARNING: iop ignored ... uungetc's are multiplexed!!! */
- {
- *getbufptr++ = c;
- }
-