* Copyright (c) 1980 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)yyparse.c 5.2 (Berkeley) %G%";
#include "tree_ty.h" /* must be included for yy.h */
* Parser for 'yacc' output.
* Specifially Modified for Berkeley Pascal
int yystate
; /* Current parser state */
unsigned yytshifts
= 1; /* Number of "true" shifts */
* Parse and parallel semantic stack
union semstack yyv
[MAXDEPTH
];
* This routine parses the input stream, and
* returns if it accepts, or if an unrecoverable syntax
int paniced
, *panicps
, idfail
;
* Push new state and value.
if (yypv
>= &yyv
[MAXDEPTH
-1]) {
yerror("Parse stack overflow");
* Locate parsing actions for the
p
= &yyact
[ yypact
[yystate
+1] ];
* Search the parse actions table
* for something useful to do.
* While n is non-positive, it is the negation
* of the token we are testing for.
yypw
[1].Wseqid
= yyseqid
;
if (N
== 1 && OY
.Yychar
== YID
&& !yyEactr(n
,
* Use goto table to find next state.
p
= &yygo
[yypgo
[yyr1
[n
]]];
while (*p
!= *ps
&& *p
>= 0)
if ((paniced
|| yyshifts
!= 0) && yyrecover(ps
, idfail
)) {
* Find a state where 'error' is a
if (paniced
&& yyshifts
<= 0 && ps
>= panicps
) {
yypv
-= (ps
- panicps
) + 1;
yypw
-= (ps
- panicps
) + 1;
for (p
= &yyact
[ yypact
[*ps
+1] ] ; *p
<= 0; p
+= 2)
yerror("Unrecoverable syntax error - QUIT");