X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/e3f12e0818baab3e61dd30270c54def9ac2f2ad4..e42906f7904ca7516e9867a3a19ee08d963b1205:/data/glr.c?ds=sidebyside diff --git a/data/glr.c b/data/glr.c index 18a11380..9038c747 100644 --- a/data/glr.c +++ b/data/glr.c @@ -172,8 +172,9 @@ m4_define([b4_rhs_location], # b4_shared_declarations # ---------------------- # Declaration that might either go into the header (if --defines) -# or open coded in the parser body. -m4_define([b4_shared_declarations], +# or open coded in the parser body. glr.cc has its own definition. +m4_if(b4_skeleton, ["glr.c"], +[m4_define([b4_shared_declarations], [b4_declare_yydebug[ ]b4_percent_code_get([[requires]])[ ]b4_token_enums[ @@ -181,7 +182,7 @@ m4_define([b4_shared_declarations], ]b4_function_declare(b4_prefix[parse], [int], b4_parse_param)[ ]b4_percent_code_get([[provides]])[]dnl ]) - +]) ## -------------- ## ## Output files. ## @@ -231,11 +232,11 @@ b4_percent_code_get([[top]])[ #endif /* Default (constant) value used for initialization for null - right-hand sides. Unlike the standard yacc.c template, - here we set the default value of $$ to a zeroed-out value. - Since the default value is undefined, this behavior is - technically correct. */ -static YYSTYPE yyval_default; + right-hand sides. Unlike the standard yacc.c template, here we set + the default value of $$ to a zeroed-out value. Since the default + value is undefined, this behavior is technically correct. */ +static YYSTYPE yyval_default;]b4_locations_if([[ +static YYLTYPE yyloc_default][]b4_yyloc_default;])[ /* Copy the second part of user declarations. */ ]b4_user_post_prologue @@ -249,29 +250,19 @@ b4_percent_code_get[]dnl # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ -# define YY_(msgid) msgid +# define YY_(Msgid) Msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +#ifdef __GNUC__ +# define YYUSE(E) ((void) (E)) #else -# define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) -#else -]b4_function_define([YYID], [static int], [[int i], [i]])[ -{ - return i; -} +# define YYUSE(E) /* empty */ #endif #ifndef YYFREE @@ -297,8 +288,9 @@ b4_percent_code_get[]dnl #ifndef YYSETJMP # include # define YYJMP_BUF jmp_buf -# define YYSETJMP(env) setjmp (env) -# define YYLONGJMP(env, val) longjmp (env, val) +# define YYSETJMP(Env) setjmp (Env) +// Pacify clang. +# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0)) #endif /*-----------------. @@ -321,7 +313,7 @@ b4_percent_code_get[]dnl #endif])[ #ifndef YYASSERT -# define YYASSERT(condition) ((void) ((condition) || (abort (), 0))) +# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0))) #endif /* YYFINAL -- State number of the termination state. */ @@ -415,33 +407,15 @@ dnl We probably ought to introduce a type for confl. { ]b4_conflicting_rules[ }; - + /* Error token number */ #define YYTERROR 1 ]b4_locations_if([[ -#ifndef YYLLOC_DEFAULT ]b4_yylloc_default_define[ # define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc) - -/* 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 +]])[ +]b4_yy_location_print_define[ /* YYLEX -- calling `yylex' with the right arguments. */ #define YYLEX ]b4_function_call([yylex], [int], b4_lex_param)[ @@ -477,7 +451,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG; YYRESULTTAG yychk_flag = YYE; \ if (yychk_flag != yyok) \ return yychk_flag; \ - } while (YYID (0)) + } while (0) #if ]b4_api_PREFIX[DEBUG @@ -489,7 +463,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG; do { \ if (yydebug) \ YYFPRINTF Args; \ - } while (YYID (0)) + } while (0) ]b4_yy_symbol_print_define[ @@ -501,7 +475,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG; yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[); \ YYFPRINTF (stderr, "\n"); \ } \ - } while (YYID (0)) + } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -546,13 +520,13 @@ int yydebug; do { \ if (Yystack->yyspaceLeft < YYHEADROOM) \ yyexpandGLRStack (Yystack); \ - } while (YYID (0)) + } while (0) #else # define YY_RESERVE_GLRSTACK(Yystack) \ do { \ if (Yystack->yyspaceLeft < YYHEADROOM) \ yyMemoryExhausted (Yystack); \ - } while (YYID (0)) + } while (0) #endif @@ -804,7 +778,7 @@ yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal) * value ($$), and yylocp points to place for location information * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT, * yyerr for YYERROR, yyabort for YYABORT. */ -/*ARGSUSED*/ static YYRESULTTAG +static YYRESULTTAG yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, yyGLRStack* yystackp, YYSTYPE* yyvalp]b4_locuser_formals[) @@ -855,9 +829,9 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, # undef yyclearin # undef YYRECOVERING } - -/*ARGSUSED*/ static void + +static void yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1) { YYUSE (yy0); @@ -865,7 +839,7 @@ yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1) switch (yyn) { - ]b4_mergers[ +]b4_mergers[ default: break; } } @@ -922,8 +896,8 @@ yylhsNonterm (yyRuleNum yyrule) return yyr1[yyrule]; } -#define yypact_value_is_default(yystate) \ - ]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[ +#define yypact_value_is_default(Yystate) \ + ]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[ /** True iff LR state YYSTATE has only a default reduction (regardless * of token). */ @@ -940,8 +914,8 @@ yydefaultAction (yyStateNum yystate) return yydefact[yystate]; } -#define yytable_value_is_error(yytable_value) \ - ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[ +#define yytable_value_is_error(Yytable_value) \ + ]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[ /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN. * Result R means @@ -1277,13 +1251,13 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, do { \ if (yydebug) \ yy_reduce_print Args; \ -} while (YYID (0)) +} while (0) /*----------------------------------------------------------------------. | Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. | `----------------------------------------------------------------------*/ -/*ARGSUSED*/ static inline void +static inline void yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk, yyRuleNum yyrule]b4_user_formals[) { @@ -1533,7 +1507,7 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) { yySemanticOption** yyz0p = &yys0->yysemantics.yyfirstVal; yySemanticOption* yyz1 = yys1->yysemantics.yyfirstVal; - while (YYID (yytrue)) + while (yytrue) { if (yyz1 == *yyz0p || yyz1 == YY_NULL) break; @@ -1694,7 +1668,7 @@ yyreportTree (yySemanticOption* yyx, int yyindent) } #endif -/*ARGSUSED*/ static YYRESULTTAG +static YYRESULTTAG yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1]b4_pure_formals[) { @@ -2025,7 +1999,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk, return yyok; } -/*ARGSUSED*/ static void +static void yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[) { if (yystackp->yyerrState != 0) @@ -2157,7 +2131,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[) /* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP, yylval, and yylloc are the syntactic category, semantic value, and location of the lookahead. */ -/*ARGSUSED*/ static void +static void yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) { size_t yyk; @@ -2166,7 +2140,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) if (yystackp->yyerrState == 3) /* We just shifted the error token and (perhaps) took some reductions. Skip tokens until we can proceed. */ - while (YYID (yytrue)) + while (yytrue) { yySymbol yytoken; if (yychar == YYEOF) @@ -2270,7 +2244,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) default: \ goto yybuglab; \ } \ - } while (YYID (0)) + } while (0) /*----------. | yyparse. | @@ -2286,14 +2260,9 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) YYDPRINTF ((stderr, "Starting parse\n")); yychar = YYEMPTY; - yylval = yyval_default; -]b4_locations_if([ -#if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL - yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[; - yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[; -#endif -]) -m4_ifdef([b4_initial_action], [ + yylval = yyval_default;]b4_locations_if([ + yylloc = yyloc_default;])[ +]m4_ifdef([b4_initial_action], [ b4_dollar_pushdef([yylval], [], [yylloc])dnl /* User initialization code. */ b4_user_initial_action @@ -2311,13 +2280,13 @@ b4_dollar_popdef])[]dnl yyglrShift (&yystack, 0, 0, 0, &yylval]b4_locations_if([, &yylloc])[); yyposn = 0; - while (YYID (yytrue)) + while (yytrue) { /* For efficiency, we have two loops, the first of which is specialized to deterministic operation (single stack, no potential ambiguity). */ /* Standard mode */ - while (YYID (yytrue)) + while (yytrue) { yyRuleNum yyrule; int yyaction; @@ -2381,7 +2350,7 @@ b4_dollar_popdef])[]dnl } } - while (YYID (yytrue)) + while (yytrue) { yySymbol yytoken_to_shift; size_t yys; @@ -2513,8 +2482,7 @@ b4_dollar_popdef])[]dnl yyfreeGLRStack (&yystack); } - /* Make sure YYID is used. */ - return YYID (yyresult); + return yyresult; } /* DEBUGGING ONLY */ @@ -2604,5 +2572,5 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C], ]b4_cpp_guard_open([b4_spec_defines_file])[ ]b4_shared_declarations[ ]b4_cpp_guard_close([b4_spec_defines_file])[ -]])]) +]])])dnl m4_divert_pop(0)