X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/720623af846838b895298fed24f6d5d4cb666742..41cce2f604996c7713d9025f8a719ea56d83783e:/data/glr.c diff --git a/data/glr.c b/data/glr.c index bcd4e615..eb495448 100644 --- a/data/glr.c +++ b/data/glr.c @@ -19,6 +19,38 @@ m4_include([c.m4]) # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # 02111-1307 USA + +## ---------------- ## +## Default values. ## +## ---------------- ## + +# Stack parameters. +m4_define_default([b4_stack_depth_max], [10000]) +m4_define_default([b4_stack_depth_init], [200]) + +# Location type. +m4_define_default([b4_location_type], [yyltype]) + +# Accumule in b4_lex_param all the yylex arguments. +# Yes, this is quite ugly... +m4_define([b4_lex_param], +m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[yylvalp]]][]dnl +b4_location_if([, [[YYLTYPE *], [yyllocp]]])])dnl +m4_ifdef([b4_lex_param], [, ]b4_lex_param))) + +# Yes, this is quite ugly... + m4_define_default([b4_parse_param]) +m4_ifdef([b4_parse_param], +[m4_define([b4_parse_param], + b4_parse_param)]) + + + +## ----------------- ## +## Semantic Values. ## +## ----------------- ## + + # b4_lhs_value([TYPE]) # -------------------- # Expansion of $$. @@ -39,15 +71,6 @@ m4_define([b4_rhs_value], ## Locations. ## ## ----------- ## -# b4_location_if(IF-TRUE, IF-FALSE) -# --------------------------------- -# Expand IF-TRUE, if locations are used, IF-FALSE otherwise. -m4_define([b4_location_if], -[m4_if(b4_locations_flag, [1], - [$1], - [$2])]) - - # b4_lhs_location() # ----------------- # Expansion of @$. @@ -64,19 +87,6 @@ m4_define([b4_rhs_location], -## -------------- ## -## %pure-parser. ## -## -------------- ## - -# b4_pure_if(IF-TRUE, IF-FALSE) -# ----------------------------- -# Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise. -m4_define([b4_pure_if], -[m4_if(b4_pure, [1], - [$1], - [$2])]) - - ## ------------------- ## ## Output file names. ## ## ------------------- ## @@ -108,11 +118,12 @@ b4_copyright([Skeleton parser for GLR parsing with Bison], [2002]) /* This is the parser code for GLR (Generalized LR) parser. */ /* FIXME: minimize these */ -#include +#include #include -#include #include -#include +#include +#include +#include /* Identify Bison output. */ #define YYBISON 1 @@ -135,10 +146,10 @@ b4_copyright([Skeleton parser for GLR parsing with Bison], [2002]) #define yynerrs b4_prefix[]nerrs b4_location_if([#define yylloc b4_prefix[]lloc])]) -/* Copy the first part of user declarations. */ -b4_pre_prologue +b4_token_defines(b4_tokens) -b4_token_defines(b4_tokens)[ +/* Copy the first part of user declarations. */ +b4_pre_prologue[ /* Enabling traces. */ #ifndef YYDEBUG @@ -167,13 +178,12 @@ typedef union b4_stype yystype; #ifndef YYLTYPE typedef struct yyltype { -]b4_location_if([ - int yyfirst_line; - int yyfirst_column; - int yylast_line; - int yylast_column;])[ + int first_line; + int first_column; + int last_line; + int last_column; } yyltype; -# define YYLTYPE ]b4_ltype[ +# define YYLTYPE ]b4_location_type[ # define YYLTYPE_IS_TRIVIAL 1 #endif @@ -197,23 +207,45 @@ static YYLTYPE yyloc_default; # define yyfalse 0 #endif -#if ! defined (yy__GNUC__) -# define inline +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#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__ +# define __attribute__(Spec) /* empty */ +# endif +#endif + +#ifndef ATTRIBUTE_UNUSED +# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif + +#if ! defined (__GNUC__) +# define inline #endif /* YYFINAL -- State number of the termination state. */ -#define YYFINAL ]b4_final[ -#define YYFLAG ]b4_flag[ +#define YYFINAL ]b4_final_state_number[ +/* YYLAST -- Last index in YYTABLE. */ #define YYLAST ]b4_last[ /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS ]b4_ntokens[ +#define YYNTOKENS ]b4_tokens_number[ /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS ]b4_nnts[ +#define YYNNTS ]b4_nterms_number[ /* YYNRULES -- Number of rules. */ -#define YYNRULES ]b4_nrules[ +#define YYNRULES ]b4_rules_number[ /* YYNRULES -- Number of states. */ -#define YYNSTATES ]b4_nstates[ +#define YYNSTATES ]b4_states_number[ /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */ #define YYMAXRHS ]b4_r2_max[ @@ -225,7 +257,7 @@ static YYLTYPE yyloc_default; ((unsigned)(YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const ]b4_uint_type(b4_translate_max)[ yytranslate[] = +static const ]b4_int_type_for([b4_translate])[ yytranslate[] = { ]b4_translate[ }; @@ -233,19 +265,19 @@ static const ]b4_uint_type(b4_translate_max)[ yytranslate[] = #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ -static const ]b4_uint_type(b4_prhs_max)[ yyprhs[] = +static const ]b4_int_type_for([b4_prhs])[ yyprhs[] = { ]b4_prhs[ }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const ]b4_sint_type(b4_rhs_max)[ yyrhs[] = +static const ]b4_int_type_for([b4_rhs])[ yyrhs[] = { ]b4_rhs[ }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const ]b4_uint_type(b4_rline_max)[ yyrline[] = +static const ]b4_int_type_for([b4_rline])[ yyrline[] = { ]b4_rline[ }; @@ -259,29 +291,29 @@ static const char *const yytname[] = ]b4_tname[ }; -#define yytname_size (sizeof (yytname) / sizeof (yytname[0])) +#define yytname_size ((int) (sizeof (yytname) / sizeof (yytname[0]))) #endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const ]b4_uint_type(b4_r1_max)[ yyr1[] = +static const ]b4_int_type_for([b4_r1])[ yyr1[] = { ]b4_r1[ }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const ]b4_uint_type(b4_r2_max)[ yyr2[] = +static const ]b4_int_type_for([b4_r2])[ yyr2[] = { ]b4_r2[ }; /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */ -static const short yydprec[] = +static const ]b4_int_type_for([b4_dprec])[ yydprec[] = { ]b4_dprec[ }; /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */ -static const short yymerger[] = +static const ]b4_int_type_for([b4_merger])[ yymerger[] = { ]b4_merger[ }; @@ -289,82 +321,77 @@ static const short yymerger[] = /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ -static const short yydefact[] = +static const ]b4_int_type_for([b4_defact])[ yydefact[] = { ]b4_defact[ }; -/* YYPGOTO[NTERM-NUM]. */ -static const short yydefgoto[] = +/* YYPDEFGOTO[NTERM-NUM]. */ +static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] = { ]b4_defgoto[ }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -static const short yypact[] = +#define YYPACT_NINF ]b4_pact_ninf[ +static const ]b4_int_type_for([b4_pact])[ yypact[] = { ]b4_pact[ }; /* YYPGOTO[NTERM-NUM]. */ -static const short yypgoto[] = +static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] = { ]b4_pgoto[ }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. */ -static const short yytable[] = + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, parse error. */ +#define YYTABLE_NINF ]b4_table_ninf[ +static const ]b4_int_type_for([b4_table])[ yytable[] = { ]b4_table[ }; -/* YYCONFLP[YYPACT[STATE-NUM]] -- pointer into yyconfl of start of list - of conflicting reductions corresponding to action entry for state - STATE-NUM in yytable. 0 means no conflicts. The list in yyconfl - is terminated by a rule number of 0. */ -static const short yyconflp[] = +/* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of + list of conflicting reductions corresponding to action entry for + state STATE-NUM in yytable. 0 means no conflicts. The list in + yyconfl is terminated by a rule number of 0. */ +static const ]b4_int_type_for([b4_conflict_list_heads])[ yyconflp[] = { ]b4_conflict_list_heads[ }; -/* YYCONFL[I] -- lists of conflicting rule numbers, each terminated - by 0, pointed into by YYCONFLP. */ -static const short yyconfl[] = +/* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by + 0, pointed into by YYCONFLP. */ +]dnl Do not use b4_int_type_for here, since there are places where +dnl pointers onto yyconfl are taken, which type is "short *". +dnl We probably ought to introduce a type for confl. +[static const short yyconfl[] = { ]b4_conflicting_rules[ }; -static const short yycheck[] = +static const ]b4_int_type_for([b4_check])[ yycheck[] = { ]b4_check[ }; -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -#else /* !YYPARSE_PARAM */ -# define YYPARSE_PARAM_ARG void -#endif /* !YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -# ifdef YYPARSE_PARAM -int yyparse (void *); -# else -int yyparse (void); -# endif -#endif +/* Prevent warning if -Wmissing-prototypes. */ +]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param) -/* Error token number */ +m4_ifset([b4_parse_param], +[#define YY_USER_FORMALS , b4_c_ansi_formals(b4_parse_param) +#define YY_USER_ARGS , b4_c_args(b4_parse_param)], +[#define YY_USER_FORMALS +#define YY_USER_ARGS]) + + +[/* Error token number */ #define YYTERROR 1 /* YYLLOC_DEFAULT -- Compute the default location (before the actions @@ -373,26 +400,18 @@ int yyparse (void); #define YYRHSLOC(yyRhs,YYK) (yyRhs[YYK].yystate.yyloc) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN) \ - yyCurrent.yyfirst_line = YYRHSLOC(yyRhs,1).yyfirst_line; \ - yyCurrent.yyfirst_column = YYRHSLOC(yyRhs,1).yyfirst_column; \ - yyCurrent.yylast_line = YYRHSLOC(yyRhs,YYN).yylast_line; \ - yyCurrent.yylast_column = YYRHSLOC(yyRhs,YYN).yylast_column; +# define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN) \ + yyCurrent.first_line = YYRHSLOC(yyRhs,1).first_line; \ + yyCurrent.first_column = YYRHSLOC(yyRhs,1).first_column; \ + yyCurrent.last_line = YYRHSLOC(yyRhs,YYN).last_line; \ + yyCurrent.last_column = YYRHSLOC(yyRhs,YYN).last_column; #endif /* YYLEX -- calling `yylex' with the right arguments. */ +#define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[ ]b4_pure_if( [ -#ifdef YYLEX_PARAM -# define YYLEX yylex (yylvalp, b4_location_if([yyllocp, ])YYLEX_PARAM) -#else -# define YYLEX yylex (yylvalp[]b4_location_if([, yyllocp])) -#endif], -[#define YYLEX yylex ()]) - -b4_pure_if( -[ #undef yynerrs #define yynerrs (yystack->yyerrcnt) #undef yychar @@ -428,12 +447,13 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) + /* Avoid empty `if' bodies. */ +# define YYDPRINTF(Args) {} #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH -# define YYINITDEPTH ]b4_initdepth[ +# define YYINITDEPTH ]b4_stack_depth_init[ #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only @@ -448,7 +468,7 @@ int yydebug; #endif #ifndef YYMAXDEPTH -# define YYMAXDEPTH ]b4_maxdepth[ +# define YYMAXDEPTH ]b4_stack_depth_max[ #endif /* Minimum number of free items on the stack allowed after an @@ -567,8 +587,12 @@ yytokenName (yySymbol yytoken) * yyerr for YYERROR, yyabort for YYABORT. */ static YYRESULTTAG yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, - YYSTYPE* yyvalp, YYLTYPE* yylocp, yyGLRStack* yystack) + YYSTYPE* yyvalp, YYLTYPE* yylocp, yyGLRStack* yystack + YY_USER_FORMALS) { + /* Avoid `unused' warnings in there are no $n. */ + (void) yystack; + if (yyrhslen == 0) { *yyvalp = yyval_default; @@ -624,6 +648,10 @@ static YYSTYPE yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1) { YYSTYPE yyval = *yy0; + /* `Use' the arguments. */ + (void) yy0; + (void) yy1; + switch (yyn) { b4_mergers @@ -652,7 +680,7 @@ yylhsNonterm (yyRuleNum yyrule) static inline bool yyisDefaultedState (yyStateNum yystate) { - return yypact[yystate] == YYFLAG; + return yypact[yystate] == YYPACT_NINF; } /** The default reduction for STATE, assuming it has one. */ @@ -662,7 +690,7 @@ yydefaultAction (yyStateNum yystate) return yydefact[yystate]; } -/** Set *ACTION to the action to take in STATE on seeing TOKEN. +/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN. * Result R means * R < 0: Reduce on rule -R. * R = 0: Error. @@ -675,16 +703,21 @@ yygetLRActions (yyStateNum yystate, int yytoken, int* yyaction, const short** yyconflicts) { int yyindex = yypact[yystate] + yytoken; - if (yyindex < 0 || yyindex > YYLAST || yycheck[yyindex] != yytoken) + if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken) { *yyaction = -yydefact[yystate]; *yyconflicts = yyconfl; } - else + else if (yytable[yyindex] != YYTABLE_NINF) { *yyaction = yytable[yyindex]; *yyconflicts = yyconfl + yyconflp[yyindex]; } + else + { + *yyaction = 0; + *yyconflicts = yyconfl + yyconflp[yyindex]; + } } static inline yyStateNum @@ -692,7 +725,7 @@ yyLRgotoState (yyStateNum yystate, yySymbol yylhs) { int yyr; yyr = yypgoto[yylhs - YYNTOKENS] + yystate; - if (yyr >= 0 && yyr <= YYLAST && yycheck[yyr] == yystate) + if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate) return yytable[yyr]; else return yydefgoto[yylhs - YYNTOKENS]; @@ -701,13 +734,13 @@ yyLRgotoState (yyStateNum yystate, yySymbol yylhs) static inline bool yyisShiftAction (int yyaction) { - return yyaction > 0; + return 0 < yyaction; } static inline bool yyisErrorAction (int yyaction) { - return yyaction == 0 || yyaction == YYFLAG; + return yyaction == 0; } /* GLRStates */ @@ -720,15 +753,16 @@ yyhasResolvedValue (yyGLRState* yystate) return yystate->yyresolved; } -void yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate, - yyGLRState* yyrhs, yyRuleNum yyrule) +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 = yyrhs; + yynewItem->yystate = rhs; yynewItem->yyrule = yyrule; yynewItem->yynext = yystate->yysemantics.yyfirstVal; yystate->yysemantics.yyfirstVal = yynewItem; @@ -786,14 +820,14 @@ yyexpandGLRStack (yyGLRStack* yystack) size_t yysize, yynewSize; size_t yyn; yysize = yystack->yynextFree - yystack->yyitems; - if (yysize >= YYMAXDEPTH) + if (YYMAXDEPTH <= yysize) yyFail (yystack, "parsing stack overflow (%d items)", yysize); yynewSize = 2*yysize; - if (yynewSize > YYMAXDEPTH) + if (YYMAXDEPTH < yynewSize) yynewSize = YYMAXDEPTH; yyinitGLRStack (&yynewStack, yynewSize); for (yyp0 = yystack->yyitems, yyp1 = yynewStack.yyitems, yyn = yysize; - yyn > 0; + 0 < yyn; yyn -= 1, yyp0 += 1, yyp1 += 1) { *yyp1 = *yyp0; @@ -882,13 +916,13 @@ yyundeleteLastStack (yyGLRStack* yystack) static inline void yyremoveDeletes (yyGLRStack* yystack) { - int yyi, yyj; + size_t yyi, yyj; yyi = yyj = 0; while (yyj < yystack->yytops.yysize) { if (yystack->yytops.yystates[yyi] == NULL) { - if (YYDEBUG && yyi == yyj) + if (yyi == yyj) YYDPRINTF ((stderr, "Removing dead stacks.\n")); yystack->yytops.yysize -= 1; } @@ -931,7 +965,7 @@ yyglrShift (yyGLRStack* yystack, int yyk, yyStateNum yylrState, size_t yyposn, * the (unresolved) semantic value of RHS under the action for RULE. */ static inline void yyglrShiftDefer (yyGLRStack* yystack, int yyk, yyStateNum yylrState, - size_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule) + size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule) { yyGLRStackItem* yynewItem; @@ -945,7 +979,7 @@ yyglrShiftDefer (yyGLRStack* yystack, int yyk, yyStateNum yylrState, yystack->yytops.yystates[yyk] = &yynewItem->yystate; yystack->yynextFree += 1; yystack->yyspaceLeft -= 1; - yyaddDeferredAction (yystack, &yynewItem->yystate, yyrhs, yyrule); + yyaddDeferredAction (yystack, &yynewItem->yystate, rhs, yyrule); } /** Pop the symbols consumed by reduction #RULE from the top of stack @@ -956,14 +990,14 @@ yyglrShiftDefer (yyGLRStack* yystack, int yyk, yyStateNum yylrState, * for userAction. */ static inline int yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule, - YYSTYPE* yyvalp, YYLTYPE* yylocp) + YYSTYPE* yyvalp, YYLTYPE* yylocp YY_USER_FORMALS) { int yynrhs = yyrhsLength (yyrule); if (yystack->yysplitPoint == NULL) { /* Standard special case: single stack. */ - yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk]; + yyGLRStackItem* rhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk]; assert (yyk == 0); yystack->yynextFree -= yynrhs; yystack->yyspaceLeft += yynrhs; @@ -975,17 +1009,18 @@ yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule, } else { - *yyvalp = yyrhs[1-yynrhs].yystate.yysemantics.yysval; - *yylocp = yyrhs[1-yynrhs].yystate.yyloc; + *yyvalp = rhs[1-yynrhs].yystate.yysemantics.yysval; + *yylocp = rhs[1-yynrhs].yystate.yyloc; } - return yyuserAction (yyrule, yynrhs, yyrhs, yyvalp, yylocp, yystack); + return yyuserAction (yyrule, yynrhs, rhs, + yyvalp, yylocp, yystack YY_USER_ARGS); } else { int yyi; yyGLRState* yys; yyGLRStackItem yyrhsVals[YYMAXRHS]; - for (yyi = yynrhs-1, yys = yystack->yytops.yystates[yyk]; yyi >= 0; + for (yyi = yynrhs-1, yys = yystack->yytops.yystates[yyk]; 0 <= yyi; yyi -= 1, yys = yys->yypred) { assert (yys->yypred != NULL); @@ -1006,10 +1041,36 @@ yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule, *yylocp = yyrhsVals[0].yystate.yyloc; } return yyuserAction (yyrule, yynrhs, yyrhsVals + (yynrhs-1), - yyvalp, yylocp, yystack); + yyvalp, yylocp, yystack YY_USER_ARGS); } } +#if !YYDEBUG +# define YY_REDUCE_PRINT(K, Rule) +#else +# define YY_REDUCE_PRINT(K, Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (K, Rule); \ +} while (0) + +/*----------------------------------------------------------. +| Report that the RULE is going to be reduced on stack #K. | +`----------------------------------------------------------*/ + +static inline void +yy_reduce_print (size_t yyk, yyRuleNum yyrule) +{ + int yyi; + YYDPRINTF ((stderr, "Reducing stack %d by rule %d (line %d),", + yyk, yyrule - 1, 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])); +} +#endif + /** Pop items off stack #K of STACK according to grammar rule RULE, * and push back on the resulting nonterminal symbol. Perform the * semantic action associated with RULE and store its value with the @@ -1022,31 +1083,34 @@ yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule, * added to the options for the existing state's semantic value. */ static inline YYRESULTTAG -yyglrReduce (yyGLRStack* yystack, int yyk, yyRuleNum yyrule, bool yyforceEval) +yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule, + bool yyforceEval YY_USER_FORMALS) { - int yyposn = yystack->yytops.yystates[yyk]->yyposn; + size_t yyposn = yystack->yytops.yystates[yyk]->yyposn; if (yyforceEval || yystack->yysplitPoint == NULL) { YYSTYPE yysval; YYLTYPE yyloc; - YYCHK (yydoAction (yystack, yyk, yyrule, &yysval, &yyloc)); + YY_REDUCE_PRINT (yyk, yyrule); + YYCHK (yydoAction (yystack, yyk, yyrule, &yysval, &yyloc YY_USER_ARGS)); yyglrShift (yystack, yyk, yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState, yylhsNonterm (yyrule)), yyposn, yysval, &yyloc); - YYDPRINTF ((stderr, "Reduced stack %d by rule #%d. Now in state %d.\n", - yyk, yyrule-1, yystack->yytops.yystates[yyk]->yylrState)); + YYDPRINTF ((stderr, "Stack %d entering state %d\n", + yyk, yystack->yytops.yystates[yyk]->yylrState)); } else { - int yyi, yyn; + size_t yyi; + int yyn; yyGLRState* yys, *yys0 = yystack->yytops.yystates[yyk]; yyStateNum yynewLRState; for (yys = yystack->yytops.yystates[yyk], yyn = yyrhsLength (yyrule); - yyn > 0; yyn -= 1) + 0 < yyn; yyn -= 1) { yys = yys->yypred; assert (yys != NULL); @@ -1153,45 +1217,46 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) * parsing state; return 0 if no combination is possible, * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */ static int -yypreference (yySemanticOption* yyy0, yySemanticOption* yyy1) +yypreference (yySemanticOption* y0, yySemanticOption* y1) { - yyRuleNum yyr0 = yyy0->yyrule, yyr1 = yyy1->yyrule; - int yyp0 = yydprec[yyr0], yyp1 = yydprec[yyr1]; + yyRuleNum r0 = y0->yyrule, r1 = y1->yyrule; + int p0 = yydprec[r0], p1 = yydprec[r1]; - if (yyp0 == yyp1) + if (p0 == p1) { - if (yymerger[yyr0] == 0 || yymerger[yyr0] != yymerger[yyr1]) + if (yymerger[r0] == 0 || yymerger[r0] != yymerger[r1]) return 0; else return 1; } - if (yyp0 == 0 || yyp1 == 0) + if (p0 == 0 || p1 == 0) return 0; - if (yyp0 < yyp1) + if (p0 < p1) return 3; - if (yyp0 > yyp1) + if (p1 < p0) return 2; return 0; } static YYRESULTTAG yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack, YYSTYPE* yyvalp, - YYLTYPE* yylocp); + YYLTYPE* yylocp YY_USER_FORMALS); static YYRESULTTAG -yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack) +yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack YY_USER_FORMALS) { YYRESULTTAG yyflag; - if (yyn > 0) + if (0 < yyn) { assert (yys->yypred != NULL); - yyflag = yyresolveStates (yys->yypred, yyn-1, yystack); + yyflag = yyresolveStates (yys->yypred, yyn-1, yystack YY_USER_ARGS); if (yyflag != yyok) return yyflag; if (! yys->yyresolved) { yyflag = yyresolveValue (yys->yysemantics.yyfirstVal, yystack, - &yys->yysemantics.yysval, &yys->yyloc); + &yys->yysemantics.yysval, &yys->yyloc + YY_USER_ARGS); if (yyflag != yyok) return yyflag; yys->yyresolved = yytrue; @@ -1202,15 +1267,15 @@ yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack) static YYRESULTTAG yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack, - YYSTYPE* yyvalp, YYLTYPE* yylocp) + YYSTYPE* yyvalp, YYLTYPE* yylocp YY_USER_FORMALS) { yyGLRStackItem yyrhsVals[YYMAXRHS]; int yynrhs, yyi; yyGLRState* yys; yynrhs = yyrhsLength (yyopt->yyrule); - YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack)); - for (yyi = yynrhs-1, yys = yyopt->yystate; yyi >= 0; + YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack YY_USER_ARGS)); + for (yyi = yynrhs-1, yys = yyopt->yystate; 0 <= yyi; yyi -= 1, yys = yys->yypred) { assert (yys->yypred != NULL); @@ -1219,27 +1284,37 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack, yyrhsVals[yyi].yystate.yyloc = yys->yyloc; } return yyuserAction (yyopt->yyrule, yynrhs, yyrhsVals + (yynrhs-1), - yyvalp, yylocp, yystack); + yyvalp, yylocp, yystack YY_USER_ARGS); } #if YYDEBUG -static yyGLRState YYLEFTMOST_STATE = { 0, NULL, -1, 0, { NULL } }; +static yyGLRState YYLEFTMOST_STATE = + { + 0, 0, -1, NULL, 0, { NULL }, + /* yyloc. */ + { +#if YYLTYPE_IS_TRIVIAL +]b4_location_if([ 0, 0, 0, 0])[ +#endif + } + }; -static void yyreportTree (yySemanticOption* yyx, int yyindent) +static void +yyreportTree (yySemanticOption* yyx, int yyindent) { int yynrhs = yyrhsLength (yyx->yyrule); int yyi; yyGLRState* yys; yyGLRState* yystates[YYMAXRHS]; - for (yyi = yynrhs, yys = yyx->yystate; yyi > 0; yyi -= 1, yys = yys->yypred) + for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred) yystates[yyi] = yys; if (yys == NULL) yystates[0] = &YYLEFTMOST_STATE; else yystates[0] = yys; - if (yys->yyposn+1 > yyx->yystate->yyposn) + if (yyx->yystate->yyposn < yys->yyposn + 1) YYFPRINTF (stderr, "%*s%s -> \n", yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)), yyx->yyrule); @@ -1269,6 +1344,10 @@ static void yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1, yyGLRStack* yystack) { + /* `Unused' warnings. */ + (void) yyx0; + (void) yyx1; + #if YYDEBUG YYFPRINTF (stderr, "Ambiguity detected.\n"); YYFPRINTF (stderr, "Option 1,\n"); @@ -1285,7 +1364,7 @@ yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1, * actions, and return the result. */ static YYRESULTTAG yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack, - YYSTYPE* yyvalp, YYLTYPE* yylocp) + YYSTYPE* yyvalp, YYLTYPE* yylocp YY_USER_FORMALS) { yySemanticOption* yybest; yySemanticOption* yyp; @@ -1318,25 +1397,25 @@ yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack, if (yymerge) { int yyprec = yydprec[yybest->yyrule]; - YYCHK (yyresolveAction (yybest, yystack, yyvalp, yylocp)); + YYCHK (yyresolveAction (yybest, yystack, yyvalp, yylocp YY_USER_ARGS)); for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext) { if (yyprec == yydprec[yyp->yyrule]) { YYSTYPE yyval1; YYLTYPE yydummy; - YYCHK (yyresolveAction (yyp, yystack, &yyval1, &yydummy)); + YYCHK (yyresolveAction (yyp, yystack, &yyval1, &yydummy YY_USER_ARGS)); *yyvalp = yyuserMerge (yymerger[yyp->yyrule], yyvalp, &yyval1); } } return yyok; } else - return yyresolveAction (yybest, yystack, yyvalp, yylocp); + return yyresolveAction (yybest, yystack, yyvalp, yylocp YY_USER_ARGS); } static YYRESULTTAG -yyresolveStack (yyGLRStack* yystack) +yyresolveStack (yyGLRStack* yystack YY_USER_FORMALS) { if (yystack->yysplitPoint != NULL) { @@ -1347,7 +1426,8 @@ yyresolveStack (yyGLRStack* yystack) yys != yystack->yysplitPoint; yys = yys->yypred, yyn += 1) ; - YYCHK (yyresolveStates (yystack->yytops.yystates[0], yyn, yystack)); + YYCHK (yyresolveStates (yystack->yytops.yystates[0], yyn, yystack + YY_USER_ARGS)); } return yyok; } @@ -1384,7 +1464,8 @@ yycompressStack (yyGLRStack* yystack) static YYRESULTTAG yyprocessOneStack (yyGLRStack* yystack, int yyk, - size_t yyposn, YYSTYPE* yylvalp, YYLTYPE* yyllocp) + size_t yyposn, YYSTYPE* yylvalp, YYLTYPE* yyllocp + YY_USER_FORMALS) { int yyaction; const short* yyconflicts; @@ -1405,15 +1486,17 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk, yymarkStackDeleted (yystack, yyk); return yyok; } - YYCHK (yyglrReduce (yystack, yyk, yyrule, yyfalse)); + YYCHK (yyglrReduce (yystack, yyk, yyrule, yyfalse YY_USER_ARGS)); } else { if (*yytokenp == YYEMPTY) { + YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; *yytokenp = YYTRANSLATE(yychar); - YYDPRINTF ((stderr, "Read token %s\n", yytokenName (*yytokenp))); + YYDPRINTF ((stderr, "Next token is %s\n", + yytokenName (*yytokenp))); } yygetLRActions (yystate, *yytokenp, &yyaction, &yyconflicts); @@ -1422,15 +1505,16 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk, int yynewStack = yysplitStack (yystack, yyk); YYDPRINTF ((stderr, "Splitting off stack %d from %d.\n", yynewStack, yyk)); - YYCHK (yyglrReduce (yystack, yynewStack, *yyconflicts, yyfalse)); + YYCHK (yyglrReduce (yystack, yynewStack, + *yyconflicts, yyfalse YY_USER_ARGS)); YYCHK (yyprocessOneStack (yystack, yynewStack, yyposn, - yylvalp, yyllocp)); + yylvalp, yyllocp YY_USER_ARGS)); yyconflicts += 1; } if (yyisShiftAction (yyaction)) { - YYDPRINTF ((stderr, "Shifted token %s on stack %d, ", + YYDPRINTF ((stderr, "Shifting token %s on stack %d, ", yytokenName (*yytokenp), yyk)); yyglrShift (yystack, yyk, yyaction, yyposn+1, *yylvalp, yyllocp); YYDPRINTF ((stderr, "which is now in state #%d\n", @@ -1444,7 +1528,7 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk, break; } else - YYCHK (yyglrReduce (yystack, yyk, -yyaction, yyfalse)); + YYCHK (yyglrReduce (yystack, yyk, -yyaction, yyfalse YY_USER_ARGS)); } } return yyok; @@ -1453,17 +1537,21 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk, static void yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp) { - yySymbol* const yytokenp = yystack->yytokenp; + /* `Unused' warnings. */ + (void) yylvalp; + (void) yyllocp; if (yystack->yyerrState == 0) { #if YYERROR_VERBOSE - int yyn, yyx, yycount, yysize; - char* yyprefix; + yySymbol* const yytokenp = yystack->yytokenp; + int yyn, yyx, yycount; + size_t yysize; + const char* yyprefix; char* yyp; char* yymsg; yyn = yypact[yystack->yytops.yystates[0]->yylrState]; - if (yyn > YYFLAG && yyn < YYLAST) + if (YYPACT_NINF < yyn && yyn < YYLAST) { yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in @@ -1473,19 +1561,21 @@ yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp) yyprefix = ", expecting "; for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size && yycount <= 5; yyx += 1) - if (yycheck[yyx + yyn] == yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) yysize += strlen (yytokenName (yyx)) + strlen (yyprefix), yycount += 1, yyprefix = " or "; yymsg = yyp = (char*) malloc (yysize); - yyp += sprintf (yyp, "parse error, unexpected %s", - yytokenName (*yytokenp)); + sprintf (yyp, "parse error, unexpected %s", + yytokenName (*yytokenp)); + yyp += strlen (yyp); if (yycount < 5) { yyprefix = ", expecting "; for (yyx = yyn < 0 ? -yyn : 0; yyx < yytname_size; yyx += 1) - if (yycheck[yyx + yyn] == yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { - yyp += sprintf (yyp, "%s%s", yyprefix, yytokenName (yyx)); + sprintf (yyp, "%s%s", yyprefix, yytokenName (yyx)); + yyp += strlen (yyp); yyprefix = " or "; } } @@ -1499,50 +1589,47 @@ yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp) } } -/* Recover from a syntax error on STACK, assuming that TOKENP, +/* Recover from a syntax error on YYSTACK, assuming that YYTOKENP, YYLVALP, and YYLLOCP point to the syntactic category, semantic - value, and location of the lookahead. - NOTE: This uses the panic-mode recovery algorithm described in the - Bison documentation, which differs from what is in bison.simple. - Specifically, this routine performs no reductions before shifting - the error token. */ + value, and location of the lookahead. */ static void yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp) { yySymbol* const yytokenp = yystack->yytokenp; - int yyk, yyj; + size_t yyk; + int yyj; if (yystack->yyerrState == 0) yystack->yyerrState = 3; else if (yystack->yyerrState == 3) - { - /* We just shifted the error token and (perhaps) took some - reductions. Skip tokens until we can proceed. */ - do { + /* We just shifted the error token and (perhaps) took some + reductions. Skip tokens until we can proceed. */ + while (yytrue) + { if (*yytokenp == YYEOF) yyFail (yystack, NULL); if (*yytokenp != YYEMPTY) YYDPRINTF ((stderr, "Discarding token %s\n", yytokenName (*yytokenp))); + YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; *yytokenp = YYTRANSLATE (yychar); - YYDPRINTF ((stderr, "Read token %s\n", yytokenName (*yytokenp))); + YYDPRINTF ((stderr, "Next token is %s\n", yytokenName (*yytokenp))); yyj = yypact[yystack->yytops.yystates[0]->yylrState]; - if (yyj == YYFLAG) - /* Something's not right; we shouldn't be here */ + if (yyj == YYPACT_NINF) + /* Something's not right; we shouldn't be here. */ yyFail (yystack, NULL); yyj += *yytokenp; - if (yyj < 0 || yyj > YYLAST || yycheck[yyj] != *yytokenp) + if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != *yytokenp) { if (yydefact[yystack->yytops.yystates[0]->yylrState] != 0) return; } - else if (yytable[yyj] != 0 && yytable[yyj] != YYFLAG) + else if (yytable[yyj] != 0 && yytable[yyj] != YYTABLE_NINF) return; - } while (yytrue); - } + } - /* Reduce to one stack */ + /* Reduce to one stack. */ for (yyk = 0; yyk < yystack->yytops.yysize; yyk += 1) if (yystack->yytops.yystates[yyk] != NULL) break; @@ -1557,7 +1644,7 @@ yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp) while (yystack->yytops.yystates[0] != NULL) { yyj = yypact[yystack->yytops.yystates[0]->yylrState] + YYTERROR; - if (yyj != YYFLAG + YYTERROR && yyj >= 0 && yyj <= YYLAST && + if (yyj != YYPACT_NINF + YYTERROR && yyj >= 0 && yyj <= YYLAST && yycheck[yyj] == YYTERROR && yyisShiftAction (yytable[yyj])) { yyglrShift (yystack, 0, yytable[yyj], @@ -1588,8 +1675,12 @@ yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp) } \ } while (0) -int -yyparse (YYPARSE_PARAM_ARG) + +/*----------. +| yyparse. | +`----------*/ + +]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[ { yySymbol yytoken; yyGLRStack yystack; @@ -1608,6 +1699,8 @@ yyparse (YYPARSE_PARAM_ARG) yyinitGLRStack (&yystack, YYINITDEPTH); yystack.yytokenp = &yytoken; + YYDPRINTF ((stderr, "Starting parse\n")); + if (setjmp (yystack.yyexception_buffer) != 0) goto yyDone; @@ -1617,9 +1710,9 @@ yyparse (YYPARSE_PARAM_ARG) while (yytrue) { - /* For efficiency, we have two loops, of which the first of which - * is specialized to deterministic operation (single stack, no - * potential ambiguity). */ + /* For efficiency, we have two loops, the first of which is + specialized to deterministic operation (single stack, no + potential ambiguity). */ /* Standard mode */ while (yytrue) @@ -1639,15 +1732,16 @@ yyparse (YYPARSE_PARAM_ARG) yyreportParseError (&yystack, yylvalp, yyllocp); goto yyuser_error; } - YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue)); + YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue YY_USER_ARGS)); } else { if (yytoken == YYEMPTY) { + YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; yytoken = YYTRANSLATE (yychar); - YYDPRINTF ((stderr, "Read token %s\n", + YYDPRINTF ((stderr, "Next token is %s\n", yytokenName (yytoken))); } yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts); @@ -1655,15 +1749,15 @@ yyparse (YYPARSE_PARAM_ARG) break; if (yyisShiftAction (yyaction)) { - YYDPRINTF ((stderr, "Shifted token %s. ", + YYDPRINTF ((stderr, "Shifting token %s, ", yytokenName (yytoken))); if (yytoken != YYEOF) yytoken = YYEMPTY; yyposn += 1; yyglrShift (&yystack, 0, yyaction, yyposn, yylval, yyllocp); - if (yystack.yyerrState > 0) + if (0 < yystack.yyerrState) yystack.yyerrState -= 1; - YYDPRINTF ((stderr, "Now in state #%d\n", + YYDPRINTF ((stderr, "Entering state %d\n", yystack.yytops.yystates[0]->yylrState)); } else if (yyisErrorAction (yyaction)) @@ -1672,7 +1766,7 @@ yyparse (YYPARSE_PARAM_ARG) goto yyuser_error; } else - YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue)); + YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue YY_USER_ARGS)); } } @@ -1682,7 +1776,7 @@ yyparse (YYPARSE_PARAM_ARG) int yyn = yystack.yytops.yysize; for (yys = 0; yys < yyn; yys += 1) YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn, - yylvalp, yyllocp)); + yylvalp, yyllocp YY_USER_ARGS)); yytoken = YYEMPTY; yyposn += 1; yyremoveDeletes (&yystack); @@ -1691,14 +1785,14 @@ yyparse (YYPARSE_PARAM_ARG) yyundeleteLastStack (&yystack); if (yystack.yytops.yysize == 0) yyFail (&yystack, "parse error"); - YYCHK1 (yyresolveStack (&yystack)); + YYCHK1 (yyresolveStack (&yystack YY_USER_ARGS)); YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); yyreportParseError (&yystack, yylvalp, yyllocp); goto yyuser_error; } else if (yystack.yytops.yysize == 1) { - YYCHK1 (yyresolveStack (&yystack)); + YYCHK1 (yyresolveStack (&yystack YY_USER_ARGS)); YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); yycompressStack (&yystack); break; @@ -1717,21 +1811,23 @@ yyparse (YYPARSE_PARAM_ARG) } /* DEBUGGING ONLY */ +static void yypstack (yyGLRStack* yystack, int yyk) ATTRIBUTE_UNUSED; +static void yypdumpstack (yyGLRStack* yystack) ATTRIBUTE_UNUSED; -void -yypstates (yyGLRState* yyst) +static void +yy_yypstack (yyGLRState* yys) { - void yy_yypstack (yyGLRState* yys) + if (yys->yypred) { - if (yys->yypred == NULL) - fprintf (stderr, "%d@%d", yys->yylrState, yys->yyposn); - else - { - yy_yypstack (yys->yypred); - fprintf (stderr, " -> %d@%d", yys->yylrState, yys->yyposn); - } + yy_yypstack (yys->yypred); + fprintf (stderr, " -> "); } + fprintf (stderr, "%d@%lu", yys->yylrState, (unsigned long) yys->yyposn); +} +static void +yypstates (yyGLRState* yyst) +{ if (yyst == NULL) fprintf (stderr, ""); else @@ -1739,7 +1835,7 @@ yypstates (yyGLRState* yyst) fprintf (stderr, "\n"); } -void +static void yypstack (yyGLRStack* yystack, int yyk) { yypstates (yystack->yytops.yystates[yyk]); @@ -1749,38 +1845,39 @@ yypstack (yyGLRStack* yystack, int yyk) ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems) -void +static void yypdumpstack (yyGLRStack* yystack) { yyGLRStackItem* yyp; - int yyi; + size_t yyi; for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1) { - fprintf (stderr, "%3d. ", yyp - yystack->yyitems); + fprintf (stderr, "%3lu. ", (unsigned long) (yyp - yystack->yyitems)); if (*(bool*) yyp) { - fprintf (stderr, "Res: %d, LR State: %d, posn: %d, pred: %d", + fprintf (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld", yyp->yystate.yyresolved, yyp->yystate.yylrState, - yyp->yystate.yyposn, - YYINDEX(yyp->yystate.yypred)); + (unsigned long) yyp->yystate.yyposn, + (long) YYINDEX (yyp->yystate.yypred)); if (! yyp->yystate.yyresolved) - fprintf (stderr, ", firstVal: %d", - YYINDEX (yyp->yystate.yysemantics.yyfirstVal)); + fprintf (stderr, ", firstVal: %ld", + (long) YYINDEX (yyp->yystate.yysemantics.yyfirstVal)); } else { - fprintf (stderr, "Option. rule: %d, state: %d, next: %d", - yyp->yyoption.yyrule, YYINDEX (yyp->yyoption.yystate), - YYINDEX (yyp->yyoption.yynext)); + fprintf (stderr, "Option. rule: %d, state: %ld, next: %ld", + yyp->yyoption.yyrule, + (long) YYINDEX (yyp->yyoption.yystate), + (long) YYINDEX (yyp->yyoption.yynext)); } fprintf (stderr, "\n"); } fprintf (stderr, "Tops:"); for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1) - fprintf (stderr, "%d: %d; ", yyi, YYINDEX (yystack->yytops.yystates[yyi])); + fprintf (stderr, "%lu: %ld; ", (unsigned long) yyi, + (long) YYINDEX (yystack->yytops.yystates[yyi])); fprintf (stderr, "\n"); } - ] b4_epilogue @@ -1809,10 +1906,10 @@ b4_location_if( [#ifndef YYLTYPE typedef struct yyltype { - int yyfirst_line; - int yyfirst_column; - int yylast_line; - int yylast_column; + int first_line; + int first_column; + int last_line; + int last_column; } yyltype; # define YYLTYPE yyltype #endif