?? parse_isa.cpp
字號(hào):
if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate;/*-----------------------------------------------------------.| yydefault -- do the default action for the current state. |`-----------------------------------------------------------*/yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce;/*-----------------------------.| yyreduce -- Do a reduction. |`-----------------------------*/yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2:#line 72 "parse_isa.y" { isa_parser_result = new isa_prog(yyvsp[-2].fenv_t, yyvsp[-1].venv_t, yyvsp[0].oper_list_t); } break; case 3:#line 77 "parse_isa.y" { yyval.fenv_t = yyvsp[-1].fenv_t; } break; case 4:#line 82 "parse_isa.y" { yyval.fenv_t = new FIELD_ENV; yyval.fenv_t->insert(FIELD_T(yyvsp[-3].sym_t, yyvsp[-1].uint)); } break; case 5:#line 86 "parse_isa.y" { yyval.fenv_t = yyvsp[-4].fenv_t; if (yyval.fenv_t->find(yyvsp[-3].sym_t)!=yyval.fenv_t->end()) { warn("Ignoring redeclaration of field ", yyvsp[-3].sym_t); } else { yyval.fenv_t->insert(FIELD_T(yyvsp[-3].sym_t, yyvsp[-1].uint)); } } break; case 6:#line 97 "parse_isa.y" { yyval.venv_t = yyvsp[-1].venv_t; } break; case 7:#line 100 "parse_isa.y" { yyval.venv_t = new VAR_ENV; } break; case 8:#line 105 "parse_isa.y" { yyval.venv_t = new VAR_ENV; yyval.venv_t->insert(VAR_T(yyvsp[-3].sym_t, yyvsp[-1].sym_t)); } break; case 9:#line 109 "parse_isa.y" { yyval.venv_t = yyvsp[-4].venv_t; if (yyval.venv_t->find(yyvsp[-3].sym_t)!=yyval.venv_t->end()) { warn("Ignoring redeclaration of variable ", yyvsp[-3].sym_t); } else { yyval.venv_t->insert(VAR_T(yyvsp[-3].sym_t, yyvsp[-1].sym_t)); } } break; case 10:#line 120 "parse_isa.y" { yyval.oper_list_t = new vector<oper_base *>; yyval.oper_list_t->push_back(yyvsp[0].oper_t); } break; case 11:#line 124 "parse_isa.y" { yyval.oper_list_t = yyvsp[-1].oper_list_t; yyval.oper_list_t->push_back(yyvsp[0].oper_t); } break; case 12:#line 130 "parse_isa.y" { yyval.oper_t = new oper(yyvsp[-6].sym_t, yyvsp[-4].code_list_t, yyvsp[-1].op_con_env_t); } break; case 13:#line 133 "parse_isa.y" { yyval.oper_t = new group(yyvsp[-3].sym_t, yyvsp[-1].oper_list_t); } break; case 14:#line 139 "parse_isa.y" { yyval.code_list_t = new vector<bin_code *>; yyval.code_list_t->push_back(new bin_literal(yyvsp[0].strval)); free(yyvsp[0].strval); } break; case 15:#line 144 "parse_isa.y" { yyval.code_list_t = new vector<bin_code *>; yyval.code_list_t->push_back(new bin_ident(yyvsp[0].sym_t)); } break; case 16:#line 148 "parse_isa.y" { yyval.code_list_t = yyvsp[-2].code_list_t; yyval.code_list_t->push_back(new bin_literal(yyvsp[0].strval)); free(yyvsp[0].strval); } break; case 17:#line 153 "parse_isa.y" { yyval.code_list_t = yyvsp[-2].code_list_t; yyval.code_list_t->push_back(new bin_ident(yyvsp[0].sym_t)); } break; case 18:#line 159 "parse_isa.y" { yyval.op_con_env_t = new OP_CON_ENV; yyval.op_con_env_t->insert(*(yyvsp[0].op_con_t)); delete yyvsp[0].op_con_t; } break; case 19:#line 164 "parse_isa.y" { yyval.op_con_env_t = yyvsp[-1].op_con_env_t; if (yyval.op_con_env_t->find(yyvsp[0].op_con_t->first)!=yyval.op_con_env_t->end()) { warn("Ignoring redeclaration of ", yyvsp[0].op_con_t->first); } else { yyval.op_con_env_t->insert(*(yyvsp[0].op_con_t)); } delete yyvsp[0].op_con_t; } break; case 20:#line 176 "parse_isa.y" { yyval.op_con_t = new OP_CON_T(yyvsp[-2].sym_t, yyvsp[0].strval); } break; }/* Line 1000 of yacc.c. */#line 1242 "parse_isa.cpp" yyvsp -= yylen; yyssp -= yylen; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate;/*------------------------------------.| yyerrlab -- here on detecting error |`------------------------------------*/yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs;#if YYERROR_VERBOSE yyn = yypact[yystate]; if (YYPACT_NINF < yyn && yyn < YYLAST) { YYSIZE_T yysize = 0; int yytype = YYTRANSLATE (yychar); const char* yyprefix; char *yymsg; int yyx; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 0; yyprefix = ", expecting "; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); yycount += 1; if (yycount == 5) { yysize = 0; break; } } yysize += (sizeof ("syntax error, unexpected ") + yystrlen (yytname[yytype])); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); yyp = yystpcpy (yyp, yytname[yytype]); if (yycount < 5) { yyprefix = ", expecting "; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { yyp = yystpcpy (yyp, yyprefix); yyp = yystpcpy (yyp, yytname[yyx]); yyprefix = " or "; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else yyerror ("syntax error; also virtual memory exhausted"); } else#endif /* YYERROR_VERBOSE */ yyerror ("syntax error"); } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* If at end of input, pop the error token, then the rest of the stack, then return failure. */ if (yychar == YYEOF) for (;;) { YYPOPSTACK; if (yyssp == yyss) YYABORT; YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[*yyssp], yyvsp); } } else { YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); yydestruct (yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1;/*---------------------------------------------------.| yyerrorlab -- error raised explicitly by YYERROR. |`---------------------------------------------------*/yyerrorlab:#ifdef __GNUC__ /* Pacify GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (0) goto yyerrorlab;#endif yyvsp -= yylen; yyssp -= yylen; yystate = *yyssp; goto yyerrlab1;/*-------------------------------------------------------------.| yyerrlab1 -- common code for both syntax error and YYERROR. |`-------------------------------------------------------------*/yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[yystate], yyvsp); YYPOPSTACK; yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } if (yyn == YYFINAL) YYACCEPT; YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval; yystate = yyn; goto yynewstate;/*-------------------------------------.| yyacceptlab -- YYACCEPT comes here. |`-------------------------------------*/yyacceptlab: yyresult = 0; goto yyreturn;/*-----------------------------------.| yyabortlab -- YYABORT comes here. |`-----------------------------------*/yyabortlab: yyresult = 1; goto yyreturn;#ifndef yyoverflow/*----------------------------------------------.| yyoverflowlab -- parser overflow comes here. |`----------------------------------------------*/yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */#endifyyreturn:#ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss);#endif return yyresult;}#line 180 "parse_isa.y"static void warn(char *msg, Symbol ident) { fprintf(stderr, "%s %s\n", msg, symbol_get_string(ident).c_str());}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -