⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 y.tab.c

📁 使用yacc和lex编写的cmm语言的词法分析和语法分析程序.
💻 C
📖 第 1 页 / 共 4 页
字号:
    {      /* 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_alloc, yyss);	YYSTACK_RELOCATE (yyvs_alloc, 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));  if (yystate == YYFINAL)    YYACCEPT;  goto yybackup;/*-----------.| yybackup.  |`-----------*/yybackup:  /* Do appropriate processing given the current state.  Read a     lookahead token if we need one and don't already have one.  */  /* First try to decide what to do without reference to lookahead token.  */  yyn = yypact[yystate];  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);      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;    }  /* Count tokens shifted since error; after three, turn off error     status.  */  if (yyerrstatus)    yyerrstatus--;  /* Shift the lookahead token.  */  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);  /* Discard the shifted token.  */  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 6:/* Line 1455 of yacc.c  */#line 53 "ycmm.y"    {            (yyval.code) = NEGATE_EXPR;        }    break;  case 7:/* Line 1455 of yacc.c  */#line 57 "ycmm.y"    {            (yyval.code) = CONVERT_EXPR;        }    break;  case 8:/* Line 1455 of yacc.c  */#line 61 "ycmm.y"    {            (yyval.code) = ADDR_EXPR;        }    break;  case 9:/* Line 1455 of yacc.c  */#line 65 "ycmm.y"    {            (yyval.code) = TRUTH_NOT_EXPR;        }    break;  case 33:/* Line 1455 of yacc.c  */#line 111 "ycmm.y"    {            (yyval.ttype) = (yyvsp[(1) - (1)].ttype);             printf("identifier:%s\n",(yyvsp[(1) - (1)].ttype)->identifier.name);        }    break;  case 34:/* Line 1455 of yacc.c  */#line 116 "ycmm.y"    {            (yyval.ttype) = (yyvsp[(1) - (1)].ttype);            if (TREE_CODE((yyvsp[(1) - (1)].ttype)) == REAL_CST)                  printf("real:%f\n",(yyvsp[(1) - (1)].ttype)->real_cst.value);            else if (TREE_CODE((yyvsp[(1) - (1)].ttype)) == INTEGER_CST)                  printf("int:%d\n",(yyvsp[(1) - (1)].ttype)->int_cst.value);        }    break;  case 35:/* Line 1455 of yacc.c  */#line 124 "ycmm.y"    {            (yyval.ttype) = (yyvsp[(2) - (3)].ttype);        }    break;/* Line 1455 of yacc.c  */#line 1597 "y.tab.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)	  {	    YYSIZE_T yyalloc = 2 * yysize;	    if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))	      yyalloc = YYSTACK_ALLOC_MAXIMUM;	    if (yymsg != yymsgbuf)	      YYSTACK_FREE (yymsg);	    yymsg = (char *) YYSTACK_ALLOC (yyalloc);	    if (yymsg)	      yymsg_alloc = yyalloc;	    else	      {		yymsg = yymsgbuf;		yymsg_alloc = sizeof yymsgbuf;	      }	  }	if (0 < yysize && yysize <= yymsg_alloc)	  {	    (void) yysyntax_error (yymsg, yystate, yychar);	    yyerror (yymsg);	  }	else	  {	    yyerror (YY_("syntax error"));	    if (yysize != 0)	      goto yyexhaustedlab;	  }      }#endif    }  if (yyerrstatus == 3)    {      /* If just tried and failed to reuse lookahead token after an	 error, discard it.  */      if (yychar <= YYEOF)	{	  /* Return failure if at end of input.  */	  if (yychar == YYEOF)	    YYABORT;	}      else	{	  yydestruct ("Error: discarding",		      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:  /* Pacify compilers like GCC when the user code never invokes     YYERROR and the label yyerrorlab therefore never appears in user     code.  */  if (/*CONSTCOND*/ 0)     goto yyerrorlab;  /* Do not reclaim the symbols of the rule which action triggered     this YYERROR.  */  YYPOPSTACK (yylen);  yylen = 0;  YY_STACK_PRINT (yyss, yyssp);  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;      yydestruct ("Error: popping",		  yystos[yystate], yyvsp);      YYPOPSTACK (1);      yystate = *yyssp;      YY_STACK_PRINT (yyss, yyssp);    }  *++yyvsp = yylval;  /* Shift the error token.  */  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);  yystate = yyn;  goto yynewstate;/*-------------------------------------.| yyacceptlab -- YYACCEPT comes here.  |`-------------------------------------*/yyacceptlab:  yyresult = 0;  goto yyreturn;/*-----------------------------------.| yyabortlab -- YYABORT comes here.  |`-----------------------------------*/yyabortlab:  yyresult = 1;  goto yyreturn;#if !defined(yyoverflow) || YYERROR_VERBOSE/*-------------------------------------------------.| yyexhaustedlab -- memory exhaustion comes here.  |`-------------------------------------------------*/yyexhaustedlab:  yyerror (YY_("memory exhausted"));  yyresult = 2;  /* Fall through.  */#endifyyreturn:  if (yychar != YYEMPTY)     yydestruct ("Cleanup: discarding lookahead",		 yytoken, &yylval);  /* Do not reclaim the symbols of the rule which action triggered     this YYABORT or YYACCEPT.  */  YYPOPSTACK (yylen);  YY_STACK_PRINT (yyss, yyssp);  while (yyssp != yyss)    {      yydestruct ("Cleanup: popping",		  yystos[*yyssp], yyvsp);      YYPOPSTACK (1);    }#ifndef yyoverflow  if (yyss != yyssa)    YYSTACK_FREE (yyss);#endif#if YYERROR_VERBOSE  if (yymsg != yymsgbuf)    YYSTACK_FREE (yymsg);#endif  /* Make sure YYID is used.  */  return YYID (yyresult);}/* Line 1675 of yacc.c  */#line 262 "ycmm.y"int main () {      yyparse();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -