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: YGIN.4C
- 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"
- #include "y4.h"
-
- void gin( int i )
- {
-
- register *p, *r, *s, *q1, *q2;
-
- /* enter gotos on nonterminal i into array a */
-
- ggreed[i] = 0;
-
- q2 = mem0+ yypgo[i+1] - 1;
- q1 = mem0 + yypgo[i];
-
- /* now, find a place for it */
-
- for( p=a; p < &a[ACTSIZE]; ++p )
- {
- if( *p ) continue;
- for( r=q1; r<q2; r+=2 )
- {
- s = p + *r +1;
- if( *s ) goto nextgp;
- if( s > maxa )
- {
- if( (maxa=s) > &a[ACTSIZE] ) error( "a array overflow" );
- }
- }
- /* we have found a spot */
-
- *p = *q2;
- if( p > maxa )
- {
- if( (maxa=p) > &a[ACTSIZE] ) error( "a array overflow" );
- }
- for( r=q1; r<q2; r+=2 )
- {
- s = p + *r + 1;
- *s = r[1];
- }
-
- pgo[i] = p-a;
- if( adb>1 ) fprintf( ftable, "Nonterminal %d, entry at %d\n" , i, pgo[i] );
- goto nextgi;
-
- nextgp:
- ;
- }
-
- error( "cannot place goto %d\n", i );
-
- nextgi:
- ;
- }
-