home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
OS2-YACC.ZIP
/
YPRCFT.3C
< prev
next >
Wrap
Text File
|
1989-09-30
|
2KB
|
58 lines
/*
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: YPRCFT.3C
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 "y3.h"
void precftn( int r, int t, int s )
{
/* decide a shift/reduce conflict by precedence.*/
/* r is a rule number, t a token number */
/* the conflict is in state s */
/* temp1[t] is changed to reflect the action */
int lp,lt, action;
lp = levprd[r];
lt = toklev[t];
if( PLEVEL(lt) == 0 || PLEVEL(lp) == 0 )
{
/* conflict */
if( foutput != NULL ) fprintf( foutput, "\n%d: shift/reduce conflict (shift %d, red'n %d) on %s",
s, temp1[t], r, symnam(t) );
++zzsrconf;
return;
}
if( PLEVEL(lt) == PLEVEL(lp) ) action = ASSOC(lt);
else if( PLEVEL(lt) > PLEVEL(lp) ) action = RASC; /* shift */
else action = LASC; /* reduce */
switch( action )
{
case BASC: /* error action */
temp1[t] = ERRCODE;
return;
case LASC: /* reduce */
temp1[t] = -r;
return;
}
}