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

📄 yacc.c

📁 bison 2.0 主要可以用来做语法分析用的
💻 C
📖 第 1 页 / 共 3 页
字号:
		    &yyvs1, yysize * sizeof (*yyvsp),]b4_location_if([		    &yyls1, yysize * sizeof (*yylsp),])[		    &yystacksize);]b4_location_if([	yyls = yyls1;])[	yyss = yyss1;	yyvs = yyvs1;      }#else /* no yyoverflow */# ifndef YYSTACK_RELOCATE      goto yyoverflowlab;# else      /* Extend the stack our own way.  */      if (YYMAXDEPTH <= yystacksize)	goto yyoverflowlab;      yystacksize *= 2;      if (YYMAXDEPTH < yystacksize)	yystacksize = YYMAXDEPTH;      {	short int *yyss1 = yyss;	union yyalloc *yyptr =	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));	if (! yyptr)	  goto yyoverflowlab;	YYSTACK_RELOCATE (yyss);	YYSTACK_RELOCATE (yyvs);]b4_location_if([	YYSTACK_RELOCATE (yyls);])[#  undef YYSTACK_RELOCATE	if (yyss1 != yyssa)	  YYSTACK_FREE (yyss1);      }# endif#endif /* no yyoverflow */      yyssp = yyss + yysize - 1;      yyvsp = yyvs + yysize - 1;]b4_location_if([      yylsp = yyls + 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.  *//* yyresume: */  /* 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;  /* Shift the look-ahead token.  */  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);  /* Discard the token being shifted unless it is eof.  */  if (yychar != YYEOF)    yychar = YYEMPTY;  *++yyvsp = yylval;]b4_location_if([  *++yylsp = yylloc;])[  /* 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];]b4_location_if([[  /* Default location. */  YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen);]])[  YY_REDUCE_PRINT (yyn);  switch (yyn)    ]{      b4_actions    }/* Line __line__ of yacc.c.  */b4_syncline([@oline@], [@ofile@])[  yyvsp -= yylen;  yyssp -= yylen;]b4_location_if([  yylsp -= yylen;])[  YY_STACK_PRINT (yyss, yyssp);  *++yyvsp = yyval;]b4_location_if([  *++yylsp = yyloc;])[  /* 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 (]b4_yyerror_args[yymsg);	      YYSTACK_FREE (yymsg);	    }	  else	    yyerror (]b4_yyerror_args["syntax error; also virtual memory exhausted");	}      else#endif /* YYERROR_VERBOSE */	yyerror (]b4_yyerror_args["syntax error");    }]b4_location_if([[  yyerror_range[0] = yylloc;]])[  if (yyerrstatus == 3)    {      /* If just tried and failed to reuse look-ahead 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 (;;)	       {]b4_location_if([[                 yyerror_range[0] = *yylsp;]])[		 YYPOPSTACK;		 if (yyssp == yyss)		   YYABORT;		 yydestruct ("Error: popping",                             yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);	       }        }      else	{	  yydestruct ("Error: discarding", yytoken, &yylval]b4_location_if([, &yylloc])[);	  yychar = YYEMPTY;	}    }  /* Else will try to reuse look-ahead 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]b4_location_if([[  yyerror_range[0] = yylsp[1-yylen];  yylsp -= yylen;  ]])[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;]b4_location_if([[      yyerror_range[0] = *yylsp;]])[      yydestruct ("Error: popping", yystos[yystate], yyvsp]b4_location_if([, yylsp])[);      YYPOPSTACK;      yystate = *yyssp;      YY_STACK_PRINT (yyss, yyssp);    }  if (yyn == YYFINAL)    YYACCEPT;  *++yyvsp = yylval;]b4_location_if([[  yyerror_range[1] = yylloc;  /* Using YYLLOC is tempting, but would change the location of     the look-ahead.  YYLOC is available though. */  YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2);  *++yylsp = yyloc;]])[  /* 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:  yydestruct ("Error: discarding lookahead",              yytoken, &yylval]b4_location_if([, &yylloc])[);  yychar = YYEMPTY;  yyresult = 1;  goto yyreturn;#ifndef yyoverflow/*----------------------------------------------.| yyoverflowlab -- parser overflow comes here.  |`----------------------------------------------*/yyoverflowlab:  yyerror (]b4_yyerror_args["parser stack overflow");  yyresult = 2;  /* Fall through.  */#endifyyreturn:#ifndef yyoverflow  if (yyss != yyssa)    YYSTACK_FREE (yyss);#endif  return yyresult;]}b4_epiloguem4_if(b4_defines_flag, 0, [],[@output @output_header_name@b4_copyright([Skeleton parser for Yacc-like parsing with Bison],             [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004])/* As a special exception, when this file is copied by Bison into a   Bison output file, you may use that output file without restriction.   This special exception was added by the Free Software Foundation   in version 1.24 of Bison.  */b4_token_defines(b4_tokens)#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)m4_ifdef([b4_stype],[b4_syncline([b4_stype_line], [b4_filename])typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE;/* Line __line__ of yacc.c.  */b4_syncline([@oline@], [@ofile@])],[typedef int YYSTYPE;])# define yystype YYSTYPE /* obsolescent; will be withdrawn */# define YYSTYPE_IS_DECLARED 1# define YYSTYPE_IS_TRIVIAL 1#endifb4_pure_if([],[extern YYSTYPE b4_prefix[]lval;])b4_location_if([#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)typedef struct YYLTYPE{  int first_line;  int first_column;  int last_line;  int last_column;} YYLTYPE;# define yyltype YYLTYPE /* obsolescent; will be withdrawn */# define YYLTYPE_IS_DECLARED 1# define YYLTYPE_IS_TRIVIAL 1#endifm4_if(b4_pure, [0],[extern YYLTYPE b4_prefix[]lloc;])])])

⌨️ 快捷键说明

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