# 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. */
class location;
}
-/* First part of user declarations. */
-]b4_pre_prologue[
+]m4_ifdef([b4_start_header],
+[[/* Copy the %start-header blocks. */
+]b4_start_header])[]dnl
-]/* Line __line__ of lalr1.cc. */
-b4_syncline([@oline@], [@ofile@])[
+[/* Line __line__ of lalr1.cc. */
+]b4_syncline([@oline@], [@ofile@])[
]dnl Include location.hh here: it might depend on headers included above.
[#include "location.hh"
/* 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. */
/// Generate an error message.
/// \param state the state where the error occurred.
- /// \param tok the look-ahead token.
+ /// \param tok the lookahead token.
virtual std::string yysyntax_error_ (int yystate]dnl
b4_error_verbose_if([, int tok])[);
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.
/* Redirection for backward compatibility. */
# define YYSTYPE b4_namespace::b4_parser_class_name::semantic_type
#endif
-])[
-#endif /* ! defined PARSER_HEADER_H */]
+])
+m4_ifdef([b4_end_header],
+[[/* Copy the %end-header blocks. */
+]b4_end_header])[]dnl
+
+[#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])
+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, [],
-[
+#define yylex b4_prefix[]lex])[
+
+/* First part of user declarations. */
+]b4_pre_prologue
+
+b4_defines_if([
#include @output_header_name@])[
/* User implementation prologue. */
{
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;
default:
yyr += *yyp;
break;
-
+
case '"':
return yyr;
}
do_not_strip_quotes: ;
}
-
+
return yystr;
}
int
]b4_parser_class_name[::parse ()
{
- /// Look-ahead and look-ahead in internal form.
+ /// Lookahead and lookahead in internal form.
int yychar = yyempty_;
int yytoken = 0;
int yynerrs_ = 0;
int yyerrstatus_ = 0;
- /// Semantic value of the look-ahead.
+ /// Semantic value of the lookahead.
semantic_type yylval;
- /// Location of the look-ahead.
+ /// Location of the lookahead.
location_type yylloc;
/// The locations where the error started and ended.
location yyerror_range[2];
/* Backup. */
yybackup:
- /* Try to take a decision without look-ahead. */
+ /* Try to take a decision without lookahead. */
yyn = yypact_[yystate];
if (yyn == yypact_ninf_)
goto yydefault;
- /* Read a look-ahead token. */
+ /* Read a lookahead token. */
if (yychar == yyempty_)
{
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))[;
}
if (yyn == yyfinal_)
goto yyacceptlab;
- /* Shift the look-ahead token. */
+ /* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the token being shifted unless it is eof. */
yyerror_range[0] = yylloc;
if (yyerrstatus_ == 3)
{
- /* If just tried and failed to reuse look-ahead token after an
+ /* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= yyeof_)
}
}
- /* Else will try to reuse look-ahead token after shifting the error
+ /* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
yyerror_range[1] = yylloc;
// Using YYLLOC is tempting, but would change the location of
- // the look-ahead. YYLOC is available though.
+ // the lookahead. YYLOC is available though.
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
yysemantic_stack_.push (yylval);
yylocation_stack_.push (yyloc);
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_;
}
]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