/* * This routine parses the input stream, and * returns if it accepts, or if an unrecoverable syntax * error is encountered. */ yyparse() { register int *ps, n, *p; int paniced, *panicps, idfail; yystate = 0; yychar = yylex(); OY.Yychar = -1; yyshifts = 3; paniced = 0; ps = &yys[0]-1; yypv = &yyv[0]-1; #ifdef PXP yypw = &yyw[0]-1; #endif stack: /* * Push new state and value. */ if (yypv >= &yyv[MAXDEPTH-1]) { yerror("Parse stack overflow"); pexit(DIED); } *++ps = yystate; *++yypv = yyval; #ifdef PXP yypw++; #endif newstate: /* * Locate parsing actions for the * new parser state. */ p = &yyact[ yypact[yystate+1] ]; actn: /* * 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. */ #ifdef PI if ((n = *p++) <= 0) { if (yychar < 0) yychar = yylex(); do if ((n += yychar) != 0) p++; while ((n = *p++) <= 0); } #else while ((n = *p++) <= 0) if ((n += yychar) != 0) p++; #endif switch (n >> 12) { /* * Shift. */ case 2: #ifdef PXP yypw[1].Wseqid = yyseqid; yypw[1].Wcol = yycol; #endif OYcopy(); yystate = n & 07777; yyval = yylval; #ifdef PI yychar = -1; #else yychar = yylex(); #endif yyshifts++; yytshifts++; goto stack; /* * Reduce. */ case 3: n &= 07777; N = yyr2[n]; if (N == 1 && OY.Yychar == YID && !yyEactr(n, yypv[0])) { idfail = 1; goto errin; } OY.Yychar = -1; ps -= N; yypv -= N; #ifdef PXP yypw -= N; #endif yyval = yypv[1]; yyactr(n); /* * Use goto table to find next state. */ p = &yygo[yypgo[yyr1[n]]]; while (*p != *ps && *p >= 0) p += 2; yystate = p[1]; goto stack; /* * Accept. */ case 4: return; /* * Error. */ case 1: idfail = 0; errin: if ((paniced || yyshifts != 0) && yyrecover(ps, idfail)) { paniced = 0; ps = Ps; yystate = *ps; goto newstate; } /* * Find a state where 'error' is a * legal shift action. */ if (paniced && yyshifts <= 0 && ps >= panicps) { yypv -= (ps - panicps) + 1; #ifdef PXP yypw -= (ps - panicps) + 1; #endif ps = panicps - 1; } while (ps >= yys) { for (p = &yyact[ yypact[*ps+1] ] ; *p <= 0; p += 2) if (*p == -256) { panicps = ps; yystate= p[1] & 07777; yyOshifts = yyshifts; yyshifts = 0; paniced = 1; goto stack; } --ps; --yypv; #ifdef PXP --yypw; #endif #ifdef PI if (OY.Yychar != YID) syneflg = TRUE; #endif OY.Yychar = -1; } if (yychar == YEOF) yyunexeof(); if (yystate == 1) yyexeof(); yerror("Unrecoverable syntax error - QUIT"); return; } panic("yyparse"); }
int yyparse (void) { register int yystate; register int yyn; register short *yyssp; register short *yyrq0; register short *yyptr; register YYSTYPE *yyvsp; int yylen; YYLTYPE *yylsp; short *yyrq1; short *yyrq2; yystate = 0; yyssp = yyss - 1; yyvsp = yyvs - 1; yylsp = yyls - 1; yyrq0 = yyrq; yyrq1 = yyrq0; yyrq2 = yyrq0; yychar = yylex(); if (yychar < 0) yychar = 0; else yychar = YYTRANSLATE(yychar); yynewstate: if (yyssp >= yyss + YYMAXDEPTH - 1) { yyabort("Parser Stack Overflow"); YYABORT; } *++yyssp = yystate; yyresume: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yydefault; yyn += yychar; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar) goto yydefault; yyn = yytable[yyn]; if (yyn < 0) { yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrlab; yystate = yyn; yyptr = yyrq2; while (yyptr != yyrq1) { yyn = *yyptr++; yylen = yyr2[yyn]; yyvsp -= yylen; yylsp -= yylen; yyguard(yyn, yyvsp, yylsp); if (yyerror) goto yysemerr; yyaction(yyn, yyvsp, yylsp); *++yyvsp = yyval; yylsp++; if (yylen == 0) { yylsp->timestamp = timeclock; yylsp->first_line = yytloc.first_line; yylsp->first_column = yytloc.first_column; yylsp->last_line = (yylsp-1)->last_line; yylsp->last_column = (yylsp-1)->last_column; yylsp->text = 0; } else { yylsp->last_line = (yylsp+yylen-1)->last_line; yylsp->last_column = (yylsp+yylen-1)->last_column; } if (yyptr == yyrq + YYMAXRULES) yyptr = yyrq; } if (yystate == YYFINAL) YYACCEPT; yyrq2 = yyptr; yyrq1 = yyrq0; *++yyvsp = yytval; *++yylsp = yytloc; yytval = yylval; yytloc = yylloc; yyget (); goto yynewstate; yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; yyreduce: *yyrq0++ = yyn; if (yyrq0 == yyrq + YYMAXRULES) yyrq0 = yyrq; if (yyrq0 == yyrq2) { yyabort("Parser Rule Queue Overflow"); YYABORT; } yyssp -= yyr2[yyn]; yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; yysemerr: *--yyptr = yyn; yyrq2 = yyptr; yyvsp += yyr2[yyn]; yyerrlab: yygssp = yyssp; yygvsp = yyvsp; yyglsp = yylsp; yyrestore(yyrq0, yyrq2); yyrecover(); yystate = *yygssp; yyssp = yygssp; yyvsp = yygvsp; yyrq0 = yyrq; yyrq1 = yyrq0; yyrq2 = yyrq0; goto yyresume; }