## ------------------------ ##
-# b4_pure_if(IF-TRUE, IF-FALSE)
-# -----------------------------
+# b4_yacc_pure_if(IF-TRUE, IF-FALSE)
+# ----------------------------------
# Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise.
-m4_define([b4_Pure_if],
+m4_define([b4_yacc_pure_if],
[b4_pure_if([m4_ifset([b4_parse_param],
[$1], [$2])],
[$2])])
# ---------------
# Arguments passed to yyerror: user args plus yylloc.
m4_define([b4_yyerror_args],
-[b4_Pure_if([b4_location_if([&yylloc, ])])dnl
+[b4_yacc_pure_if([b4_location_if([&yylloc, ])])dnl
m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
m4_define([b4_rhs_value],
-[(yyvsp@{m4_eval([$2 - $1])@}m4_ifval([$3], [.$3]))])
+[(yyvsp@{($2) - ($1)@}m4_ifval([$3], [.$3]))])
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
# on RHS.
m4_define([b4_rhs_location],
-[(yylsp@{m4_eval([$2 - $1])@})])
+[(yylsp@{($2) - ($1)@})])
b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
[1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005])[
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
+/* As a special exception, when this parser skeleton is copied by
+ Bison into a Bison output file, you may use that output file
+ without restriction. This special exception was added by the Free
+ Software Foundation for C LALR(1) parsers in version 1.24 of
+ Bison. */
-/* Written by Richard Stallman by simplifying the original so called
- ``semantic'' parser. */
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
/* Line __line__ of yacc.c. */
b4_syncline([@oline@], [@ofile@])[
+/* Define YYMODERN_C if this compiler supports C89 or better. If
+ __STDC__ is defined, the compiler is modern. IBM xlc 7.0 when run
+ as 'cc' doesn't define __STDC__ (or __STDC_VERSION__) for pedantic
+ reasons, but it defines __C99__FUNC__ so check that as well.
+ Consider a C++ compiler to be modern if it defines __cplusplus. */
+#ifndef YYMODERN_C
+# if defined (__STDC__) || defined (__C99__FUNC__) || defined (__cplusplus)
+# define YYMODERN_C 1
+# else
+# define YYMODERN_C 0
+# endif
+#endif
+
#ifndef YYSIZE_T
# if defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
# elif defined (size_t)
# define YYSIZE_T size_t
-# elif ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
+# elif ! defined (YYSIZE_T) && YYMODERN_C
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
-# if (! defined (_ALLOCA_H) && ! defined (_STDLIB_H) \
- && (defined (__STDC__) || defined (__cplusplus)))
+# if ! defined (_ALLOCA_H) && ! defined (_STDLIB_H) && YYMODERN_C
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef _STDLIB_H
# define _STDLIB_H 1
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
-# if (! defined (malloc) && ! defined (_STDLIB_H) \
- && (defined (__STDC__) || defined (__cplusplus)))
+# if ! defined (malloc) && ! defined (_STDLIB_H) && YYMODERN_C
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
-# if (! defined (free) && ! defined (_STDLIB_H) \
- && (defined (__STDC__) || defined (__cplusplus)))
+# if ! defined (free) && ! defined (_STDLIB_H) && YYMODERN_C
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
#endif
-#if defined (__STDC__) || defined (__cplusplus)
+#if YYMODERN_C
typedef signed char yysigned_char;
#else
typedef short int yysigned_char;
YYFPRINTF Args; \
} while (/*CONSTCOND*/ 0)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yysymprint (stderr, \
- Type, Value]b4_location_if([, Location])[); \
- YYFPRINTF (stderr, "\n"); \
- } \
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yysymprint (stderr, \
+ Type, Value]b4_location_if([, Location])[]b4_user_args[); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
} while (/*CONSTCOND*/ 0)
+]b4_yysymprint_generate([b4_c_function_def])[
+
/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included). |
`------------------------------------------------*/
]b4_c_function_def([yy_reduce_print], [static void],
- [[int yyrule], [yyrule]])[
+ [[YYSTYPE *yyvsp], [yyvsp]],
+ b4_location_if([[[YYLTYPE *yylsp], [yylsp]],])
+ [[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,])
+ b4_parse_param)[
{
+ int yynrhs = yyr2[yyrule];
int yyi;
unsigned long int yylno = yyrline[yyrule];
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
yyrule - 1, yylno);
- /* Print the symbols being reduced, and their result. */
- for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
- YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
- YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ fprintf (stderr, " $%d = ", yyi + 1);
+ yysymprint (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &]b4_rhs_value(yynrhs, yyi + 1)[
+ ]b4_location_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
+ b4_user_args[);
+ fprintf (stderr, "\n");
+ }
}
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
- yy_reduce_print (Rule); \
+ yy_reduce_print (yyvsp, ]b4_location_if([yylsp, ])[Rule]b4_user_args[); \
} while (/*CONSTCOND*/ 0)
/* Nonzero means print parse trace. It is left uninitialized so that
# else
/* Return the length of YYSTR. */
static YYSIZE_T
-# if defined (__STDC__) || defined (__cplusplus)
+# if YYMODERN_C
yystrlen (const char *yystr)
# else
yystrlen (yystr)
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
YYDEST. */
static char *
-# if defined (__STDC__) || defined (__cplusplus)
+# if YYMODERN_C
yystpcpy (char *yydest, const char *yysrc)
# else
yystpcpy (yydest, yysrc)
#endif /* YYERROR_VERBOSE */
\f
-#if YYDEBUG
-]b4_yysymprint_generate([b4_c_function_def])[
-#endif /* ! YYDEBUG */
-]b4_yydestruct_generate([b4_c_function_def])
+]b4_yydestruct_generate([b4_c_function_def])[
\f
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
+# if YYMODERN_C
int yyparse (void *YYPARSE_PARAM);
# else
int yyparse ();
# endif
#else /* ! YYPARSE_PARAM */
-b4_c_function_decl([yyparse], [int], b4_parse_param)
+]b4_c_function_decl([yyparse], [int], b4_parse_param)[
#endif /* ! YYPARSE_PARAM */
-m4_divert_push([KILL])# ======================== M4 code.
+]m4_divert_push([KILL])# ======================== M4 code.
# b4_declare_parser_variables
# ---------------------------
# Declare the variables that are global, or local to YYPARSE if
`----------*/
#ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
+# if YYMODERN_C
int yyparse (void *YYPARSE_PARAM)
# else
int yyparse (YYPARSE_PARAM)
YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen);]])[
YY_REDUCE_PRINT (yyn);
switch (yyn)
- ]{
- b4_actions
+ {
+ ]b4_actions[
default: break;
}
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
/* Line __line__ of yacc.c. */
-b4_syncline([@oline@], [@ofile@])
+]b4_syncline([@oline@], [@ofile@])[
\f
-[ yyvsp -= yylen;
+ yyvsp -= yylen;
yyssp -= yylen;
]b4_location_if([ yylsp -= yylen;])[
}
else
{
- yydestruct ("Error: discarding", yytoken, &yylval]b4_location_if([, &yylloc])[);
+ yydestruct ("Error: discarding",
+ yytoken, &yylval]b4_location_if([, &yylloc])[]b4_user_args[);
yychar = YYEMPTY;
}
}
YYABORT;
]b4_location_if([[ yyerror_range[0] = *yylsp;]])[
- yydestruct ("Error: popping", yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp]b4_location_if([, yylsp])[]b4_user_args[);
YYPOPSTACK;
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
yyreturn:
if (yychar != YYEOF && yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval]b4_location_if([, &yylloc])[);
+ yytoken, &yylval]b4_location_if([, &yylloc])[]b4_user_args[);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
+ yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[]b4_user_args[);
YYPOPSTACK;
}
#ifndef yyoverflow