#define yynerrs b4_prefix[]nerrs
#define yylloc b4_prefix[]lloc])
-b4_token_defines(b4_tokens)
+b4_token_enums(b4_tokens)
/* Copy the first part of user declarations. */
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@])],
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
-#include <setjmp.h>
#ifndef YY_
# if YYENABLE_NLS
#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. |
`-----------------*/
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
-# if !defined (__GNUC__) || __GNUC__ < 2 || \
-(__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+# if (!defined (__GNUC__) || __GNUC__ < 2 \
+ || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
# define __attribute__(Spec) /* empty */
-# else
-]b4_location_if([# define YYOPTIONAL_LOC(Name) Name],[
-# if defined (__cplusplus)
-# define YYOPTIONAL_LOC(Name) /* empty */
-# else
-# define YYOPTIONAL_LOC(Name) Name __attribute__ ((__unused__))
-# endif])[
# endif
#endif
+]b4_location_if([#define YYOPTIONAL_LOC(Name) Name],[
+#ifdef __cplusplus
+# define YYOPTIONAL_LOC(Name) /* empty */
+#else
+# define YYOPTIONAL_LOC(Name) Name __attribute__ ((__unused__))
+#endif])[
+
#ifndef YYASSERT
# define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
#endif
YYFPRINTF (stderr, "%s ", Title); \
yysymprint (stderr, \
Type, Value]b4_location_if([, Location])[); \
+ YYFPRINTF (stderr, "\n"); \
} \
} while (0)
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
]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)
+{
+ 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 yySymbol
yylhsNonterm (yyRuleNum yyrule)
YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
{
yySemanticOption* yybest;
- yySemanticOption* yyp;
+ yySemanticOption** yypp;
yybool yymerge;
yybest = yyoptionList;
yymerge = yyfalse;
- for (yyp = yyoptionList->yynext; yyp != NULL; yyp = yyp->yynext)
+ for (yypp = &yyoptionList->yynext; *yypp != NULL; )
{
+ yySemanticOption* yyp = *yypp;
+
if (yyidenticalOptions (yybest, yyp))
- yymergeOptionSets (yybest, yyp);
+ {
+ yymergeOptionSets (yybest, yyp);
+ *yypp = yyp->yynext;
+ }
else
- switch (yypreference (yybest, yyp))
- {
- case 0:
- yyreportAmbiguity (yybest, yyp, yystack]b4_pure_args[);
- break;
- case 1:
- yymerge = yytrue;
- break;
- case 2:
- break;
- case 3:
- yybest = yyp;
- yymerge = yyfalse;
- break;
- }
+ {
+ switch (yypreference (yybest, yyp))
+ {
+ case 0:
+ yyreportAmbiguity (yybest, yyp, yystack]b4_pure_args[);
+ break;
+ case 1:
+ yymerge = yytrue;
+ break;
+ case 2:
+ break;
+ case 3:
+ 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;
+ }
}
if (yymerge)
{
+ yySemanticOption* yyp;
int yyprec = yydprec[yybest->yyrule];
YYCHK (yyresolveAction (yybest, yystack, yyvalp, yylocp]b4_user_args[));
for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext)
yychar = YYLEX;
*yytokenp = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp);
- YYDPRINTF ((stderr, "\n"));
}
yygetLRActions (yystate, *yytokenp, &yyaction, &yyconflicts);
YY_SYMBOL_PRINT ("shifting", *yytokenp, yylvalp, yyllocp);
yyglrShift (yystack, yyk, yyaction, yyposn+1,
*yylvalp, yyllocp);
- YYDPRINTF ((stderr, ", now in state #%d\n",
+ YYDPRINTF ((stderr, "Stack %lu now in state #%d\n",
+ (unsigned long int) yyk,
yystack->yytops.yystates[yyk]->yylrState));
break;
}
yychar = YYLEX;
*yytokenp = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp);
- YYDPRINTF ((stderr, "\n"));
yyj = yypact[yystack->yytops.yystates[0]->yylrState];
if (yyis_pact_ninf (yyj))
return;
YYLLOC_DEFAULT (yyerrloc, yystack->yyerror_range, 2);]])[
YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]],
yylvalp, &yyerrloc);
- YYDPRINTF ((stderr, "\n"));
yyglrShift (yystack, 0, yytable[yyj],
yys->yyposn, *yylvalp, &yyerrloc);
yys = yystack->yytops.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 ("Error: popping", yys);
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)
[
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);
yychar = YYLEX;
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, yylvalp, yyllocp);
- YYDPRINTF ((stderr, "\n"));
}
yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
if (*yyconflicts != 0)
if (yyisShiftAction (yyaction))
{
YY_SYMBOL_PRINT ("Shifting", yytoken, yylvalp, yyllocp);
- YYDPRINTF ((stderr, "\n"));
if (yytoken != YYEOF)
yytoken = YYEMPTY;
yyposn += 1;
yyresult = 0;
goto yyreturn;
+ yybuglab:
+ YYASSERT (yyfalse);
+ /* Fall through. */
+
yyabortlab:
yyresult = 1;
goto yyreturn;
yyreturn:
if (yytoken != YYEOF && yytoken != YYEMPTY)
- yydestruct ("Error: discarding lookahead",
+ yydestruct ("Cleanup: discarding lookahead",
yytoken, yylvalp]b4_location_if([, yyllocp])[);
/* If the stack is well-formed, pop the stack until it is empty,
{
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);
yystates[0] = yys->yypred;
yystack.yynextFree -= 1;
yystack.yyspaceLeft += 1;
b4_copyright([Skeleton parser for GLR parsing with Bison],
[2002, 2003, 2004, 2005])
-b4_token_defines(b4_tokens)
+b4_token_enums(b4_tokens)
#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@])],