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

📄 parse-gram.c

📁 GNU的词法/语法分析器bison源码
💻 C
📖 第 1 页 / 共 5 页
字号:
  case 64:#line 393 "parse-gram.y"    { grammar_rule_end ((yylsp[0])); }    break;  case 65:#line 394 "parse-gram.y"    { grammar_rule_end ((yylsp[0])); }    break;  case 67:#line 400 "parse-gram.y"    { grammar_rule_begin (current_lhs, current_lhs_location); }    break;  case 68:#line 402 "parse-gram.y"    { grammar_current_rule_symbol_append ((yyvsp[0].symbol), (yylsp[0])); }    break;  case 69:#line 404 "parse-gram.y"    { grammar_current_rule_action_append ((yyvsp[0].chars), (yylsp[0])); }    break;  case 70:#line 406 "parse-gram.y"    { grammar_current_rule_prec_set ((yyvsp[0].symbol), (yylsp[0])); }    break;  case 71:#line 408 "parse-gram.y"    { grammar_current_rule_dprec_set ((yyvsp[0].integer), (yylsp[0])); }    break;  case 72:#line 410 "parse-gram.y"    { grammar_current_rule_merge_set ((yyvsp[0].uniqstr), (yylsp[0])); }    break;  case 73:#line 414 "parse-gram.y"    { (yyval.symbol) = (yyvsp[0].symbol); }    break;  case 74:#line 415 "parse-gram.y"    { (yyval.symbol) = (yyvsp[0].symbol); }    break;  case 75:#line 420 "parse-gram.y"    { (yyval.chars) = (yyvsp[0].chars); }    break;  case 76:#line 426 "parse-gram.y"    {      (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[0].chars)), (yylsp[0]));      symbol_class_set ((yyval.symbol), token_sym, (yylsp[0]));    }    break;  case 77:#line 435 "parse-gram.y"    { (yyval.chars) = (yyvsp[0].chars); }    break;  case 79:#line 442 "parse-gram.y"    {      muscle_code_grow ("epilogue", (yyvsp[0].chars), (yylsp[0]));      scanner_last_string_free ();    }    break;      default: break;    }/* Line 1126 of yacc.c.  */#line 1912 "parse-gram.c"  yyvsp -= yylen;  yyssp -= yylen;  yylsp -= yylen;  YY_STACK_PRINT (yyss, yyssp);  *++yyvsp = yyval;  *++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)	{	  int yytype = YYTRANSLATE (yychar);	  YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);	  YYSIZE_T yysize = yysize0;	  YYSIZE_T yysize1;	  int yysize_overflow = 0;	  char *yymsg = 0;#	  define YYERROR_VERBOSE_ARGS_MAXIMUM 5	  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];	  int yyx;#if 0	  /* This is so xgettext sees the translatable formats that are	     constructed on the fly.  */	  YY_("syntax error, unexpected %s");	  YY_("syntax error, unexpected %s, expecting %s");	  YY_("syntax error, unexpected %s, expecting %s or %s");	  YY_("syntax error, unexpected %s, expecting %s or %s or %s");	  YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");#endif	  char *yyfmt;	  char const *yyf;	  static char const yyunexpected[] = "syntax error, unexpected %s";	  static char const yyexpecting[] = ", expecting %s";	  static char const yyor[] = " or %s";	  char yyformat[sizeof yyunexpected			+ sizeof yyexpecting - 1			+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)			   * (sizeof yyor - 1))];	  char const *yyprefix = yyexpecting;	  /* 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 = 1;	  yyarg[0] = yytname[yytype];	  yyfmt = yystpcpy (yyformat, yyunexpected);	  for (yyx = yyxbegin; yyx < yyxend; ++yyx)	    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)	      {		if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)		  {		    yycount = 1;		    yysize = yysize0;		    yyformat[sizeof yyunexpected - 1] = '\0';		    break;		  }		yyarg[yycount++] = yytname[yyx];		yysize1 = yysize + yytnamerr (0, yytname[yyx]);		yysize_overflow |= yysize1 < yysize;		yysize = yysize1;		yyfmt = yystpcpy (yyfmt, yyprefix);		yyprefix = yyor;	      }	  yyf = YY_(yyformat);	  yysize1 = yysize + yystrlen (yyf);	  yysize_overflow |= yysize1 < yysize;	  yysize = yysize1;	  if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)	    yymsg = (char *) YYSTACK_ALLOC (yysize);	  if (yymsg)	    {	      /* Avoid sprintf, as that infringes on the user's name space.		 Don't have undefined behavior even if the translation		 produced a string with the wrong number of "%s"s.  */	      char *yyp = yymsg;	      int yyi = 0;	      while ((*yyp = *yyf))		{		  if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)		    {		      yyp += yytnamerr (yyp, yyarg[yyi++]);		      yyf += 2;		    }		  else		    {		      yyp++;		      yyf++;		    }		}	      yyerror (yymsg);	      YYSTACK_FREE (yymsg);	    }	  else	    {	      yyerror (YY_("syntax error"));	      goto yyexhaustedlab;	    }	}      else#endif /* YYERROR_VERBOSE */	yyerror (YY_("syntax error"));    }  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)        {	  /* Return failure if at end of input.  */	  if (yychar == YYEOF)	    YYABORT;        }      else	{	  yydestruct ("Error: discarding", yytoken, &yylval, &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:  /* Pacify compilers like GCC when the user code never invokes     YYERROR and the label yyerrorlab therefore never appears in user     code.  */  if (0)     goto yyerrorlab;  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;      yyerror_range[0] = *yylsp;      yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp);      YYPOPSTACK;      yystate = *yyssp;      YY_STACK_PRINT (yyss, yyssp);    }  if (yyn == YYFINAL)    YYACCEPT;  *++yyvsp = yylval;  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:  yyresult = 1;  goto yyreturn;#ifndef yyoverflow/*-------------------------------------------------.| yyexhaustedlab -- memory exhaustion comes here.  |`-------------------------------------------------*/yyexhaustedlab:  yyerror (YY_("memory exhausted"));  yyresult = 2;  /* Fall through.  */#endifyyreturn:  if (yychar != YYEOF && yychar != YYEMPTY)     yydestruct ("Cleanup: discarding lookahead",		 yytoken, &yylval, &yylloc);  while (yyssp != yyss)    {      yydestruct ("Cleanup: popping",		  yystos[*yyssp], yyvsp, yylsp);      YYPOPSTACK;    }#ifndef yyoverflow  if (yyss != yyssa)    YYSTACK_FREE (yyss);#endif  return yyresult;}#line 448 "parse-gram.y"/* Return the location of the left-hand side of a rule whose   right-hand side is RHS[1] ... RHS[N].  Ignore empty nonterminals in   the right-hand side, and return an empty location equal to the end   boundary of RHS[0] if the right-hand side is empty.  */static YYLTYPElloc_default (YYLTYPE const *rhs, int n){  int i;  YYLTYPE loc;  /* SGI MIPSpro 7.4.1m miscompiles "loc.start = loc.end = rhs[n].end;".     The bug is fixed in 7.4.2m, but play it safe for now.  */  loc.start = rhs[n].end;  loc.end = rhs[n].end;  /* Ignore empty nonterminals the start of the the right-hand side.     Do not bother to ignore them at the end of the right-hand side,     since empty nonterminals have the same end as their predecessors.  */  for (i = 1; i <= n; i++)    if (! equal_boundaries (rhs[i].start, rhs[i].end))      {	loc.start = rhs[i].start;	break;      }  return loc;}/* Add a lex-param or a parse-param (depending on TYPE) with   declaration DECL and location LOC.  */static voidadd_param (char const *type, char *decl, location loc){  static char const alphanum[26 + 26 + 1 + 10] =    "abcdefghijklmnopqrstuvwxyz"    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"    "_"    "0123456789";  char const *name_start = NULL;  char *p;  /* Stop on last actual character.  */  for (p = decl; p[1]; p++)    if ((p == decl	 || ! memchr (alphanum, p[-1], sizeof alphanum))	&& memchr (alphanum, p[0], sizeof alphanum - 10))      name_start = p;  /* Strip the surrounding '{' and '}', and any blanks just inside     the braces.  */  while (*--p == ' ' || *p == '\t')    continue;  p[1] = '\0';  while (*++decl == ' ' || *decl == '\t')    continue;  if (! name_start)    complain_at (loc, _("missing identifier in parameter declaration"));  else    {      char *name;      size_t name_len;      for (name_len = 1;	   memchr (alphanum, name_start[name_len], sizeof alphanum);	   name_len++)	continue;      name = xmalloc (name_len + 1);      memcpy (name, name_start, name_len);      name[name_len] = '\0';      muscle_pair_list_grow (type, decl, name);      free (name);    }  scanner_last_string_free ();}static voidgram_error (location const *loc, char const *msg){  complain_at (*loc, "%s", msg);}char const *token_name (int type){  return yytname[YYTRANSLATE (type)];}

⌨️ 快捷键说明

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