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

📄 parse-gram.c

📁 GNU的词法/语法分析器bison源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only   if the built-in stack extension method is used).   Do not make this value too large; the results are undefined if   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)   evaluated with infinite-precision integer arithmetic.  */#ifndef YYMAXDEPTH# define YYMAXDEPTH 10000#endif#if YYERROR_VERBOSE# ifndef yystrlen#  if defined (__GLIBC__) && defined (_STRING_H)#   define yystrlen strlen#  else/* Return the length of YYSTR.  */static YYSIZE_T#   if defined (__STDC__) || defined (__cplusplus)yystrlen (const char *yystr)#   elseyystrlen (yystr)     const char *yystr;#   endif{  const char *yys = yystr;  while (*yys++ != '\0')    continue;  return yys - yystr - 1;}#  endif# endif# ifndef yystpcpy#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)#   define yystpcpy stpcpy#  else/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in   YYDEST.  */static char *#   if defined (__STDC__) || defined (__cplusplus)yystpcpy (char *yydest, const char *yysrc)#   elseyystpcpy (yydest, yysrc)     char *yydest;     const char *yysrc;#   endif{  char *yyd = yydest;  const char *yys = yysrc;  while ((*yyd++ = *yys++) != '\0')    continue;  return yyd - 1;}#  endif# endif# ifndef yytnamerr/* Copy to YYRES the contents of YYSTR after stripping away unnecessary   quotes and backslashes, so that it's suitable for yyerror.  The   heuristic is that double-quoting is unnecessary unless the string   contains an apostrophe, a comma, or backslash (other than   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is   null, do not copy; instead, return the length of what the result   would have been.  */static YYSIZE_Tyytnamerr (char *yyres, const char *yystr){  if (*yystr == '"')    {      size_t yyn = 0;      char const *yyp = yystr;      for (;;)	switch (*++yyp)	  {	  case '\'':	  case ',':	    goto do_not_strip_quotes;	  case '\\':	    if (*++yyp != '\\')	      goto do_not_strip_quotes;	    /* Fall through.  */	  default:	    if (yyres)	      yyres[yyn] = *yyp;	    yyn++;	    break;	  case '"':	    if (yyres)	      yyres[yyn] = '\0';	    return yyn;	  }    do_not_strip_quotes: ;    }  if (! yyres)    return yystrlen (yystr);  return yystpcpy (yyres, yystr) - yyres;}# endif#endif /* YYERROR_VERBOSE */#if YYDEBUG/*--------------------------------.| Print this symbol on YYOUTPUT.  |`--------------------------------*/#if defined (__STDC__) || defined (__cplusplus)static voidyysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)#elsestatic voidyysymprint (yyoutput, yytype, yyvaluep, yylocationp)    FILE *yyoutput;    int yytype;    YYSTYPE *yyvaluep;    YYLTYPE *yylocationp;#endif{  /* Pacify ``unused variable'' warnings.  */  (void) yyvaluep;  (void) yylocationp;  if (yytype < YYNTOKENS)    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);  else    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);  YY_LOCATION_PRINT (yyoutput, *yylocationp);  YYFPRINTF (yyoutput, ": ");# ifdef YYPRINT  if (yytype < YYNTOKENS)    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);# endif  switch (yytype)    {      case 3: /* "\"string\"" */#line 165 "parse-gram.y"        { fprintf (stderr, "\"%s\"", (yyvaluep->chars)); };#line 1070 "parse-gram.c"        break;      case 4: /* "\"integer\"" */#line 178 "parse-gram.y"        { fprintf (stderr, "%d", (yyvaluep->integer)); };#line 1075 "parse-gram.c"        break;      case 8: /* "\"%destructor {...}\"" */#line 167 "parse-gram.y"        { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };#line 1080 "parse-gram.c"        break;      case 9: /* "\"%printer {...}\"" */#line 171 "parse-gram.y"        { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };#line 1085 "parse-gram.c"        break;      case 10: /* "\"%union {...}\"" */#line 172 "parse-gram.y"        { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };#line 1090 "parse-gram.c"        break;      case 26: /* "\"%initial-action {...}\"" */#line 168 "parse-gram.y"        { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };#line 1095 "parse-gram.c"        break;      case 27: /* "\"%lex-param {...}\"" */#line 169 "parse-gram.y"        { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };#line 1100 "parse-gram.c"        break;      case 34: /* "\"%parse-param {...}\"" */#line 170 "parse-gram.y"        { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };#line 1105 "parse-gram.c"        break;      case 41: /* "\"type\"" */#line 176 "parse-gram.y"        { fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); };#line 1110 "parse-gram.c"        break;      case 45: /* "\"identifier\"" */#line 180 "parse-gram.y"        { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); };#line 1115 "parse-gram.c"        break;      case 46: /* "\"identifier:\"" */#line 182 "parse-gram.y"        { fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); };#line 1120 "parse-gram.c"        break;      case 48: /* "\"%{...%}\"" */#line 174 "parse-gram.y"        { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };#line 1125 "parse-gram.c"        break;      case 49: /* "\"epilogue\"" */#line 174 "parse-gram.y"        { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };#line 1130 "parse-gram.c"        break;      case 50: /* "\"{...}\"" */#line 173 "parse-gram.y"        { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };#line 1135 "parse-gram.c"        break;      case 71: /* "symbol" */#line 180 "parse-gram.y"        { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); };#line 1140 "parse-gram.c"        break;      case 72: /* "action" */#line 173 "parse-gram.y"        { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };#line 1145 "parse-gram.c"        break;      case 73: /* "string_as_id" */#line 180 "parse-gram.y"        { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); };#line 1150 "parse-gram.c"        break;      case 74: /* "string_content" */#line 165 "parse-gram.y"        { fprintf (stderr, "\"%s\"", (yyvaluep->chars)); };#line 1155 "parse-gram.c"        break;      default:        break;    }  YYFPRINTF (yyoutput, ")");}#endif /* ! YYDEBUG *//*-----------------------------------------------.| Release the memory associated to this symbol.  |`-----------------------------------------------*/#if defined (__STDC__) || defined (__cplusplus)static voidyydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)#elsestatic voidyydestruct (yymsg, yytype, yyvaluep, yylocationp)    const char *yymsg;    int yytype;    YYSTYPE *yyvaluep;    YYLTYPE *yylocationp;#endif{  /* Pacify ``unused variable'' warnings.  */  (void) yyvaluep;  (void) yylocationp;  if (!yymsg)    yymsg = "Deleting";  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);  switch (yytype)    {      default:        break;    }}/* Prevent warnings from -Wmissing-prototypes.  */#ifdef YYPARSE_PARAM# if defined (__STDC__) || defined (__cplusplus)int yyparse (void *YYPARSE_PARAM);# elseint yyparse ();# endif#else /* ! YYPARSE_PARAM */#if defined (__STDC__) || defined (__cplusplus)int yyparse (void);#elseint yyparse ();#endif#endif /* ! YYPARSE_PARAM *//*----------.| yyparse.  |`----------*/#ifdef YYPARSE_PARAM# if defined (__STDC__) || defined (__cplusplus)int yyparse (void *YYPARSE_PARAM)# elseint yyparse (YYPARSE_PARAM)  void *YYPARSE_PARAM;# endif#else /* ! YYPARSE_PARAM */#if defined (__STDC__) || defined (__cplusplus)intyyparse (void)#elseintyyparse ()    ;#endif#endif{  /* The look-ahead symbol.  */int yychar;/* The semantic value of the look-ahead symbol.  */YYSTYPE yylval;/* Number of syntax errors so far.  */int yynerrs;/* Location data for the look-ahead symbol.  */YYLTYPE yylloc;  int yystate;  int yyn;  int yyresult;  /* Number of tokens to shift before error messages enabled.  */  int yyerrstatus;  /* Look-ahead token as an internal (translated) token number.  */  int yytoken = 0;  /* Three stacks and their tools:     `yyss': related to states,     `yyvs': related to semantic values,     `yyls': related to locations.     Refer to the stacks thru separate pointers, to allow yyoverflow     to reallocate them elsewhere.  */  /* The state stack.  */  short int yyssa[YYINITDEPTH];  short int *yyss = yyssa;  short int *yyssp;  /* The semantic value stack.  */  YYSTYPE yyvsa[YYINITDEPTH];  YYSTYPE *yyvs = yyvsa;  YYSTYPE *yyvsp;  /* The location stack.  */  YYLTYPE yylsa[YYINITDEPTH];  YYLTYPE *yyls = yylsa;  YYLTYPE *yylsp;  /* The locations where the error started and ended. */  YYLTYPE yyerror_range[2];#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)  YYSIZE_T yystacksize = YYINITDEPTH;  /* The variables used to return semantic value and location from the     action routines.  */  YYSTYPE yyval;  YYLTYPE yyloc;  /* When reducing, the number of symbols on the RHS of the reduced     rule.  */  int yylen;  YYDPRINTF ((stderr, "Starting parse\n"));  yystate = 0;  yyerrstatus = 0;  yynerrs = 0;  yychar = YYEMPTY;		/* Cause a token to be read.  */  /* Initialize stack pointers.     Waste one element of value and location stack     so that they stay on the same level as the state stack.     The wasted elements are never initialized.  */  yyssp = yyss;  yyvsp = yyvs;  yylsp = yyls;#if YYLTYPE_IS_TRIVIAL  /* Initialize the default location before parsing starts.  */  yylloc.first_line   = yylloc.last_line   = 1;  yylloc.first_column = yylloc.last_column = 0;#endif  /* User initialization code. */#line 69 "parse-gram.y"{  /* Bison's grammar can initial empty locations, hence a default     location is needed. */  yylloc.start.file   = yylloc.end.file   = current_file;  yylloc.start.line   = yylloc.end.line   = 1;  yylloc.start.column = yylloc.end.column = 0;}/* Line 930 of yacc.c.  */#line 1329 "parse-gram.c"  yylsp[0] = yylloc;  goto yysetstate;/*------------------------------------------------------------.| yynewstate -- Push a new state, which is found in yystate.  |`------------------------------------------------------------*/ yynewstate:  /* In all cases, when you get here, the value and location stacks     have just been pushed. so pushing a state here evens the stacks.     */  yyssp++; yysetstate:  *yyssp = yystate;  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;	short int *yyss1 = yyss;	YYLTYPE *yyls1 = yyls;	/* 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),		    &yyls1, yysize * sizeof (*yylsp),		    &yystacksize);	yyls = yyls1;	yyss = yyss1;	yyvs = yyvs1;      }#else /* no yyoverflow */

⌨️ 快捷键说明

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