1*10938Srrh#ifndef lint 2*10938Srrhstatic char yaccpar_sccsid[] = "@(#)old.yaccpar 4.1 (Berkeley) 02/11/83"; 3*10938Srrh#endif not lint 4*10938Srrh 5*10938Srrh# 6*10938Srrh# define YYFLAG -1000 7*10938Srrh# define YYERROR goto yyerrlab 8*10938Srrh# define YYACCEPT return(0) 9*10938Srrh# define YYABORT return(1) 10*10938Srrh 11*10938Srrh/* parser for yacc output */ 12*10938Srrh 13*10938Srrh#ifdef YYDEBUG 14*10938Srrhint yydebug = 0; /* 1 for debugging */ 15*10938Srrh#endif 16*10938SrrhYYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */ 17*10938Srrhint yychar = -1; /* current input token number */ 18*10938Srrhint yynerrs = 0; /* number of errors */ 19*10938Srrhshort yyerrflag = 0; /* error recovery flag */ 20*10938Srrh 21*10938Srrhyyparse() { 22*10938Srrh 23*10938Srrh short yys[YYMAXDEPTH]; 24*10938Srrh short yyj, yym; 25*10938Srrh register YYSTYPE *yypvt; 26*10938Srrh register short yystate, *yyps, yyn; 27*10938Srrh register YYSTYPE *yypv; 28*10938Srrh register short *yyxi; 29*10938Srrh 30*10938Srrh yystate = 0; 31*10938Srrh yychar = -1; 32*10938Srrh yynerrs = 0; 33*10938Srrh yyerrflag = 0; 34*10938Srrh yyps= &yys[-1]; 35*10938Srrh yypv= &yyv[-1]; 36*10938Srrh 37*10938Srrh yystack: /* put a state and value onto the stack */ 38*10938Srrh 39*10938Srrh#ifdef YYDEBUG 40*10938Srrh if( yydebug ) printf( "state %d, char 0%o\n", yystate, yychar ); 41*10938Srrh#endif 42*10938Srrh if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); } 43*10938Srrh *yyps = yystate; 44*10938Srrh ++yypv; 45*10938Srrh *yypv = yyval; 46*10938Srrh 47*10938Srrh yynewstate: 48*10938Srrh 49*10938Srrh yyn = yypact[yystate]; 50*10938Srrh 51*10938Srrh if( yyn<= YYFLAG ) goto yydefault; /* simple state */ 52*10938Srrh 53*10938Srrh if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0; 54*10938Srrh if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault; 55*10938Srrh 56*10938Srrh if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */ 57*10938Srrh yychar = -1; 58*10938Srrh yyval = yylval; 59*10938Srrh yystate = yyn; 60*10938Srrh if( yyerrflag > 0 ) --yyerrflag; 61*10938Srrh goto yystack; 62*10938Srrh } 63*10938Srrh 64*10938Srrh yydefault: 65*10938Srrh /* default state action */ 66*10938Srrh 67*10938Srrh if( (yyn=yydef[yystate]) == -2 ) { 68*10938Srrh if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0; 69*10938Srrh /* look through exception table */ 70*10938Srrh 71*10938Srrh for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */ 72*10938Srrh 73*10938Srrh while( *(yyxi+=2) >= 0 ){ 74*10938Srrh if( *yyxi == yychar ) break; 75*10938Srrh } 76*10938Srrh if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */ 77*10938Srrh } 78*10938Srrh 79*10938Srrh if( yyn == 0 ){ /* error */ 80*10938Srrh /* error ... attempt to resume parsing */ 81*10938Srrh 82*10938Srrh switch( yyerrflag ){ 83*10938Srrh 84*10938Srrh case 0: /* brand new error */ 85*10938Srrh 86*10938Srrh yyerror( "syntax error" ); 87*10938Srrh yyerrlab: 88*10938Srrh ++yynerrs; 89*10938Srrh 90*10938Srrh case 1: 91*10938Srrh case 2: /* incompletely recovered error ... try again */ 92*10938Srrh 93*10938Srrh yyerrflag = 3; 94*10938Srrh 95*10938Srrh /* find a state where "error" is a legal shift action */ 96*10938Srrh 97*10938Srrh while ( yyps >= yys ) { 98*10938Srrh yyn = yypact[*yyps] + YYERRCODE; 99*10938Srrh if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){ 100*10938Srrh yystate = yyact[yyn]; /* simulate a shift of "error" */ 101*10938Srrh goto yystack; 102*10938Srrh } 103*10938Srrh yyn = yypact[*yyps]; 104*10938Srrh 105*10938Srrh /* the current yyps has no shift onn "error", pop stack */ 106*10938Srrh 107*10938Srrh#ifdef YYDEBUG 108*10938Srrh if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] ); 109*10938Srrh#endif 110*10938Srrh --yyps; 111*10938Srrh --yypv; 112*10938Srrh } 113*10938Srrh 114*10938Srrh /* there is no state on the stack with an error shift ... abort */ 115*10938Srrh 116*10938Srrh yyabort: 117*10938Srrh return(1); 118*10938Srrh 119*10938Srrh 120*10938Srrh case 3: /* no shift yet; clobber input char */ 121*10938Srrh 122*10938Srrh#ifdef YYDEBUG 123*10938Srrh if( yydebug ) printf( "error recovery discards char %d\n", yychar ); 124*10938Srrh#endif 125*10938Srrh 126*10938Srrh if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */ 127*10938Srrh yychar = -1; 128*10938Srrh goto yynewstate; /* try again in the same state */ 129*10938Srrh 130*10938Srrh } 131*10938Srrh 132*10938Srrh } 133*10938Srrh 134*10938Srrh /* reduction by production yyn */ 135*10938Srrh 136*10938Srrh#ifdef YYDEBUG 137*10938Srrh if( yydebug ) printf("reduce %d\n",yyn); 138*10938Srrh#endif 139*10938Srrh yyps -= yyr2[yyn]; 140*10938Srrh yypvt = yypv; 141*10938Srrh yypv -= yyr2[yyn]; 142*10938Srrh yyval = yypv[1]; 143*10938Srrh yym=yyn; 144*10938Srrh /* consult goto table to find next state */ 145*10938Srrh yyn = yyr1[yyn]; 146*10938Srrh yyj = yypgo[yyn] + *yyps + 1; 147*10938Srrh if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]]; 148*10938Srrh switch(yym){ 149*10938Srrh $A 150*10938Srrh } 151*10938Srrh goto yystack; /* stack new state and value */ 152*10938Srrh 153*10938Srrh } 154