Files
bison/src/complain.c
Paul Eggert 0e021770cc * src/getargs.c (skeleton_arg): Last arg is now location const *.
Rewrite to simplify the logic.
(language_argmatch): Likewise.

* doc/bison.texinfo (Decl Summary, Bison Options): Don't claim
Java is supported.
* src/complain.c (program_name): Remove decl; no longer needed.
* src/main.c (program_name): Remove; now belongs to getargs.

2006-12-18  Paolo Bonzini  <bonzini@gnu.org>

* NEWS: Document %language.

* data/Makefile.am (dist_pkgdata_DATA): Add c-skel.m4, c++-skel.m4.

* data/c-skel.m4, data/c++-skel.m4: New files.
* data/glr.c: Complain on push parsers.

* doc/bison.texinfo (C++ Parser Interface): Prefer %language
over %skeleton.
(Directives): Document %language and %skeleton.
(Command line): Document -L.

* examples/extexi: Rewrite %require directive.
* examples/calc++/Makefile.am: Pass VERSION to extexi.

* src/files.c (compute_exts_from_gc): Look in language structure
for .y extension.
(compute_file_name_parts): Check whether .tab should be added.
* src/getargs.c (valid_languages, skeleton_prio, language_prio):
(language, skeleton_arg, language_argmatch): New.
(long_options): Add --language.
(getargs): Use skeleton_arg, add -L/--language.
* src/getargs.h: Include location.h.
(struct bison_language, language, skeleton_arg, language_argmatch): New.
* src/output.c (prepare): Pick default skeleton from struct language.
Don't dispatch C skeletons here.
* src/parse-gram.y (PERCENT_LANGUAGE): New.
(prologue_declaration): Add "%language" rule, use skeleton_arg.
* src/scan-gram.l ("%language"): New rule.

* tests/calc.at: Test %skeleton and %language.
* tests/local.at (AT_SKEL_CC_IF): Look for %language.
(AT_GLR_IF): Look for %skeleton "glr.cc".
(AT_LALR1_CC_IF, AT_GLR_CC_IF): Rewrite.
(AT_YACC_IF): Reject %language.

2006-12-18  Paul Eggert  <eggert@cs.ucla.edu>
2006-12-19 00:34:37 +00:00

142 lines
3.4 KiB
C
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* Declaration for error-reporting function for Bison.
Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006
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 the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA. */
/* Based on error.c and error.h,
written by David MacKenzie <djm@gnu.ai.mit.edu>. */
#include <config.h>
#include "system.h"
#include <stdarg.h>
#include "complain.h"
#include "files.h"
#include "getargs.h"
bool complaint_issued;
/** Report an error message.
*
* \param loc the location, defaulting to the current file,
* or the program name.
* \param prefix put before the message (e.g., "warning").
* \param message the error message, a printf format string.
* \param args the arguments of the format string.
*/
static
void
error_message (location *loc,
const char *prefix,
const char *message, va_list args)
{
if (loc)
location_print (stderr, *loc);
else
fputs (current_file ? current_file : program_name, stderr);
fputs (": ", stderr);
if (prefix)
fprintf (stderr, "%s: ", prefix);
vfprintf (stderr, message, args);
va_end (args);
putc ('\n', stderr);
fflush (stderr);
}
/** Wrap error_message() with varargs handling. */
#define ERROR_MESSAGE(Loc, Prefix, Message) \
{ \
va_list args; \
va_start (args, Message); \
error_message (Loc, Prefix, Message, args); \
}
/*--------------------------------.
| Report a warning, and proceed. |
`--------------------------------*/
static void
set_warning_issued (void)
{
static bool warning_issued = false;
if (!warning_issued && (warnings_flag & warnings_error))
{
fprintf (stderr, "%s: warnings being treated as errors\n", program_name);
complaint_issued = true;
}
warning_issued = true;
}
void
warn_at (location loc, const char *message, ...)
{
set_warning_issued ();
ERROR_MESSAGE (&loc, _("warning"), message);
}
void
warn (const char *message, ...)
{
set_warning_issued ();
ERROR_MESSAGE (NULL, _("warning"), message);
}
/*-----------------------------------------------------------.
| An error has occurred, but we can proceed, and die later. |
`-----------------------------------------------------------*/
void
complain_at (location loc, const char *message, ...)
{
ERROR_MESSAGE (&loc, NULL, message);
complaint_issued = true;
}
void
complain (const char *message, ...)
{
ERROR_MESSAGE (NULL, NULL, message);
complaint_issued = true;
}
/*-------------------------------------------------.
| A severe error has occurred, we cannot proceed. |
`-------------------------------------------------*/
void
fatal_at (location loc, const char *message, ...)
{
ERROR_MESSAGE (&loc, _("fatal error"), message);
exit (EXIT_FAILURE);
}
void
fatal (const char *message, ...)
{
ERROR_MESSAGE (NULL, _("fatal error"), message);
exit (EXIT_FAILURE);
}