# GLR skeleton for Bison
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
[m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])])
-# b4_lex_param
-# ------------
-# 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 *]], [[&yylval]]][]dnl
-b4_locations_if([, [[YYLTYPE *], [&yylloc]]])])dnl
-m4_ifdef([b4_lex_param], [, ]b4_lex_param)))
-
-
# b4_yyerror_args
# ---------------
# Optional effective arguments passed to yyerror: user args plus yylloc, and
# 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_function_declare(b4_prefix[parse], [int], b4_parse_param)[
]b4_percent_code_get([[provides]])[]dnl
])
-
+])
## -------------- ##
## Output files. ##
## -------------- ##
-# We do want M4 expansion after # for CPP macros.
-m4_changecom()
-m4_divert_push(0)dnl
-@output(b4_parser_file_name@)@
+b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
- [2002-2012])
-[
+ [2002-2013])[
+
/* C GLR parser skeleton written by Paul Hilfinger. */
]b4_identification
#define yyparse ]b4_prefix[parse
#define yylex ]b4_prefix[lex
#define yyerror ]b4_prefix[error
+#define yydebug ]b4_prefix[debug
+]]b4_pure_if([], [[
#define yylval ]b4_prefix[lval
#define yychar ]b4_prefix[char
-#define yydebug ]b4_prefix[debug
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
-#define yylloc ]b4_prefix[lloc]])])[
+#define yylloc ]b4_prefix[lloc]])]))[
/* First part of user declarations. */
]b4_user_pre_prologue[
#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. */
-#ifdef __GNUC__
-# define YYUSE(e) ((void) (e))
-#else
-# define YYUSE(e) /* empty */
-#endif
-
#ifndef YYFREE
# define YYFREE free
#endif
#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))
-# define __attribute__(Spec) /* empty */
-# endif
+# define YYSETJMP(Env) setjmp (Env)
+/* Pacify clang. */
+# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
#endif
-]b4_locations_if([#define YYOPTIONAL_LOC(Name) Name],[
-#ifdef __cplusplus
-# define YYOPTIONAL_LOC(Name) /* empty */
-#else
-# define YYOPTIONAL_LOC(Name) Name __attribute__ ((__unused__))
-#endif])[
+]b4_attribute_define[
#ifndef YYASSERT
-# define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
+# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
#endif
/* YYFINAL -- State number of the termination state. */
/* 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 int *".
+dnl pointers onto yyconfl are taken, whose type is "short int *".
dnl We probably ought to introduce a type for confl.
[static const short int yyconfl[] =
{
]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
-
-/* YYLEX -- calling `yylex' with the right arguments. */
-#define YYLEX ]b4_function_call([yylex], [int], b4_lex_param)[
+]])[
]b4_pure_if(
[
# define YYFPRINTF fprintf
# endif
+]b4_yy_location_print_define[
+
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
multiple parsers can coexist. */
int yydebug;
+struct yyGLRStack;
+static void yypstack (struct yyGLRStack* yystackp, size_t yyk)
+ __attribute__ ((__unused__));
+static void yypdumpstack (struct yyGLRStack* yystackp)
+ __attribute__ ((__unused__));
+
#else /* !]b4_api_PREFIX[DEBUG */
# define YYDPRINTF(Args)
* (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
* yyerr for YYERROR, yyabort for YYABORT. */
static YYRESULTTAG
-yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
+yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
yyGLRStack* yystackp,
YYSTYPE* yyvalp]b4_locuser_formals[)
{
(yystackp->yysplitPoint == YY_NULL);
int yylow;
]b4_parse_param_use([yyvalp], [yylocp])dnl
-[# undef yyerrok
+[ YYUSE (yyrhslen);
+# undef yyerrok
# define yyerrok (yystackp->yyerrState = 0)
# undef YYACCEPT
# define YYACCEPT return yyaccept
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
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
+ yychar = ]b4_lex[;
}
if (yychar <= YYEOF)
#if ! YYERROR_VERBOSE
yyerror (]b4_lyyerror_args[YY_("syntax error"));
#else
+ {
yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
size_t yysize0 = yytnamerr (YY_NULL, yytokenName (yytoken));
size_t yysize = yysize0;
- size_t yysize1;
yybool yysize_overflow = yyfalse;
char* yymsg = YY_NULL;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
break;
}
yyarg[yycount++] = yytokenName (yyx);
- yysize1 = yysize + yytnamerr (YY_NULL, yytokenName (yyx));
- yysize_overflow |= yysize1 < yysize;
- yysize = yysize1;
+ {
+ size_t yysz = yysize + yytnamerr (YY_NULL, yytokenName (yyx));
+ yysize_overflow |= yysz < yysize;
+ yysize = yysz;
+ }
}
}
}
#undef YYCASE_
}
- yysize1 = yysize + strlen (yyformat);
- yysize_overflow |= yysize1 < yysize;
- yysize = yysize1;
+ {
+ size_t yysz = yysize + strlen (yyformat);
+ yysize_overflow |= yysz < yysize;
+ yysize = yysz;
+ }
if (!yysize_overflow)
yymsg = (char *) YYMALLOC (yysize);
yyerror (]b4_lyyerror_args[YY_("syntax error"));
yyMemoryExhausted (yystackp);
}
+ }
#endif /* YYERROR_VERBOSE */
yynerrs += 1;
}
yytoken, &yylval]b4_locuser_args([&yylloc])[);
}
YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
+ yychar = ]b4_lex[;
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
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
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
+ yychar = ]b4_lex[;
}
if (yychar <= YYEOF)
/* DEBUGGING ONLY */
#if ]b4_api_PREFIX[DEBUG
-static void yypstack (yyGLRStack* yystackp, size_t yyk)
- __attribute__ ((__unused__));
-static void yypdumpstack (yyGLRStack* yystackp) __attribute__ ((__unused__));
-
static void
yy_yypstack (yyGLRState* yys)
{
YYFPRINTF (stderr, "\n");
}
#endif
+
+#undef yylval
+#undef yychar
+#undef yynerrs]b4_locations_if([
+#undef yylloc])
+
+m4_if(b4_prefix, [yy], [],
+[[/* Substitute the variable and function names. */
+#define yyparse ]b4_prefix[parse
+#define yylex ]b4_prefix[lex
+#define yyerror ]b4_prefix[error
+#define yylval ]b4_prefix[lval
+#define yychar ]b4_prefix[char
+#define yydebug ]b4_prefix[debug
+#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
+#define yylloc ]b4_prefix[lloc]])])[
+
]b4_epilogue[]dnl
-dnl
-dnl glr.cc produces its own header.
-dnl
+b4_output_end()
+
+# glr.cc produces its own header.
m4_if(b4_skeleton, ["glr.c"],
[b4_defines_if(
-[@output(b4_spec_defines_file@)@
+[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C],
- [2002-2012])[
+ [2002-2013])[
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[
-]])])dnl
-m4_divert_pop(0)
+]b4_output_end()
+])])