📄 calc_yacc.c
字号:
if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1;#ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; }#else /* no yyoverflow */# ifndef YYSTACK_RELOCATE goto yyexhaustedlab;# else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs);# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); }# endif#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup;/*-----------.| yybackup. |`-----------*/yybackup: /* Do appropriate processing given the current state. Read a look-ahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a look-ahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead 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); YY_SYMBOL_PRINT ("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; /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the look-ahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; 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 96 "calc_yacc.y" { cc_builder((yyvsp[(1) - (1)].n_point)); cc_cleanup((yyvsp[(1) - (1)].n_point)); ;} break; case 3:#line 100 "calc_yacc.y" { (yyval.n_point) = exp_op(',', 2, 0, 0); ;} break; case 4:#line 101 "calc_yacc.y" { (yyval.n_point) = exp_op(',', 2, (yyvsp[(1) - (2)].n_point), (yyvsp[(2) - (2)].n_point)); ;} break; case 5:#line 105 "calc_yacc.y" { (yyval.n_point) = exp_op(',', 2, 0, 0); ;} break; case 6:#line 106 "calc_yacc.y" { (yyval.n_point) = (yyvsp[(1) - (1)].n_point); ;} break; case 7:#line 107 "calc_yacc.y" { (yyval.n_point) = (yyvsp[(1) - (1)].n_point); ;} break; case 8:#line 108 "calc_yacc.y" { (yyval.n_point) = (yyvsp[(1) - (1)].n_point); ;} break; case 9:#line 109 "calc_yacc.y" { (yyval.n_point) = (yyvsp[(1) - (1)].n_point); ;} break; case 10:#line 110 "calc_yacc.y" { (yyval.n_point) = (yyvsp[(1) - (1)].n_point); ;} break; case 11:#line 111 "calc_yacc.y" { (yyval.n_point) = (yyvsp[(2) - (3)].n_point); ;} break; case 12:#line 115 "calc_yacc.y" { (yyval.n_point) = exp_op(IFX, 2, (yyvsp[(3) - (5)].n_point), (yyvsp[(5) - (5)].n_point) ); ;} break; case 13:#line 116 "calc_yacc.y" { (yyval.n_point) = exp_op(IFX, 3, (yyvsp[(3) - (7)].n_point), (yyvsp[(5) - (7)].n_point), (yyvsp[(7) - (7)].n_point)); ;} break; case 14:#line 120 "calc_yacc.y" { (yyval.n_point) = ass_op(GOTO, (yyvsp[(2) - (3)].s_value), 0); ;} break; case 15:#line 124 "calc_yacc.y" { (yyval.n_point) = ass_op(LABE, (yyvsp[(1) - (3)].s_value), (yyvsp[(3) - (3)].n_point)); ;} break; case 16:#line 128 "calc_yacc.y" { (yyval.n_point) = exp_op(DO, 2, (yyvsp[(2) - (7)].n_point), (yyvsp[(5) - (7)].n_point)); ;} break; case 17:#line 129 "calc_yacc.y" { (yyval.n_point) = exp_op(WH, 2, (yyvsp[(3) - (5)].n_point), (yyvsp[(5) - (5)].n_point)); ;} break; case 18:#line 133 "calc_yacc.y" { (yyval.n_point) = exp_op(';', 1, (yyvsp[(1) - (2)].n_point)); ;} break; case 19:#line 137 "calc_yacc.y" { (yyval.n_point) = con_cr((yyvsp[(1) - (1)].r_value)); ;} break; case 20:#line 138 "calc_yacc.y" { (yyval.n_point) = con_ci((yyvsp[(1) - (1)].i_value)); ;} break; case 21:#line 139 "calc_yacc.y" { (yyval.n_point) = con_cc((yyvsp[(1) - (1)].c_value)); ;} break; case 22:#line 140 "calc_yacc.y" { (yyval.n_point) = con_cs((yyvsp[(1) - (1)].s_value)); ;} break; case 23:#line 141 "calc_yacc.y" { (yyval.n_point) = var_id((yyvsp[(1) - (1)].s_value)); ;} break; case 24:#line 142 "calc_yacc.y" { (yyval.n_point) = ass_op((yyvsp[(2) - (3)].i_value), (yyvsp[(1) - (3)].s_value), (yyvsp[(3) - (3)].n_point)); ;} break; case 25:#line 143 "calc_yacc.y" { (yyval.n_point) = exp_op(OOR, 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 26:#line 144 "calc_yacc.y" { (yyval.n_point) = exp_op(AND, 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 27:#line 145 "calc_yacc.y" { (yyval.n_point) = exp_op('|', 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 28:#line 146 "calc_yacc.y" { (yyval.n_point) = exp_op('^', 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 29:#line 147 "calc_yacc.y" { (yyval.n_point) = exp_op('&', 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 30:#line 148 "calc_yacc.y" { (yyval.n_point) = exp_op(CEQ, 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 31:#line 149 "calc_yacc.y" { (yyval.n_point) = exp_op(CNE, 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 32:#line 150 "calc_yacc.y" { (yyval.n_point) = exp_op(CLE, 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 33:#line 151 "calc_yacc.y" { (yyval.n_point) = exp_op(CGE, 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 34:#line 152 "calc_yacc.y" { (yyval.n_point) = exp_op(CLE, 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 35:#line 153 "calc_yacc.y" { (yyval.n_point) = exp_op(CGE, 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 36:#line 154 "calc_yacc.y" { (yyval.n_point) = exp_op(SHL, 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 37:#line 155 "calc_yacc.y" { (yyval.n_point) = exp_op(SHR, 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 38:#line 156 "calc_yacc.y" { (yyval.n_point) = exp_op('+', 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 39:#line 157 "calc_yacc.y" { (yyval.n_point) = exp_op('-', 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 40:#line 158 "calc_yacc.y" { (yyval.n_point) = exp_op('*', 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 41:#line 159 "calc_yacc.y" { (yyval.n_point) = exp_op('/', 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 42:#line 160 "calc_yacc.y" { (yyval.n_point) = exp_op('%', 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break; case 43:#line 161 "calc_yacc.y" { (yyval.n_point) = exp_op('!', 1, (yyvsp[(2) - (2)].n_point)); ;} break; case 44:#line 162 "calc_yacc.y" { (yyval.n_point) = exp_op('~', 1, (yyvsp[(2) - (2)].n_point)); ;} break; case 45:#line 163 "calc_yacc.y" { (yyval.n_point) = exp_op(UMI, 1, (yyvsp[(2) - (2)].n_point)); ;} break; case 46:#line 164 "calc_yacc.y" { (yyval.n_point) = ass_op(CALL, (yyvsp[(1) - (3)].s_value), 0); ;} break; case 47:#line 165 "calc_yacc.y" { (yyval.n_point) = ass_op(CALL, (yyvsp[(1) - (4)].s_value), (yyvsp[(3) - (4)].n_point)); ;} break; case 48:#line 166 "calc_yacc.y" { (yyval.n_point) = (yyvsp[(2) - (3)].n_point); ;} break; case 49:#line 170 "calc_yacc.y" { (yyval.n_point) = exp_op(',', 2, 0, (yyvsp[(1) - (1)].n_point)); ;} break; case 50:#line 171 "calc_yacc.y" { (yyval.n_point) = exp_op(',', 2, (yyvsp[(1) - (3)].n_point), (yyvsp[(3) - (3)].n_point)); ;} break;/* Line 1267 of yacc.c. */#line 1788 "calc_yacc.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; 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 yyerror (YY_("syntax error"));#else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -