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