## ------------------------ ##
+# b4_user_formals
+# ---------------
+# The possible parse-params formal arguments preceded by a comma.
+#
+# This is not shared with yacc.c in c.m4 because GLR relies on ISO C
+# formal argument declarations.
+m4_define([b4_user_formals],
+[m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])])
+
+
# b4_lex_param
# ------------
# Accumule in b4_lex_param all the yylex arguments.
m4_ifdef([b4_lex_param], [, ]b4_lex_param)))
-# b4_user_formals
-# ---------------
-m4_define([b4_user_formals],
-[m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])])
-
-
# b4_yyerror_args
# ---------------
-# Arguments passed to yyerror: user args plus yylloc.
+# Optional effective arguments passed to yyerror: user args plus yylloc, and
+# a trailing comma.
m4_define([b4_yyerror_args],
[b4_pure_if([b4_location_if([yylocp, ])])dnl
m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
# b4_pure_args
# ------------
-# Arguments needed by yyerror: user args plus yylloc.
+# Same as b4_yyerror_args, but with a leading comma.
m4_define([b4_pure_args],
[b4_pure_if([b4_location_if([, yylocp])])[]b4_user_args])
-# b4_pure_formals
-# ---------------
-# Arguments passed to yyerror: user formals plus yyllocp.
-m4_define([b4_pure_formals],
-[b4_pure_if([b4_location_if([, YYLTYPE *yylocp])])[]b4_user_formals])
-
-
# b4_lpure_args
# -------------
# Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
[b4_pure_if([b4_location_if([, yyllocp])])[]b4_user_args])
+# b4_pure_formals
+# ---------------
+# Arguments passed to yyerror: user formals plus yyllocp.
+m4_define([b4_pure_formals],
+[b4_pure_if([b4_location_if([, YYLTYPE *yylocp])])[]b4_user_formals])
+
+
# b4_lpure_formals
# ----------------
# Same as above, but on the look-ahead, hence yyllocp instead of yylocp.
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
m4_define([b4_rhs_value],
-[(((yyGLRStackItem const *)yyvsp)@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))])
+[(((yyGLRStackItem const *)yyvsp)@{YYFILL ($2 - $1)@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))])
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
# on RHS.
m4_define([b4_rhs_location],
-[(((yyGLRStackItem const *)yyvsp)@{YYFILL (m4_eval([$2 - $1]))@}.yystate.yyloc)])
+[(((yyGLRStackItem const *)yyvsp)@{YYFILL ($2 - $1)@}.yystate.yyloc)])
+
+
+
+## -------------- ##
+## Output files. ##
+## -------------- ##
# We do want M4 expansion after # for CPP macros.
m4_changecom()
/* This is the parser code for GLR (Generalized LR) parser. */
]b4_identification
+
m4_if(b4_prefix[], [yy], [],
[/* Substitute the variable and function names. */
#define yyparse b4_prefix[]parse
#define yychar b4_prefix[]char
#define yydebug b4_prefix[]debug
#define yynerrs b4_prefix[]nerrs
-#define yylloc b4_prefix[]lloc])
+#define yylloc b4_prefix[]lloc])
-b4_token_defines(b4_tokens)
+dnl # b4_shared_declarations
+dnl # ----------------------
+dnl # Declaration that might either go into the header (if --defines)
+dnl # or open coded in the parser body.
+m4_define([b4_shared_declarations],
+[b4_token_enums(b4_tokens)[
/* Copy the first part of user declarations. */
-b4_pre_prologue[
-
-/* Enabling traces. */
-#ifndef YYDEBUG
-# define YYDEBUG ]b4_debug[
-#endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE ]b4_error_verbose[
-#endif
-
-/* Enabling the token table. */
-#ifndef YYTOKEN_TABLE
-# define YYTOKEN_TABLE ]b4_token_table[
-#endif
+]b4_pre_prologue[
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
]m4_ifdef([b4_stype],
-[b4_syncline([b4_stype_line], [b4_filename])
+[b4_syncline([b4_stype_line], [b4_file_name])
typedef union m4_bregexp(b4_stype, [^{], [YYSTYPE ])b4_stype YYSTYPE;
/* Line __line__ of glr.c. */
b4_syncline([@oline@], [@ofile@])],
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
+]])
+
+m4_if(b4_defines_flag, 0,
+ [b4_shared_declarations],
+ [#include @output_header_name@])[
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG ]b4_debug[
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE ]b4_error_verbose[
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE ]b4_token_table[
+#endif
/* Default (constant) value used for initialization for null
right-hand sides. Unlike the standard yacc.c template,
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
-#include <setjmp.h>
#ifndef YY_
# if YYENABLE_NLS
# endif
#endif
+/* Suppress unused-variable warnings by "using" E. */
+#define YYUSE(e) do {;} while (/*CONSTCOND*/ yyfalse && (e))
+
#ifndef YYFREE
# define YYFREE free
#endif
#define yytrue 1
#define yyfalse 0
+#ifndef YYSETJMP
+# include <setjmp.h>
+# define YYJMP_BUF jmp_buf
+# define YYSETJMP(env) setjmp (env)
+# define YYLONGJMP(env, val) longjmp (env, val)
+#endif
+
/*-----------------.
| GCC extensions. |
`-----------------*/
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
- while (0)
+ while (/*CONSTCOND*/ 0)
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
#define YYCHK(YYE) \
do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
- while (0)
+ while (/*CONSTCOND*/ 0)
#if YYDEBUG
do { \
if (yydebug) \
YYFPRINTF Args; \
-} while (0)
+} while (/*CONSTCOND*/ 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)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yysymprint (stderr, \
+ Type, Value]b4_location_if([, Location])[]b4_user_args[); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (/*CONSTCOND*/ 0)
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
# endif
#endif
+#if YYSTACKEXPANDABLE
+# define YY_RESERVE_GLRSTACK(Yystack) \
+ do { \
+ if (Yystack->yyspaceLeft < YYHEADROOM) \
+ yyexpandGLRStack (Yystack); \
+ } while (/*CONSTCOND*/ 0)
+#else
+# define YY_RESERVE_GLRSTACK(Yystack) \
+ do { \
+ if (Yystack->yyspaceLeft < YYHEADROOM) \
+ yyMemoryExhausted (Yystack); \
+ } while (/*CONSTCOND*/ 0)
+#endif
+
+
#if YYERROR_VERBOSE
# ifndef yystpcpy
int yyrawchar;
])[
yySymbol* yytokenp;
- jmp_buf yyexception_buffer;
+ YYJMP_BUF yyexception_buffer;
yyGLRStackItem* yyitems;
yyGLRStackItem* yynextFree;
size_t yyspaceLeft;
{
if (yymsg != NULL)
yyerror (]b4_yyerror_args[yymsg);
- longjmp (yystack->yyexception_buffer, 1);
+ YYLONGJMP (yystack->yyexception_buffer, 1);
}
static void yyMemoryExhausted (yyGLRStack* yystack)
static void
yyMemoryExhausted (yyGLRStack* yystack)
{
- longjmp (yystack->yyexception_buffer, 2);
+ YYLONGJMP (yystack->yyexception_buffer, 2);
}
#if YYDEBUG || YYERROR_VERBOSE
/** 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. */
+ * containing the pointer to the next state in the chain. */
static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__));
static void
yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
}
/* 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. */
+ * 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 int
static void
yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
{
- /* `Use' the arguments. */
- (void) yy0;
- (void) yy1;
+ YYUSE (yy0);
+ YYUSE (yy1);
switch (yyn)
{
]b4_yydestruct_generate([b4_c_ansi_function_def])[
-/** Number of symbols composing the right hand side of rule #RULE. */
+/** Number of symbols composing the right hand side of rule #RULE. */
static inline int
yyrhsLength (yyRuleNum yyrule)
{
return yyr2[yyrule];
}
+static void
+yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
+{
+ if (yys->yyresolved)
+ yydestruct (yymsg, yystos[yys->yylrState],
+ &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[]b4_user_args[);
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ {
+ YYFPRINTF (stderr, "%s unresolved ", yymsg);
+ yysymprint (stderr, yystos[yys->yylrState],
+ &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[]b4_user_args[);
+ 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]b4_user_args[);
+ }
+ }
+}
+
/** Left-hand-side symbol for rule #RULE. */
static inline yySymbol
yylhsNonterm (yyRuleNum yyrule)
}
#define yyis_pact_ninf(yystate) \
- ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), 1,
- 0,
- ((yystate) == YYPACT_NINF))[
+ ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), [1],
+ [0],
+ [((yystate) == YYPACT_NINF)])[
/** True iff LR state STATE has only a default reduction (regardless
* of token). */
}
#define yyis_table_ninf(yytable_value) \
- ]m4_if(m4_eval(b4_table_ninf < b4_table_min), 1,
- 0,
- ((yytable_value) == YYTABLE_NINF))[
+ ]m4_if(m4_eval(b4_table_ninf < b4_table_min), [1],
+ [0],
+ [((yytable_value) == YYTABLE_NINF)])[
/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
* Result R means
/* GLRStates */
+/** Return a fresh GLRStackItem. Callers should call
+ * YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
+ * headroom. */
+
+static inline yyGLRStackItem*
+yynewGLRStackItem (yyGLRStack* yystack, yybool yyisState)
+{
+ yyGLRStackItem* yynewItem = yystack->yynextFree;
+ yystack->yyspaceLeft -= 1;
+ yystack->yynextFree += 1;
+ yynewItem->yystate.yyisState = yyisState;
+ return yynewItem;
+}
+
static void
yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate,
yyGLRState* rhs, yyRuleNum yyrule)
{
- yySemanticOption* yynewItem;
- yynewItem = &yystack->yynextFree->yyoption;
- yystack->yyspaceLeft -= 1;
- yystack->yynextFree += 1;
- yynewItem->yyisState = yyfalse;
- yynewItem->yystate = rhs;
- yynewItem->yyrule = yyrule;
- yynewItem->yynext = yystate->yysemantics.yyfirstVal;
- yystate->yysemantics.yyfirstVal = yynewItem;
- if (yystack->yyspaceLeft < YYHEADROOM)
- yyexpandGLRStack (yystack);
+ yySemanticOption* yynewOption =
+ &yynewGLRStackItem (yystack, yyfalse)->yyoption;
+ yynewOption->yystate = rhs;
+ yynewOption->yyrule = yyrule;
+ yynewOption->yynext = yystate->yysemantics.yyfirstVal;
+ yystate->yysemantics.yyfirstVal = yynewOption;
+
+ YY_RESERVE_GLRSTACK (yystack);
}
/* GLRStacks */
return yyinitStateSet (&yystack->yytops);
}
-#define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
+
+#if YYSTACKEXPANDABLE
+# define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
&((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
/** If STACK is expandable, extend it. WARNING: Pointers into the
static void
yyexpandGLRStack (yyGLRStack* yystack)
{
-#if YYSTACKEXPANDABLE
yyGLRStackItem* yynewItems;
yyGLRStackItem* yyp0, *yyp1;
size_t yysize, yynewSize;
yystack->yyitems = yynewItems;
yystack->yynextFree = yynewItems + yysize;
yystack->yyspaceLeft = yynewSize - yysize;
-
-#else
- yyMemoryExhausted (yystack);
-#endif
}
+#endif
static void
yyfreeGLRStack (yyGLRStack* yystack)
size_t yyposn,
YYSTYPE yysval, YYLTYPE* yylocp)
{
- yyGLRStackItem* yynewItem;
+ yyGLRState* yynewState = &yynewGLRStackItem (yystack, yytrue)->yystate;
- yynewItem = yystack->yynextFree;
- yystack->yynextFree += 1;
- yystack->yyspaceLeft -= 1;
- yynewItem->yystate.yyisState = yytrue;
- yynewItem->yystate.yylrState = yylrState;
- yynewItem->yystate.yyposn = yyposn;
- yynewItem->yystate.yyresolved = yytrue;
- yynewItem->yystate.yypred = yystack->yytops.yystates[yyk];
- yystack->yytops.yystates[yyk] = &yynewItem->yystate;
- yynewItem->yystate.yysemantics.yysval = yysval;
- yynewItem->yystate.yyloc = *yylocp;
- if (yystack->yyspaceLeft < YYHEADROOM)
- yyexpandGLRStack (yystack);
+ yynewState->yylrState = yylrState;
+ yynewState->yyposn = yyposn;
+ yynewState->yyresolved = yytrue;
+ yynewState->yypred = yystack->yytops.yystates[yyk];
+ yynewState->yysemantics.yysval = yysval;
+ yynewState->yyloc = *yylocp;
+ yystack->yytops.yystates[yyk] = yynewState;
+
+ YY_RESERVE_GLRSTACK (yystack);
}
/** Shift stack #K of YYSTACK, to a new state corresponding to LR
yyglrShiftDefer (yyGLRStack* yystack, size_t yyk, yyStateNum yylrState,
size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
{
- yyGLRStackItem* yynewItem;
+ yyGLRState* yynewState = &yynewGLRStackItem (yystack, yytrue)->yystate;
- yynewItem = yystack->yynextFree;
- yynewItem->yystate.yyisState = yytrue;
- yynewItem->yystate.yylrState = yylrState;
- yynewItem->yystate.yyposn = yyposn;
- yynewItem->yystate.yyresolved = yyfalse;
- yynewItem->yystate.yypred = yystack->yytops.yystates[yyk];
- yynewItem->yystate.yysemantics.yyfirstVal = NULL;
- yystack->yytops.yystates[yyk] = &yynewItem->yystate;
- yystack->yynextFree += 1;
- yystack->yyspaceLeft -= 1;
- yyaddDeferredAction (yystack, &yynewItem->yystate, rhs, yyrule);
+ yynewState->yylrState = yylrState;
+ yynewState->yyposn = yyposn;
+ yynewState->yyresolved = yyfalse;
+ yynewState->yypred = yystack->yytops.yystates[yyk];
+ yynewState->yysemantics.yyfirstVal = NULL;
+ yystack->yytops.yystates[yyk] = yynewState;
+
+ /* Invokes YY_RESERVE_GLRSTACK. */
+ yyaddDeferredAction (yystack, yynewState, rhs, yyrule);
}
/** Pop the symbols consumed by reduction #RULE from the top of stack
}
else
{
+ /* At present, doAction is never called in nondeterministic
+ * mode, so this branch is never taken. It is here in
+ * anticipation of a future feature that will allow immediate
+ * evaluation of selected actions in nondeterministic mode. */
int yyi;
yyGLRState* yys;
yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
- = yystack->yytops.yystates[yyk];
+ = yystack->yytops.yystates[yyk];]b4_location_if([[
+ if (yynrhs == 0)
+ /* Set default location. */
+ yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[
for (yyi = 0; yyi < yynrhs; yyi += 1)
{
yys = yys->yypred;
}
#if !YYDEBUG
-# define YY_REDUCE_PRINT(K, Rule)
+# define YY_REDUCE_PRINT(Args)
#else
-# define YY_REDUCE_PRINT(K, Rule) \
+# define YY_REDUCE_PRINT(Args) \
do { \
if (yydebug) \
- yy_reduce_print (K, Rule); \
-} while (0)
+ yy_reduce_print Args; \
+} while (/*CONSTCOND*/ 0)
/*----------------------------------------------------------.
| Report that the RULE is going to be reduced on stack #K. |
`----------------------------------------------------------*/
static inline void
-yy_reduce_print (size_t yyk, yyRuleNum yyrule)
+yy_reduce_print (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
+ YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
{
+ int yynrhs = yyrhsLength (yyrule);
+ yybool yynormal __attribute__ ((__unused__)) =
+ (yystack->yysplitPoint == NULL);
+ yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystack->yytops.yystates[yyk];
+ int yylow = 1;
int yyi;
- YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu), ",
+ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
(unsigned long int) yyk, yyrule - 1,
(unsigned long int) yyrline[yyrule]);
/* Print the symbols being reduced, and their result. */
- for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
- YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi]));
- YYFPRINTF (stderr, "-> %s\n", yytokenName (yyr1[yyrule]));
+ //for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ fprintf (stderr, " $%d = ", yyi);
+ yysymprint (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &]b4_rhs_value(yynrhs, yyi)[
+ ]b4_location_if([, &]b4_rhs_location(yynrhs, yyi))[]dnl
+ b4_user_args[);
+ fprintf (stderr, "\n");
+ }
}
#endif
YYSTYPE yysval;
YYLTYPE yyloc;
- YY_REDUCE_PRINT (yyk, yyrule);
+ YY_REDUCE_PRINT ((yystack, yyk, yyrule, &yysval, &yyloc]b4_user_args[));
YYCHK (yydoAction (yystack, yyk, yyrule, &yysval, &yyloc]b4_user_args[));
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
yyglrShift (yystack, yyk,
yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState,
yylhsNonterm (yyrule)),
yynrhs = yyrhsLength (yyopt->yyrule);
YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack]b4_user_args[));
- yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;
+ yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_location_if([[
+ if (yynrhs == 0)
+ /* Set default location. */
+ yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[
return yyuserAction (yyopt->yyrule, yynrhs,
yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
yyvalp, yylocp, yystack]b4_user_args[);
yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,
yyGLRStack* yystack]b4_pure_formals[)
{
- /* `Unused' warnings. */
- (void) yyx0;
- (void) yyx1;
+ YYUSE (yyx0);
+ YYUSE (yyx1);
#if YYDEBUG
YYFPRINTF (stderr, "Ambiguity detected.\n");
yybest = yyp;
yymerge = yyfalse;
break;
+ default:
+ /* This cannot happen so it is not worth a YYASSERT (yyfalse),
+ but some compilers complain if the default case is
+ omitted. */
+ break;
}
yypp = &yyp->yynext;
}
yyreportSyntaxError (yyGLRStack* yystack,
YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[)
{
- /* `Unused' warnings. */
- (void) yylvalp;
- (void) yyllocp;
+ YYUSE (yylvalp);
+ YYUSE (yyllocp);
if (yystack->yyerrState == 0)
{
yyerror_range[2].yystate.yyloc = *yyllocp;
YYLLOC_DEFAULT (yys->yyloc, yyerror_range, 2);]])[
yydestruct ("Error: discarding",
- *yytokenp, yylvalp]b4_location_if([, yyllocp])[);
+ *yytokenp, yylvalp]b4_location_if([, yyllocp])[]b4_user_args[);
}
YYDPRINTF ((stderr, "Reading a token: "));
yychar = YYLEX;
}
}
]b4_location_if([[ yystack->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
- yydestruct ("Error: popping",
- yystos[yys->yylrState],
- &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
+ yydestroyGLRState ("Error: popping", yys]b4_user_args[);
yystack->yytops.yystates[0] = yys->yypred;
yystack->yynextFree -= 1;
yystack->yyspaceLeft += 1;
#define YYCHK1(YYE) \
do { \
switch (YYE) { \
- default: \
+ case yyok: \
break; \
case yyabort: \
goto yyabortlab; \
goto yyacceptlab; \
case yyerr: \
goto yyuser_error; \
+ default: \
+ goto yybuglab; \
} \
- } while (0)
+ } while (/*CONSTCOND*/ 0)
/*----------.
[
if (! yyinitGLRStack (&yystack, YYINITDEPTH))
goto yyexhaustedlab;
- switch (setjmp (yystack.yyexception_buffer))
+ switch (YYSETJMP (yystack.yyexception_buffer))
{
+ case 0: break;
case 1: goto yyabortlab;
case 2: goto yyexhaustedlab;
+ default: goto yybuglab;
}
yystack.yytokenp = &yytoken;
yyglrShift (&yystack, 0, 0, 0, yylval, &yylloc);
yyresult = 0;
goto yyreturn;
+ yybuglab:
+ YYASSERT (yyfalse);
+ /* Fall through. */
+
yyabortlab:
yyresult = 1;
goto yyreturn;
yyreturn:
if (yytoken != YYEOF && yytoken != YYEMPTY)
- yydestruct ("Error: discarding lookahead",
- yytoken, yylvalp]b4_location_if([, yyllocp])[);
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, yylvalp]b4_location_if([, yyllocp])[]b4_user_args[);
/* If the stack is well-formed, pop the stack until it is empty,
destroying its entries as we go. But free the stack regardless
{
yyGLRState *yys = yystates[0];
]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
-)[ yydestruct ("Error: popping",
- yystos[yys->yylrState],
- &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
+)[ yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[);
yystates[0] = yys->yypred;
yystack.yynextFree -= 1;
yystack.yyspaceLeft += 1;
m4_if(b4_defines_flag, 0, [],
[@output @output_header_name@
b4_copyright([Skeleton parser for GLR parsing with Bison],
- [2002, 2003, 2004, 2005])
-
-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 glr.c. */
-b4_syncline([@oline@], [@ofile@])],
-[typedef int YYSTYPE;])
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
+ [2002, 2003, 2004, 2005])
-b4_pure_if([],
-[extern YYSTYPE b4_prefix[]lval;])
+b4_shared_declarations
-#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
-typedef struct YYLTYPE
-{
-b4_location_if([
- int first_line;
- int first_column;
- int last_line;
- int last_column;
-],[
- char yydummy;
-])
-} YYLTYPE;
-# define YYLTYPE_IS_DECLARED 1
-# define YYLTYPE_IS_TRIVIAL 1
-#endif
+extern YYSTYPE b4_prefix[]lval;
b4_location_if([b4_pure_if([],
[extern YYLTYPE b4_prefix[]lloc;])