?? btyaccpa.ske
字號:
memcpy (yyerrctx->ss, yyps->ss, (yyps->ssp - yyps->ss + 1)*sizeof(Yshort)); YYSCopy(yyerrctx->vs, yyps->vs, (yyps->ssp - yyps->ss + 1)); YYPCopy(yyerrctx->ps, yyps->ps, (yyps->ssp - yyps->ss + 1)); yyerrctx->lexeme = yylvp - yylvals; } yylvp = yylvals + save->lexeme; yylpp = yylpsns + save->lexeme; yylexp = yylexemes + save->lexeme; yychar = -1; yyps->ssp = yyps->ss + (save->ssp - save->ss); yyps->vsp = yyps->vs + (save->vsp - save->vs); yyps->psp = yyps->ps + (save->psp - save->ps); memcpy (yyps->ss, save->ss, (yyps->ssp - yyps->ss + 1) * sizeof(Yshort)); YYSCopy(yyps->vs, save->vs, yyps->vsp - yyps->vs + 1); YYPCopy(yyps->ps, save->ps, yyps->psp - yyps->ps + 1); ctry = ++save->ctry; yystate = save->state; // We tried shift, try reduce now if ((yyn = yyctable[ctry]) >= 0) { goto yyreduce; } yyps->save = save->save; YYFreeState(save); // // Nothing left on the stack -- error // if (!yyps->save) {#if YYDEBUG if (yydebug) { printf("yydebug[%d]: trial parse FAILED, entering ERROR mode\n", (int)yytrial); }#endif // Restore state as it was in the most forward-advanced error yylvp = yylvals + yyerrctx->lexeme; yylpp = yylpsns + yyerrctx->lexeme; yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; yyposn = yylpp[-1]; yyps->ssp = yyps->ss + (yyerrctx->ssp - yyerrctx->ss); yyps->vsp = yyps->vs + (yyerrctx->vsp - yyerrctx->vs); yyps->psp = yyps->ps + (yyerrctx->psp - yyerrctx->ps); memcpy (yyps->ss, yyerrctx->ss, (yyps->ssp - yyps->ss + 1) * sizeof(Yshort)); YYSCopy(yyps->vs, yyerrctx->vs, yyps->vsp - yyps->vs + 1); YYPCopy(yyps->ps, yyerrctx->ps, yyps->psp - yyps->ps + 1); yystate = yyerrctx->state; YYFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag) {#ifdef YYERROR_DETAILED yyerror_detailed("syntax error", yychar, yylval, yyposn);#else yyerror("syntax error");#endif } ++yynerrs; yyinrecovery: if (yyps->errflag < 3) { yyps->errflag = 3; for (;;) { if ((yyn = yysindex[*(yyps->ssp)]) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) {#if YYDEBUG if (yydebug) printf("yydebug[%d,%d]: state %d, ERROR recovery shifts to state %d\n", yydepth, (int)yytrial, *(yyps->ssp), yytable[yyn]);#endif /* Use label yyerrlab, so that compiler does not warn */ if(yyps->errflag != yyps->errflag) goto yyerrlab; yystate = yytable[yyn]; goto yyshift; } else {#if YYDEBUG if (yydebug) printf("yydebug[%d,%d]: ERROR recovery discards state %d\n", yydepth, (int)yytrial, *(yyps->ssp));#endif if (yyps->ssp <= yyps->ss) { goto yyabort; } if(!yytrial) { YYDELETEVAL(yyps->vsp[0],1); YYDELETEPOSN(yyps->psp[0],1); } --(yyps->ssp); --(yyps->vsp); --(yyps->psp); } } } else { if (yychar == 0) goto yyabort;#if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("yydebug[%d,%d]: state %d, ERROR recovery discards token %d (%s)\n", yydepth, (int)yytrial, yystate, yychar, yys); }#endif if(!yytrial) { YYDELETEVAL(yylval,0); YYDELETEPOSN(yyposn,0); } yychar = (-1); goto yyloop; } // // Reduce the rule //yyreduce: yym = yylen[yyn];#if YYDEBUG if (yydebug) { printf("yydebug[%d,%d]: state %d, reducing by rule %d (%s)", yydepth, (int)yytrial, yystate, yyn, yyrule[yyn]);#ifdef YYDBPR if (yym) { int i; printf("<"); for (i=yym; i>0; i--) { if (i!=yym) printf(", "); YYDBPR((yyps->vsp)[1-i]); } printf(">"); }#endif printf("\n"); }#endif if (yyps->ssp + 1 - yym >= yyps->ss + yyps->stacksize) { YYMoreStack(yyps); } /* "$$ = NULL" default action */ memset(&yyps->val, 0, sizeof(yyps->val)); /* default reduced position is NULL -- no position at all. no position will be assigned at trial time and if no position handling is present */ memset(&yyps->pos, 0, sizeof(yyps->pos)); reduce_posn = TRUE; switch (yyn) {%% trailer default: break; }#if YYDEBUG && defined(YYDBPR) if (yydebug) { printf("yydebug[%d]: after reduction, result is ", yytrial); YYDBPR(yyps->val); printf("\n"); }#endif // Perform user-defined position reduction#ifdef YYREDUCEPOSNFUNC if(!yytrial) { YYCALLREDUCEPOSN(YYREDUCEPOSNFUNCARG); }#endif yyps->ssp -= yym; yystate = *(yyps->ssp); yyps->vsp -= yym; yyps->psp -= yym; yym = yylhs[yyn]; if (yystate == 0 && yym == 0) {#if YYDEBUG if (yydebug) { printf("yydebug[%d,%d]: after reduction, shifting from state 0 to state %d\n", yydepth, (int)yytrial, YYFINAL); }#endif yystate = YYFINAL; *++(yyps->ssp) = YYFINAL; *++(yyps->vsp) = yyps->val; yyretlval = yyps->val; // return value of root non-terminal to yylval *++(yyps->psp) = yyps->pos; yyretposn = yyps->pos; // return value of root position to yyposn if (yychar < 0) { if ((yychar = YYLex1()) < 0) { yychar = 0; }#if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("yydebug[%d,%d]: state %d, reading %d (%s)\n", yydepth, (int)yytrial, YYFINAL, yychar, yys); }#endif } if (yychar == 0) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) { yystate = yytable[yyn]; } else { yystate = yydgoto[yym]; }#if YYDEBUG if (yydebug) printf("yydebug[%d,%d]: after reduction, shifting from state %d to state %d\n", yydepth, (int)yytrial, *(yyps->ssp), yystate);#endif if (yyps->ssp >= yyps->ss + yyps->stacksize - 1) { YYMoreStack(yyps); } *++(yyps->ssp) = yystate; *++(yyps->vsp) = yyps->val; *++(yyps->psp) = yyps->pos; goto yyloop; // // Reduction declares that this path is valid. // Set yypath and do a full parse //yyvalid: if (yypath) { goto yyabort; } while (yyps->save) { yyparsestate *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; }#if YYDEBUG if (yydebug) printf("yydebug[%d,%d]: CONFLICT trial successful, backtracking to state %d, %d tokens\n", yydepth, (int)yytrial, yypath->state, yylvp - yylvals - yypath->lexeme);#endif if(yyerrctx) { YYFreeState(yyerrctx); yyerrctx = NULL; } yychar = -1; yyps->ssp = yyps->ss + (yypath->ssp - yypath->ss); yyps->vsp = yyps->vs + (yypath->vsp - yypath->vs); yyps->psp = yyps->ps + (yypath->psp - yypath->ps); memcpy (yyps->ss, yypath->ss, (yyps->ssp - yyps->ss + 1) * sizeof(Yshort)); YYSCopy(yyps->vs, yypath->vs, yyps->vsp - yyps->vs + 1); YYPCopy(yyps->ps, yypath->ps, yyps->psp - yyps->ps + 1); yylvp = yylvals + yypath->lexeme; yylpp = yylpsns + yypath->lexeme; yylexp = yylexemes + yypath->lexeme; yystate = yypath->state; goto yyloop;yyabort: if(yyerrctx) { YYFreeState(yyerrctx); yyerrctx = NULL; } YYSTYPE *pv; for(pv=yyps->vs; pv<yyps->vsp; pv++) { YYDELETEVAL(*pv,2); } YYPOSN *pp; for(pp=yyps->ps; pp<yyps->psp; pp++) { YYDELETEPOSN(*pp,2); } while (yyps) { yyparsestate *save = yyps; yyps = save->save; YYFreeState(save); } while (yypath) { yyparsestate *save = yypath; yypath = save->save; YYFreeState(save); } return (1);yyaccept: if (yyps->save) goto yyvalid; if(yyerrctx) { YYFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { yyparsestate *save = yyps; yyps = save->save; YYFreeState(save); } while (yypath) { yyparsestate *save = yypath; yypath = save->save; YYFreeState(save); } return (0);}int YYLex1() { if(yylvp<yylve) { yylval = *yylvp++; yyposn = *yylpp++; return *yylexp++; } else { if(yyps->save) { if(yylvp==yylvlim) { yyexpand(); } *yylexp = yylex(); *yylvp++ = yylval; yylve++; *yylpp++ = yyposn; yylpe++; return *yylexp++; } else { return yylex(); } }}int yyexpand() { int p = yylvp-yylvals; int s = yylvlim-yylvals; s += YYSTACKGROWTH; { Yshort *tl = yylexemes; YYSTYPE *tv = yylvals; YYPOSN *tp = yylpsns; yylvals = new YYSTYPE[s]; yylpsns = new YYPOSN[s]; yylexemes = new Yshort[s]; memcpy(yylexemes, tl, (s-YYSTACKGROWTH)*sizeof(Yshort)); YYSCopy(yylvals, tv, s-YYSTACKGROWTH); YYPCopy(yylpsns, tp, s-YYSTACKGROWTH); delete[] tl; delete[] tv; delete[] tp; } yylvp = yylve = yylvals + p; yylvlim = yylvals + s; yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; yylexp = yylexemes + p; return 0;}void YYSCopy(YYSTYPE *to, YYSTYPE *from, int size) { int i; for (i = size-1; i >= 0; i--) { to[i] = from[i]; }}void YYPCopy(YYPOSN *to, YYPOSN *from, int size) { int i; for (i = size-1; i >= 0; i--) { to[i] = from[i]; }}void YYMoreStack(yyparsestate *yyps) { int p = yyps->ssp - yyps->ss; Yshort *tss = yyps->ss; YYSTYPE *tvs = yyps->vs; YYPOSN *tps = yyps->ps; yyps->ss = new Yshort [yyps->stacksize + YYSTACKGROWTH]; yyps->vs = new YYSTYPE[yyps->stacksize + YYSTACKGROWTH]; yyps->ps = new YYPOSN [yyps->stacksize + YYSTACKGROWTH]; memcpy(yyps->ss, tss, yyps->stacksize * sizeof(Yshort)); YYSCopy(yyps->vs, tvs, yyps->stacksize); YYPCopy(yyps->ps, tps, yyps->stacksize); yyps->stacksize += YYSTACKGROWTH; delete[] tss; delete[] tvs; delete[] tps; yyps->ssp = yyps->ss + p; yyps->vsp = yyps->vs + p; yyps->psp = yyps->ps + p; }yyparsestate *YYNewState(int size) { yyparsestate *p = new yyparsestate; p->stacksize = size+4; p->ss = new Yshort [size + 4]; p->vs = new YYSTYPE[size + 4]; p->ps = new YYPOSN [size + 4]; memset(&p->vs[0], 0, (size+4)*sizeof(YYSTYPE)); memset(&p->ps[0], 0, (size+4)*sizeof(YYPOSN)); return p;}void YYFreeState(yyparsestate *p) { delete[] p->ss; delete[] p->vs; delete[] p->ps; delete p;}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -