# 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)])])
+[m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])])
# b4_lex_param
# a trailing comma.
m4_define([b4_yyerror_args],
[b4_pure_if([b4_locations_if([yylocp, ])])dnl
-m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
+m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
# b4_lyyerror_args
# Same as above, but on the lookahead, hence &yylloc instead of yylocp.
m4_define([b4_lyyerror_args],
[b4_pure_if([b4_locations_if([&yylloc, ])])dnl
-m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
+m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
# b4_pure_args
# 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(b4_tokens)[
+]b4_token_enums[
]b4_declare_yylstype[
-]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
+]b4_function_declare(b4_prefix[parse], [int], b4_parse_param)[
]b4_percent_code_get([[provides]])[]dnl
])
-
+])
## -------------- ##
## Output files. ##
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
#define yylloc ]b4_prefix[lloc]])])[
-/* Copy the first part of user declarations. */
+/* First part of user declarations. */
]b4_user_pre_prologue[
]b4_null_define[
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
- [b4_shared_declarations])[
+ [b4_shared_declarations])[
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
#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
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* 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_c_function_def([YYID], [static int], [[int i], [i]])[
-{
- return i;
-}
+# define YYUSE(E) /* empty */
#endif
#ifndef YYFREE
#ifndef YYSETJMP
# include <setjmp.h>
# 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
/*-----------------.
#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. */
{
]b4_conflicting_rules[
};
-\f
+
/* 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_c_function_call([yylex], [int], b4_lex_param)[
+#define YYLEX ]b4_function_call([yylex], [int], b4_lex_param)[
]b4_pure_if(
[
YYRESULTTAG yychk_flag = YYE; \
if (yychk_flag != yyok) \
return yychk_flag; \
- } while (YYID (0))
+ } while (0)
#if ]b4_api_PREFIX[DEBUG
do { \
if (yydebug) \
YYFPRINTF Args; \
- } while (YYID (0))
+ } while (0)
-]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[
+]b4_yy_symbol_print_define[
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
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. */
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
* 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[)
# undef yyclearin
# undef YYRECOVERING
}
-\f
-/*ARGSUSED*/ static void
+
+static void
yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
{
YYUSE (yy0);
switch (yyn)
{
- ]b4_mergers[
+]b4_mergers[
default: break;
}
}
/* Bison grammar-table manipulation. */
-]b4_yydestruct_generate([b4_c_ansi_function_def])[
+]b4_yydestruct_define[
/** Number of symbols composing the right hand side of rule #RULE. */
static inline int
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). */
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
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[)
{
{
yySemanticOption** yyz0p = &yys0->yysemantics.yyfirstVal;
yySemanticOption* yyz1 = yys1->yysemantics.yyfirstVal;
- while (YYID (yytrue))
+ while (yytrue)
{
if (yyz1 == *yyz0p || yyz1 == YY_NULL)
break;
}
#endif
-/*ARGSUSED*/ static YYRESULTTAG
+static YYRESULTTAG
yyreportAmbiguity (yySemanticOption* yyx0,
yySemanticOption* yyx1]b4_pure_formals[)
{
return yyok;
}
-/*ARGSUSED*/ static void
+static void
yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
{
if (yystackp->yyerrState != 0)
/* 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;
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)
default: \
goto yybuglab; \
} \
- } while (YYID (0))
+ } while (0)
/*----------.
| yyparse. |
`----------*/
-]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[
+]b4_function_define([yyparse], [int], b4_parse_param)[
{
int yyresult;
yyGLRStack yystack;
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], [
-m4_pushdef([b4_at_dollar], [yylloc])dnl
-m4_pushdef([b4_dollar_dollar], [yylval])dnl
+ 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
-m4_popdef([b4_dollar_dollar])dnl
-m4_popdef([b4_at_dollar])])dnl
+b4_dollar_popdef])[]dnl
[
if (! yyinitGLRStack (yystackp, YYINITDEPTH))
goto yyexhaustedlab;
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;
}
}
- while (YYID (yytrue))
+ while (yytrue)
{
yySymbol yytoken_to_shift;
size_t yys;
yyfreeGLRStack (&yystack);
}
- /* Make sure YYID is used. */
- return YYID (yyresult);
+ return yyresult;
}
/* DEBUGGING ONLY */
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[
-]])])
+]])])dnl
m4_divert_pop(0)