Prefer M4 to CPP.

* data/lalr1.cc: Use b4_error_verbose_if instead of #if
	YYERROR_VERBOSE.
(cherry picked from commit 422c18f48d)
This commit is contained in:
Akim Demaille
2008-08-21 22:04:27 +02:00
committed by Joel E. Denny
parent e657f3698e
commit 39f6a8d142
2 changed files with 16 additions and 15 deletions

View File

@@ -1,3 +1,9 @@
2008-11-11 Akim Demaille <demaille@gostai.com>
Prefer M4 to CPP.
* data/lalr1.cc: Use b4_error_verbose_if instead of #if
YYERROR_VERBOSE.
2008-11-11 Akim Demaille <demaille@gostai.com> 2008-11-11 Akim Demaille <demaille@gostai.com>
Support i18n of the parse error messages. Support i18n of the parse error messages.

View File

@@ -233,12 +233,10 @@ b4_user_stype
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
/// For a symbol, its name in clear. /// For a symbol, its name in clear.
static const char* const yytname_[]; static const char* const yytname_[];
#endif #endif]b4_error_verbose_if([
#if YYERROR_VERBOSE
/// Convert the symbol name \a n to a form suitable for a diagnostic. /// Convert the symbol name \a n to a form suitable for a diagnostic.
virtual std::string yytnamerr_ (const char *n); static std::string yytnamerr_ (const char *n);])[
#endif
#if YYDEBUG #if YYDEBUG
/// A type to store symbol numbers and -1. /// A type to store symbol numbers and -1.
@@ -384,8 +382,7 @@ do { \
#define YYERROR goto yyerrorlab #define YYERROR goto yyerrorlab
#define YYRECOVERING() (!!yyerrstatus_) #define YYRECOVERING() (!!yyerrstatus_)
]b4_namespace_open[ ]b4_namespace_open[]b4_error_verbose_if([[
#if YYERROR_VERBOSE
/* Return YYSTR after stripping away unnecessary quotes and /* Return YYSTR after stripping away unnecessary quotes and
backslashes, so that it's suitable for yyerror. The heuristic is backslashes, so that it's suitable for yyerror. The heuristic is
@@ -423,8 +420,7 @@ do { \
return yystr; return yystr;
} }
]])[
#endif
/// Build a parser object. /// Build a parser object.
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [ ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
@@ -849,12 +845,11 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
// Generate an error message. // Generate an error message.
std::string std::string
]b4_parser_class_name[::yysyntax_error_ (int yystate, int]dnl ]b4_parser_class_name[::yysyntax_error_ (]dnl
b4_error_verbose_if([ yytoken])[) b4_error_verbose_if([int yystate, int yytoken],
[int, int])[)
{ {
std::string yyres; std::string yyres;]b4_error_verbose_if([[
YYUSE (yystate);
#if YYERROR_VERBOSE
int yyn = yypact_[yystate]; int yyn = yypact_[yystate];
if (yypact_ninf_ < yyn && yyn <= yylast_) if (yypact_ninf_ < yyn && yyn <= yylast_)
{ {
@@ -913,8 +908,8 @@ b4_error_verbose_if([ yytoken])[)
yyres += *yyp; yyres += *yyp;
} }
else else
#endif ]])dnl
yyres = YY_("syntax error"); [ yyres = YY_("syntax error");
return yyres; return yyres;
} }