divert(0)
integer function yypars( yyargu)
common/yycomn/yylval, yyval, yypv, yyv(YYMAXDEPTH)
common/yylcom/yychar,yyerrf,yydebu
integer yyval,yypv,yylval,yychar,yydebu,yynerr,yystat,yyargu
integer yylex,yys(YYMAXDEPTH),yyerrf,yyv,yyn,yyj,yym,yypvt,yynn
#INCLUDE(print)
define(`YYFLAG',-1000)
define(`yystack',`100#')
define(`yynewstate',`200#')
define(`yydefault',`500#')
define(`yyerrlab',`300#')
define(`yyabort',`400#')
define(`YYERROR',`goto yyerrlab')
define(`YYACCEPT',return(0))
define(`YYABORT',return(1))

divert(3)
yyval = 0
yystat = 0
yychar = -1
yynerr = 0
yyerrf = 0
yypv = 0

yystack:	# put a state and value onto the stack

#EPRINT("state",I(yystat)," char",I(yychar))

yypv = yypv + 1
if(yypv>YYMAXDEPTH){ call yyerro; return(1) }	# stack overflow
yys( yypv ) = yystat
yyv( yypv ) = yyval

yynewstate:

yyn = yypact( yystat+1 )

if( yyn <= YYFLAG ) goto yydefault	# simple state

if( yychar<0 ) yychar = max0( yylex(yylval), 0 )
yyn = yyn + yychar
if( yyn < 0 || yyn >= YYLAST ) goto yydefault

yyn = yyact( yyn+1 )
if( yychk( yyn+1 ) == yychar ){	# valid shift
	yychar = -1
	yyval = yylval
	yystat = yyn
	if( yyerrf > 0 ) yyerrf = yyerrf - 1
	goto yystack
	}

yydefault:	# default state action

	yyn = yydef( yystat+1 )

	if( yyn == (-2) )  {
#EPRINT("Exception executed")
		if(yychar<0) yychar=max0(yylex(yylval),0)
		# look through exception table

		for(yyn=1; yyexca(yyn)!=(-1) || yyexca(yyn+1)!=yystat; yyn=yyn+2) ; #VOID

		for(yyn=yyn+2; yyexca(yyn)>=0; yyn=yyn+2) if(yyexca(yyn)==yychar) break
		yyn=yyexca(yyn+1)
		if(yyn<0) return(0)	# accept
		}


	if( yyn == 0 ){ # error
		# error ... attempt to resume parsing

		if( yyerrf == 3 ){	# no shift yet; clobber input char
#EPRINT("Error recovery discards char",I(yychar))

			if( yychar == 0 ) goto yyabort	# dont discard EOF, quit
			yychar = -1
			goto yynewstate	# try again in the same state
			}

		if( yyerrf == 0 ){#  brand new error
			call yyerro	# print "syntax error " - user provided
		yyerrlab:
			yynerr = yynerr + 1
			}

		# case 1,2: incompletely recovered error ... try again
		yyerrf = 3

		# find a state where "error" is a legal shift action

		while( yypv >= 1 ){
			yyn = yys( yypv )
			yyn = yypact(  yyn+1 ) + YYERRCODE
			if( yyn >= 0 && yyn < YYLAST ){
				yyn = yyact( yyn+1 )
				if( yychk( yyn+1 ) == YYERRCODE ){
					yystat = yyn
					goto yystack	# simulate a shift of "error"
					}
				}
			yyn = yys(yypv)
			yyn = yypact(yyn+1)

			# the current yyps has no shift on "error", pop stack
#EPRINT("Error recovery pops state",I(yys(yypv))," uncovers",I(yys(yypv-1)))
			yypv = yypv - 1
			}

		# there is no state on the stack with an error shift ... abort
yyabort:
		return(1)

		}

#EPRINT("Reduce",I(yyn))
	yypvt = yypv
	yypv = yypv - yyr2( yyn+1 )	# reduction by production yyn
	yyval = yyv( yypv+1 )
	yym = yyn
	yyn = yyr1( yyn+1 )	# consult goto table to find next state
	yyj = yypgo( yyn+1 ) + yys( yypv ) +2
	if( yyj > YYLAST ) goto 899
	yystat = yyact( yyj )
	if( yychk( yystat+1 ) != ( -yyn ) ){
		899 yynn = yypgo( yyn+1 )
		yystat = yyact( yynn+1 )
		}
#EPRINT("Executing Action",I(yym))
	goto 1000	# switch on yym
	$A
	goto yystack	# stack new state and value
	end
