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

📄 glr.c

📁 GNU的词法/语法分析器bison源码
💻 C
📖 第 1 页 / 共 5 页
字号:
    while (0)/* YY_LOCATION_PRINT -- Print the location on the stream.   This macro was not mandated originally: define only if we know   we won't break user code: when these are the locations we know.  */# define YY_LOCATION_PRINT(File, Loc)			\    fprintf (File, "%d.%d-%d.%d",			\             (Loc).first_line, (Loc).first_column,	\             (Loc).last_line,  (Loc).last_column)#endif]],[#ifndef YYLLOC_DEFAULT# define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)#endif])[#ifndef YY_LOCATION_PRINT# define YY_LOCATION_PRINT(File, Loc) ((void) 0)#endif/* YYLEX -- calling `yylex' with the right arguments.  */#define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[]b4_pure_if([#undef yynerrs#define yynerrs (yystack->yyerrcnt)#undef yychar#define yychar (yystack->yyrawchar)],[YYSTYPE yylval;YYLTYPE yylloc;int yynerrs;int yychar;])[static const int YYEOF = 0;static const int YYEMPTY = -2;typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;#define YYCHK(YYE)							     \   do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; }	     \   while (0)#if YYDEBUG#if ! defined (YYFPRINTF)#  define YYFPRINTF fprintf#endif# define YYDPRINTF(Args)			\do {						\  if (yydebug)					\    YYFPRINTF Args;				\} while (0)]b4_yysymprint_generate([b4_c_ansi_function_def])[# define YY_SYMBOL_PRINT(Title, Type, Value, Location)		\do {								\  if (yydebug)							\    {								\      YYFPRINTF (stderr, "%s ", Title);				\      yysymprint (stderr,					\                  Type, Value]b4_location_if([, Location])[);	\      YYFPRINTF (stderr, "\n");					\    }								\} while (0)/* Nonzero means print parse trace.  It is left uninitialized so that   multiple parsers can coexist.  */int yydebug;#else /* !YYDEBUG */# define YYDPRINTF(Args)# define YY_SYMBOL_PRINT(Title, Type, Value, Location)#endif /* !YYDEBUG *//* YYINITDEPTH -- initial size of the parser's stacks.  */#ifndef	YYINITDEPTH# define YYINITDEPTH ]b4_stack_depth_init[#endif/* 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   SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)   evaluated with infinite-precision integer arithmetic.  */#ifndef YYMAXDEPTH# define YYMAXDEPTH ]b4_stack_depth_max[#endif/* Minimum number of free items on the stack allowed after an   allocation.  This is to allow allocation and initialization   to be completed by functions that call yyexpandGLRStack before the   stack is expanded, thus insuring that all necessary pointers get   properly redirected to new data. */#define YYHEADROOM 2#ifndef YYSTACKEXPANDABLE# if (! defined (__cplusplus) \      || (]b4_location_if([[defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \	  && ]])[defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))#  define YYSTACKEXPANDABLE 1# else#  define YYSTACKEXPANDABLE 0# endif#endif#if YYERROR_VERBOSE# 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 *yystpcpy (char *yydest, const char *yysrc){  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 size_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 strlen (yystr);  return yystpcpy (yyres, yystr) - yyres;}# endif#endif /* !YYERROR_VERBOSE *//** State numbers, as in LALR(1) machine */typedef int yyStateNum;/** Rule numbers, as in LALR(1) machine */typedef int yyRuleNum;/** Grammar symbol */typedef short int yySymbol;/** Item references, as in LALR(1) machine */typedef short int yyItemNum;typedef struct yyGLRState yyGLRState;typedef struct yySemanticOption yySemanticOption;typedef union yyGLRStackItem yyGLRStackItem;typedef struct yyGLRStack yyGLRStack;typedef struct yyGLRStateSet yyGLRStateSet;struct yyGLRState {  /** Type tag: always true. */  yybool yyisState;  /** Type tag for yysemantics. If true, yysval applies, otherwise   *  yyfirstVal applies. */  yybool yyresolved;  /** Number of corresponding LALR(1) machine state. */  yyStateNum yylrState;  /** Preceding state in this stack */  yyGLRState* yypred;  /** Source position of the first token produced by my symbol */  size_t yyposn;  union {    /** First in a chain of alternative reductions producing the     *  non-terminal corresponding to this state, threaded through     *  yynext. */    yySemanticOption* yyfirstVal;    /** Semantic value for this state. */    YYSTYPE yysval;  } yysemantics;  /** Source location for this state. */  YYLTYPE yyloc;};struct yyGLRStateSet {  yyGLRState** yystates;  size_t yysize, yycapacity;};struct yySemanticOption {  /** Type tag: always false. */  yybool yyisState;  /** Rule number for this reduction */  yyRuleNum yyrule;  /** The last RHS state in the list of states to be reduced. */  yyGLRState* yystate;  /** Next sibling in chain of options. To facilitate merging,   *  options are chained in decreasing order by address. */  yySemanticOption* yynext;};/** Type of the items in the GLR stack. The yyisState field *  indicates which item of the union is valid. */union yyGLRStackItem {  yyGLRState yystate;  yySemanticOption yyoption;};struct yyGLRStack {  int yyerrState;]b4_location_if([[  /* To compute the location of the error token.  */  yyGLRStackItem yyerror_range[3];]])[]b4_pure_if([  int yyerrcnt;  int yyrawchar;])[  yySymbol* yytokenp;  YYJMP_BUF yyexception_buffer;  yyGLRStackItem* yyitems;  yyGLRStackItem* yynextFree;  size_t yyspaceLeft;  yyGLRState* yysplitPoint;  yyGLRState* yylastDeleted;  yyGLRStateSet yytops;};static void yyexpandGLRStack (yyGLRStack* yystack);static void yyFail (yyGLRStack* yystack]b4_pure_formals[, const char* yymsg)  __attribute__ ((__noreturn__));static voidyyFail (yyGLRStack* yystack]b4_pure_formals[, const char* yymsg){  if (yymsg != NULL)    yyerror (]b4_yyerror_args[yymsg);  YYLONGJMP (yystack->yyexception_buffer, 1);}static void yyMemoryExhausted (yyGLRStack* yystack)  __attribute__ ((__noreturn__));static voidyyMemoryExhausted (yyGLRStack* yystack){  YYLONGJMP (yystack->yyexception_buffer, 2);}#if YYDEBUG || YYERROR_VERBOSE/** A printable representation of TOKEN.  */static inline const char*yytokenName (yySymbol yytoken){  if (yytoken == YYEMPTY)    return "";  return yytname[yytoken];}#endif/** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting *  at YYVSP[YYLOW0].yystate.yypred.  Leaves YYVSP[YYLOW1].yystate.yypred *  containing the pointer to the next state in the chain. Assumes *  YYLOW1 < YYLOW0.  */static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__));static voidyyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1){  yyGLRState* s;  int i;  s = yyvsp[yylow0].yystate.yypred;  for (i = yylow0-1; i >= yylow1; i -= 1)    {      YYASSERT (s->yyresolved);      yyvsp[i].yystate.yyresolved = yytrue;      yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;      yyvsp[i].yystate.yyloc = s->yyloc;      s = yyvsp[i].yystate.yypred = s->yypred;    }}/* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1.  Otherwise, fill in   YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.   For convenience, always return YYLOW1.  */static inline int yyfill (yyGLRStackItem *, int *, int, yybool)     __attribute__ ((__unused__));static inline intyyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal){  if (!yynormal && yylow1 < *yylow)    {      yyfillin (yyvsp, *yylow, yylow1);      *yylow = yylow1;    }  return yylow1;}/** Perform user action for rule number YYN, with RHS length YYRHSLEN, *  and top stack item YYVSP.  YYLVALP points to place to put semantic *  value ($$), and yylocp points to place for location information *  (@@$). Returns yyok for normal return, yyaccept for YYACCEPT, *  yyerr for YYERROR, yyabort for YYABORT. */static YYRESULTTAGyyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,	      YYSTYPE* yyvalp,	      YYLTYPE* YYOPTIONAL_LOC (yylocp),	      yyGLRStack* yystack              ]b4_user_formals[){  yybool yynormal __attribute__ ((__unused__)) =    (yystack->yysplitPoint == NULL);  int yylow;# undef yyerrok# define yyerrok (yystack->yyerrState = 0)# undef YYACCEPT# define YYACCEPT return yyaccept# undef YYABORT# define YYABORT return yyabort# undef YYERROR# define YYERROR return yyerrok, yyerr# undef YYRECOVERING# define YYRECOVERING (yystack->yyerrState != 0)# undef yyclearin# define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)# undef YYFILL# define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)# undef YYBACKUP# define YYBACKUP(Token, Value)						     \  return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")),     \	 yyerrok, yyerr  yylow = 1;  if (yyrhslen == 0)    *yyvalp = yyval_default;  else    *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;  YYLLOC_DEFAULT (*yylocp, yyvsp - yyrhslen, yyrhslen);]b4_location_if([[  yystack->yyerror_range[1].yystate.yyloc = *yylocp;]])  switch (yyn)    {      b4_actions      default: break;    }  return yyok;# undef yyerrok# undef YYABORT# undef YYACCEPT# undef YYERROR# undef YYBACKUP# undef yyclearin# undef YYRECOVERING/* Line __line__ of glr.c.  */b4_syncline([@oline@], [@ofile@])}static voidyyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1){  /* `Use' the arguments.  */  (void) yy0;  (void) yy1;  switch (yyn)    {      b4_mergers      default: break;    }}[			      /* Bison grammar-table manipulation.  */]b4_yydestruct_generate([b4_c_ansi_function_def])[/** Number of symbols composing the right hand side of rule #RULE.  */static inline intyyrhsLength (yyRuleNum yyrule){  return yyr2[yyrule];}static voidyydestroyGLRState (char const *yymsg, yyGLRState *yys){  if (yys->yyresolved)    yydestruct (yymsg, yystos[yys->yylrState],		&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);  else    {#if YYDEBUG      if (yydebug)	{	  YYFPRINTF (stderr, "%s unresolved ", yymsg);	  yysymprint (stderr, yystos[yys->yylrState],		      &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);	  YYFPRINTF (stderr, "\n");	}#endif      if (yys->yysemantics.yyfirstVal)        {          yySemanticOption *yyoption = yys->yysemantics.yyfirstVal;          yyGLRState *yyrh;          int yyn;          for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule);               yyn > 0;               yyrh = yyrh->yypred, yyn -= 1)            yydestroyGLRState (yymsg, yyrh);        }    }}/** Left-hand-side symbol for rule #RULE. */static inline yySymbolyylhsNonterm (yyRuleNum yyrule){  return yyr1[yyrule];}#define yyis_pact_ninf(yystate) \  ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), 1,	 0,	 ((yystate) == YYPACT_NINF))[

⌨️ 快捷键说明

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