# 02110-1301 USA
m4_include(b4_pkgdatadir/[c++.m4])
+
+# The header is mandatory.
+b4_defines_if([],
+ [m4_fatal(b4_skeleton[: using %defines is mandatory])])
+
# Backward compatibility.
m4_define([b4_location_constructors])
m4_include(b4_pkgdatadir/[location.cc])
# We do want M4 expansion after # for CPP macros.
m4_changecom()
m4_divert(0)dnl
-m4_if(b4_defines_flag, 0, [],
+b4_defines_if(
[@output @output_header_name@
-b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
- [2002, 2003, 2004, 2005, 2006])
+b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
+ [2002, 2003, 2004, 2005, 2006])
dnl FIXME: This is wrong, we want computed header guards.
[
/* C++ LALR(1) parser skeleton written by Akim Demaille. */
#include <iostream>
#include "stack.hh"
-namespace yy
+namespace ]b4_namespace[
{
class position;
class location;
/* Enabling traces. */
#ifndef YYDEBUG
-# define YYDEBUG ]b4_debug[
+# define YYDEBUG ]b4_debug_flag[
#endif
/* Enabling verbose error messages. */
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
-# define YYERROR_VERBOSE ]b4_error_verbose[
+# define YYERROR_VERBOSE ]b4_error_verbose_flag[
#endif
/* Enabling the token table. */
} while (false)
#endif
-namespace yy
+namespace ]b4_namespace[
{
/// A Bison parser.
{
]b4_token_enums(b4_tokens)[
};
+ /// Token type.
+ typedef token::yytokentype token_type;
/// Build a parser object.
]b4_parser_class_name[ (]b4_parse_param_decl[);
virtual void yystack_print_ ();
#endif
- /// Convert a scanner token number to a symbol number.
- token_number_type yytranslate_ (int token);
+ /// Convert a scanner token number \a t to a symbol number.
+ token_number_type yytranslate_ (int t);
/// \brief Reclaim the memory associated to a symbol.
/// \param yymsg Why this token is reclaimed.
#ifndef YYSTYPE
/* Redirection for backward compatibility. */
-# define YYSTYPE yy::b4_parser_class_name::semantic_type
+# define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type
#endif
])[
#endif /* ! defined PARSER_HEADER_H */]
])dnl
@output @output_parser_name@
-b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
- [2002, 2003, 2004, 2005, 2006])
-m4_if(b4_prefix[], [yy], [],
+b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++],
+ [2002, 2003, 2004, 2005, 2006])
+m4_if(b4_prefix, [yy], [],
[
// Take the name prefix into account.
#define yylex b4_prefix[]lex])
-m4_if(b4_defines_flag, 0, [],
-[
+b4_defines_if([
#include @output_header_name@])[
/* User implementation prologue. */
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
-#if YYERROR_VERBOSE
-
-/* Return YYSTR after stripping away unnecessary quotes and
- backslashes, so that it's suitable for yyerror. The heuristic is
- that double-quoting is unnecessary unless the string contains an
- apostrophe, a comma, or backslash (other than backslash-backslash).
- YYSTR is taken from yytname. */
-std::string
-yy::]b4_parser_class_name[::yytnamerr_ (const char *yystr)
+namespace ]b4_namespace[
{
- if (*yystr == '"')
- {
- std::string yyr = "";
- char const *yyp = yystr;
+#if YYERROR_VERBOSE
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- yyr += *yyp;
- break;
-
- case '"':
- return yyr;
- }
- do_not_strip_quotes: ;
- }
+ /* Return YYSTR after stripping away unnecessary quotes and
+ backslashes, so that it's suitable for yyerror. The heuristic is
+ that double-quoting is unnecessary unless the string contains an
+ apostrophe, a comma, or backslash (other than backslash-backslash).
+ YYSTR is taken from yytname. */
+ std::string
+ ]b4_parser_class_name[::yytnamerr_ (const char *yystr)
+ {
+ if (*yystr == '"')
+ {
+ std::string yyr = "";
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ yyr += *yyp;
+ break;
+
+ case '"':
+ return yyr;
+ }
+ do_not_strip_quotes: ;
+ }
- return yystr;
-}
+ return yystr;
+ }
#endif
-namespace yy
-{
/// Build a parser object.
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)
: yydebug_ (false),
YYCDEBUG << "Reading a token: ";
yychar = ]b4_c_function_call([yylex], [int],
[[YYSTYPE*], [&yylval]][]dnl
-b4_location_if([, [[location*], [&yylloc]]])dnl
+b4_locations_if([, [[location*], [&yylloc]]])dnl
m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
}
YYUSE (yystate);
#if YYERROR_VERBOSE
int yyn = yypact_[yystate];
- if (yypact_ninf_ < yyn && yyn < yylast_)
+ if (yypact_ninf_ < yyn && yyn <= yylast_)
{
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
- int yychecklim = yylast_ - yyn;
+ int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
int count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
]b4_parser_class_name[::token_number_type
- ]b4_parser_class_name[::yytranslate_ (int token)
+ ]b4_parser_class_name[::yytranslate_ (int t)
{
static
const token_number_type
{
]b4_translate[
};
- if ((unsigned int) token <= yyuser_token_number_max_)
- return translate_table[token];
+ if ((unsigned int) t <= yyuser_token_number_max_)
+ return translate_table[t];
else
return yyundef_token_;
}
const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[;
const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
-} // namespace yy
+} // namespace ]b4_namespace[
]b4_epilogue
dnl
@output b4_dir_prefix[]stack.hh
-b4_copyright([stack handling for Bison C++ parsers],
+b4_copyright([Stack handling for Bison parsers in C++],
[2002, 2003, 2004, 2005, 2006])[
#ifndef BISON_STACK_HH
#include <deque>
-namespace yy
+namespace ]b4_namespace[
{
template <class T, class S = std::deque<T> >
class stack