📄 vtc.c
字号:
/* ** check for syntax error */ if ( yy_n == 0 ) /* have an error */ { /* no worry about speed here! */ switch ( yyerrflag ) { case 0: /* new error */ yyerror( (nl_msg(30003,"syntax error")) ); yynerrs++; goto skip_init; yyerrlab: /* ** get globals into registers. ** we have a user generated syntax type error */ yy_pv = yypv; yy_ps = yyps; yy_state = yystate; yynerrs++; skip_init: case 1: case 2: /* incompletely recovered error */ /* try again... */ yyerrflag = 3; /* ** find state where "error" is a legal ** shift action */ while ( yy_ps >= yys ) { yy_n = yypact[ *yy_ps ] + YYERRCODE; if ( yy_n >= 0 && yy_n < YYLAST && yychk[yyact[yy_n]] == YYERRCODE) { /* ** simulate shift of "error" */ yy_state = yyact[ yy_n ]; goto yy_stack; } /* ** current state has no shift on ** "error", pop stack */#if YYDEBUG# define _POP_ "Error recovery pops state %d, uncovers state %d\n" if ( yydebug ) printf( _POP_, *yy_ps, yy_ps[-1] );# undef _POP_#endif yy_ps--; yy_pv--; } /* ** there is no state on stack with "error" as ** a valid shift. give up. */ YYABORT; case 3: /* no shift yet; eat a token */#if YYDEBUG /* ** if debugging, look up token in list of ** pairs. 0 and negative shouldn't occur, ** but since timing doesn't matter when ** debugging, it doesn't hurt to leave the ** tests here. */ if ( yydebug ) { register int yy_i; printf( "Error recovery discards " ); if ( yychar == 0 ) printf( "token end-of-file\n" ); else if ( yychar < 0 ) printf( "token -none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } printf( "token %s\n", yytoks[yy_i].t_name ); } }#endif /* YYDEBUG */ if ( yychar == 0 ) /* reached EOF. quit */ YYABORT; yychar = -1; goto yy_newstate; } }/* end if ( yy_n == 0 ) */ /* ** reduction by production yy_n ** put stack tops, etc. so things right after switch */#if YYDEBUG /* ** if debugging, print the string that is the user's ** specification of the reduction which is just about ** to be done. */ if ( yydebug ) printf( "Reduce by (%d) \"%s\"\n", yy_n, yyreds[ yy_n ] );#endif yytmp = yy_n; /* value to switch over */ yypvt = yy_pv; /* $vars top of value stack */ /* ** Look in goto table for next state ** Sorry about using yy_state here as temporary ** register variable, but why not, if it works... ** If yyr2[ yy_n ] doesn't have the low order bit ** set, then there is no action to be done for ** this reduction. So, no saving & unsaving of ** registers done. The only difference between the ** code just after the if and the body of the if is ** the goto yy_stack in the body. This way the test ** can be made before the choice of what to do is needed. */ { /* length of production doubled with extra bit */ register int yy_len = yyr2[ yy_n ]; if ( !( yy_len & 01 ) ) { yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } goto yy_stack; } yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } } /* save until reenter driver code */ yystate = yy_state; yyps = yy_ps; yypv = yy_pv; } /* ** code supplied by user is placed in this switch */ switch( yytmp ) { case 2:# line 171 "vtc.y"{ Code(I_NULL); } break;case 3:# line 172 "vtc.y"{ Code(I_NULL); } break;case 6:# line 179 "vtc.y"{ curfunc = yypvt[-1].s; if (find_prmt(yypvt[-1].s) != -1) yyerror(ERR_PRMTNAME); } break;case 8:# line 185 "vtc.y"{ reqargs = avarc; } break;case 15:# line 196 "vtc.y"{ add_tag(avars, &avarc, yypvt[-0].s); } break;case 16:# line 197 "vtc.y"{ add_tag(avars, &avarc, yypvt[-0].s); } break;case 17:# line 200 "vtc.y"{ add_tag(lvars, &lvarc, yypvt[-0].s); } break;case 18:# line 201 "vtc.y"{ add_tag(lvars, &lvarc, yypvt[-0].s); } break;case 19:# line 204 "vtc.y"{ Code(I_EVAL); } break;case 21:# line 208 "vtc.y"{ code_var(yypvt[-0].s); } break;case 22:# line 209 "vtc.y"{ Code2(I_BOBJ, bobj, yypvt[-0].bobj); } break;case 23:# line 210 "vtc.y"{ Code2(I_SCONST, sindex, enter_sconst(cstr_s(yypvt[-0].s))); Code_pcall(PR_LOOKUP, 2); } break;case 24:# line 213 "vtc.y"{ Code_pcall(OP_ADD, 2); } break;case 25:# line 214 "vtc.y"{ if (yypvt[-1].num) { Code_iconst(yypvt[-1].num); Code_pcall(OP_ADD, 2); } } break;case 29:# line 223 "vtc.y"{ Code_iconst(yypvt[-0].num); } break;case 30:# line 224 "vtc.y"{ Code2(I_SCONST, sindex, yypvt[-0].str); } break;case 31:# line 225 "vtc.y"{ int ind = find_prmt(yypvt[-0].s); if (ind != -1) Code2(I_PPTR, pnum, ind); else Code2(I_FPTR, ident, yypvt[-0].s); } break;case 32:# line 229 "vtc.y"{ int ind = find_prmt(yypvt[-3].s); if (ind != -1) Code_pcall(ind, yypvt[-1].num); else Code_fcall(yypvt[-3].s, yypvt[-1].num); } break;case 33:# line 233 "vtc.y"{ Code2(I_EXEC, argc, yypvt[-1].num); } break;case 36:# line 239 "vtc.y"{ Code_pcall(OP_POSTINC, 1); } break;case 37:# line 240 "vtc.y"{ Code_pcall(OP_POSTDEC, 1); } break;case 39:# line 244 "vtc.y"{ Code(I_EVAL); } break;case 40:# line 245 "vtc.y"{ Code_pcall(OP_PREINC, 1); } break;case 41:# line 246 "vtc.y"{ Code_pcall(OP_PREDEC, 1); } break;case 42:# line 247 "vtc.y"{ Code_pcall(OP_NOT, 1); } break;case 43:# line 248 "vtc.y"{ Code_pcall(OP_COMPL, 1); } break;case 44:# line 249 "vtc.y"{ Code_pcall(OP_NEG, 1); } break;case 48:# line 255 "vtc.y"{ Code(I_CVTB); Jmp(I_JMPPT); } break;case 49:# line 256 "vtc.y"{ Code(I_CVTB); Dest; } break;case 50:# line 257 "vtc.y"{ Code(I_CVTB); Jmp(I_JMPPF); } break;case 51:# line 258 "vtc.y"{ Code(I_CVTB); Dest; } break;case 52:# line 259 "vtc.y"{ Code_pcall(OP_BOR, 2); } break;case 53:# line 260 "vtc.y"{ Code_pcall(OP_BXOR, 2); } break;case 54:# line 261 "vtc.y"{ Code_pcall(OP_BAND, 2); } break;case 55:# line 262 "vtc.y"{ Code_pcall(OP_EQ, 2); } break;case 56:# line 263 "vtc.y"{ Code_pcall(OP_NE, 2); } break;case 57:# line 264 "vtc.y"{ Code_pcall(OP_LT, 2); } break;case 58:# line 265 "vtc.y"{ Code_pcall(OP_LE, 2); } break;case 59:# line 266 "vtc.y"{ Code_pcall(OP_GT, 2); } break;case 60:# line 267 "vtc.y"{ Code_pcall(OP_GE, 2); } break;case 61:# line 268 "vtc.y"{ Code_pcall(OP_SL, 2); } break;case 62:# line 269 "vtc.y"{ Code_pcall(OP_SR, 2); } break;case 63:# line 270 "vtc.y"{ Code_pcall(OP_ADD, 2); } break;case 64:# line 271 "vtc.y"{ Code_pcall(OP_SUB, 2); } break;case 65:# line 272 "vtc.y"{ Code_pcall(OP_MULT, 2); } break;case 66:# line 273 "vtc.y"{ Code_pcall(OP_DIV, 2); } break;case 67:# line 274 "vtc.y"{ Code_pcall(OP_MOD, 2); } break;case 68:# line 275 "vtc.y"{ Jmp(I_JMPF); } break;case 69:# line 276 "vtc.y"{ Destnext; Jmp(I_JMP); } break;case 70:# line 277 "vtc.y"{ Dest; } break;case 71:# line 278 "vtc.y"{ Jmp(I_JMPPT); } break;case 72:# line 278 "vtc.y"{ Dest; } break;case 74:# line 282 "vtc.y"{ Code_pcall(OP_ASN, 2); } break;case 75:# line 283 "vtc.y"{ Code(I_DUP); Code(I_EVAL); } break;case 76:# line 284 "vtc.y"{ Code_pcall(yypvt[-2].num, 2); Code_pcall(OP_ASN, 2); } break;case 77:# line 286 "vtc.y"{ Code(I_DUP); Code(I_EVAL); Jmp(I_JMPPT); } break;case 78:# line 288 "vtc.y"{ Dest; Code_pcall(OP_ASN, 2); } break;case 79:# line 291 "vtc.y"{ yyval.num = OP_MULT; } break;case 80:# line 291 "vtc.y"{ yyval.num = OP_DIV; } break;case 81:# line 292 "vtc.y"{ yyval.num = OP_MOD; } break;case 82:# line 292 "vtc.y"{ yyval.num = OP_ADD; } break;case 83:# line 293 "vtc.y"{ yyval.num = OP_SUB; } break;case 84:# line 293 "vtc.y"{ yyval.num = OP_SL; } break;case 85:# line 294 "vtc.y"{ yyval.num = OP_SR; } break;case 86:# line 294 "vtc.y"{ yyval.num = OP_BAND; } break;case 87:# line 295 "vtc.y"{ yyval.num = OP_BXOR; } break;case 88:# line 295 "vtc.y"{ yyval.num = OP_BOR; } break;case 90:# line 300 "vtc.y"{ Code(I_POP); } break;case 92:# line 304 "vtc.y"{ yyval.num = 1; } break;case 93:# line 305 "vtc.y"{ yyval.num = yypvt[-2].num + 1; } break;case 94:# line 308 "vtc.y"{ yyval.num = 0; } break;case 97:# line 314 "vtc.y"{ Code(I_POP); } break;case 98:# line 318 "vtc.y"{ Code_iconst(1); } break;case 103:# line 328 "vtc.y"{ Jmp(I_JMPF); } break;case 106:# line 332 "vtc.y"{ Dest; } break;case 107:# line 333 "vtc.y"{ Destnext; Jmp(I_JMP); } break;case 108:# line 333 "vtc.y"{ Dest; } break;case 109:# line 334 "vtc.y"{ Incloop(2); Ldest(0); } break;case 110:# line 335 "vtc.y"{ Ljmp(1, I_JMPF); } break;case 111:# line 336 "vtc.y"{ Ljmp(0, I_JMP); Ldest(1); Decloop; } break;case 112:# line 337 "vtc.y"{ Incloop(3); Ldest(2); } break;case 113:# line 338 "vtc.y"{ Ldest(0); } break;case 114:# line 339 "vtc.y"{ Ljmp(2, I_JMPT); Ldest(1); Decloop; } break;case 115:# line 340 "vtc.y"{ Incloop(4); Ldest(3); } break;case 116:# line 341 "vtc.y"{ Ljmp(1, I_JMPF); Ljmp(2, I_JMP); Ldest(0); } break;case 117:# line 343 "vtc.y"{ Ljmp(3, I_JMP); Ldest(2); } break;case 118:# line 344 "vtc.y"{ Ljmp(0, I_JMP); Ldest(1); Decloop; } break;case 119:# line 345 "vtc.y"{ code_goto(yypvt[-1].s, 0); } break;case 121:# line 346 "vtc.y"{ code_goto(yypvt[-1].s, 1); } break;case 122:# line 347 "vtc.y"{ Break; } break;case 123:# line 348 "vtc.y"{ Continue; } break;case 124:# line 349 "vtc.y"{ Code(I_NULL); Return; } break;case 125:# line 350 "vtc.y"{ Return; } break;case 127:# line 355 "vtc.y"{ yyerror(ERR_RESERVED); yyval.s = ""; } break; } goto yystack; /* reset registers in driver code */}# ifdef __RUNTIME_YYMAXDEPTHstatic int allocate_stacks() { /* allocate the yys and yyv stacks */ yys = (int *) malloc(yymaxdepth * sizeof(int)); yyv = (YYSTYPE *) malloc(yymaxdepth * sizeof(YYSTYPE)); if (yys==0 || yyv==0) { yyerror( (nl_msg(30004,"unable to allocate space for yacc stacks")) ); return(1); } else return(0);}static void free_stacks() { if (yys!=0) free((char *) yys); if (yyv!=0) free((char *) yyv);}# endif /* defined(__RUNTIME_YYMAXDEPTH) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -