* src/reader.c (lineno): Remove.
Adjust all dependencies.
(get_merge_function): Take a location and use complain_at.
* src/symtab.h, src/symtab.c (symbol_make_alias): Likewise.
* tests/regression.at (Invalid inputs, Mixing %token styles):
Adjust.
+2002-07-09 Akim Demaille <akim@epita.fr>
+
+ * src/complain.h, src/complain.c (warn, complain): Remove, unused.
+ * src/reader.c (lineno): Remove.
+ Adjust all dependencies.
+ (get_merge_function): Take a location and use complain_at.
+ * src/symtab.h, src/symtab.c (symbol_make_alias): Likewise.
+ * tests/regression.at (Invalid inputs, Mixing %token styles):
+ Adjust.
+
2002-07-09 Akim Demaille <akim@epita.fr>
* src/parse-gram.y (rules_or_grammar_declaration): Add an error
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
-This file is part of GNU Autoconf.
+This file is part of GNU Bison.
-GNU Autoconf is free software; you can redistribute it and/or modify
+GNU Bison 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.
-GNU Autoconf is distributed in the hope that it will be useful,
+GNU Bison 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 autoconf; see the file COPYING. If not, write to
+along with GNU Bison; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
putc ('\n', stderr);
fflush (stderr);
}
-
-
-void
-#if defined VA_START && defined __STDC__
-warn (const char *message, ...)
-#else
-warn (message, va_alist)
- char *message;
- va_dcl
-#endif
-{
-#ifdef VA_START
- va_list args;
-#endif
-
- if (error_one_per_line)
- {
- static const char *old_infile;
- static int old_lineno;
-
- if (old_lineno == lineno &&
- (infile == old_infile || !strcmp (old_infile, infile)))
- /* Simply return and print nothing. */
- return;
-
- old_infile = infile;
- old_lineno = lineno;
- }
-
- fflush (stdout);
- if (infile != NULL)
- fprintf (stderr, "%s:%d: ", infile, lineno);
- else
- fprintf (stderr, "%s:", program_name);
-
- fputs (_("warning: "), stderr);
-
-#ifdef VA_START
- VA_START (args, message);
- vfprintf (stderr, message, args);
- va_end (args);
-#else
- fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
-#endif
-
- ++warn_message_count;
- putc ('\n', stderr);
- fflush (stderr);
-}
\f
/*-----------------------------------------------------------.
| An error has occurred, but we can proceed, and die later. |
putc ('\n', stderr);
fflush (stderr);
}
-
-
-void
-#if defined VA_START && defined __STDC__
-complain (const char *message, ...)
-#else
-complain (message, va_alist)
- char *message;
- va_dcl
-#endif
-{
-#ifdef VA_START
- va_list args;
-#endif
-
- if (error_one_per_line)
- {
- static const char *old_infile;
- static int old_lineno;
-
- if (old_lineno == lineno &&
- (infile == old_infile || !strcmp (old_infile, infile)))
- /* Simply return and print nothing. */
- return;
-
- old_infile = infile;
- old_lineno = lineno;
- }
-
- fflush (stdout);
- if (infile != NULL)
- fprintf (stderr, "%s:%d: ", infile, lineno);
- else
- fprintf (stderr, "%s:", program_name);
-
-#ifdef VA_START
- VA_START (args, message);
- vfprintf (stderr, message, args);
- va_end (args);
-#else
- fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
-#endif
-
- ++complain_message_count;
- putc ('\n', stderr);
- fflush (stderr);
-}
\f
/*-------------------------------------------------.
| A severe error has occurred, we cannot proceed. |
#endif
fflush (stdout);
- if (infile != NULL)
- fprintf (stderr, "%s:%d: ", infile, lineno);
- else
- fprintf (stderr, "%s:", program_name);
+ fprintf (stderr, "%s: ", infile ? infile : program_name);
fputs (_("fatal error: "), stderr);
/* Informative messages, but we proceed. */
-void warn (const char *format, ...)
- __attribute__ ((__format__ (__printf__, 1, 2)));
-
void warn_at (location_t location, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
/* Something bad happen, but let's continue and die later. */
-void complain (const char *format, ...)
- __attribute__ ((__format__ (__printf__, 1, 2)));
-
void complain_at (location_t location, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
__attribute__ ((__format__ (__printf__, 2, 3)));
# else
-void warn ();
void warn_at ();
-void complain ();
void complain_at ();
void fatal ();
void fatal_at ();
/* Position in the current input file. */
extern char *infile;
-extern int lineno;
/* This variable is incremented each time `warn' is called. */
extern unsigned int warn_message_count;
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- lineno = 0;
getargs (argc, argv);
if (trace_flag)
{
symbol_class_set (yyvsp[-1].symbol, current_class, yylsp[-1]);
symbol_type_set (yyvsp[-1].symbol, current_type, yylsp[-1]);
- symbol_make_alias (yyvsp[-1].symbol, yyvsp[0].symbol);
+ symbol_make_alias (yyvsp[-1].symbol, yyvsp[0].symbol, yyloc);
}
break;
symbol_class_set (yyvsp[-2].symbol, current_class, yylsp[-2]);
symbol_type_set (yyvsp[-2].symbol, current_type, yylsp[-2]);
symbol_user_token_number_set (yyvsp[-2].symbol, yyvsp[-1].integer, yylsp[-1]);
- symbol_make_alias (yyvsp[-2].symbol, yyvsp[0].symbol);
+ symbol_make_alias (yyvsp[-2].symbol, yyvsp[0].symbol, yyloc);
}
break;
{
symbol_class_set ($1, current_class, @1);
symbol_type_set ($1, current_type, @1);
- symbol_make_alias ($1, $2);
+ symbol_make_alias ($1, $2, @$);
}
| ID INT string_as_id
{
symbol_class_set ($1, current_class, @1);
symbol_type_set ($1, current_type, @1);
symbol_user_token_number_set ($1, $2, @2);
- symbol_make_alias ($1, $3);
+ symbol_make_alias ($1, $3, @$);
}
;
#include "conflicts.h"
#include "muscle_tab.h"
-int lineno;
static symbol_list_t *grammar = NULL;
static int start_flag = 0;
merger_list *merge_functions;
`-------------------------------------------------------------------*/
static int
-get_merge_function (const char* name, const char* type)
+get_merge_function (const char* name, const char* type,
+ location_t loc)
{
merger_list *syms;
merger_list head;
for (syms = &head, n = 1; syms->next != NULL; syms = syms->next, n += 1)
if (strcmp (name, syms->next->name) == 0)
break;
- if (syms->next == NULL) {
- syms->next = XMALLOC (merger_list, 1);
- syms->next->name = strdup (name);
- syms->next->type = strdup (type);
- syms->next->next = NULL;
- merge_functions = head.next;
- } else if (strcmp (type, syms->next->type) != 0)
- warn (_("result type clash on merge function %s: `%s' vs. `%s'"),
- name, type, syms->next->type);
+ if (syms->next == NULL)
+ {
+ syms->next = XMALLOC (merger_list, 1);
+ syms->next->name = strdup (name);
+ syms->next->type = strdup (type);
+ syms->next->next = NULL;
+ merge_functions = head.next;
+ }
+ else if (strcmp (type, syms->next->type) != 0)
+ warn_at (loc, _("result type clash on merge function %s: `%s' vs. `%s'"),
+ name, type, syms->next->type);
return n;
}
if (current_rule->merger != 0)
complain_at (location, _("only one %%merge allowed per rule"));
current_rule->merger =
- get_merge_function (name, current_rule->sym->type_name);
+ get_merge_function (name, current_rule->sym->type_name, location);
}
/* Attach a SYMBOL to the current rule. If needed, move the previous
reader (void)
{
gram_control_t gram_control;
- lineno = 1;
/* Initialize the symbol table. */
symbols_new ();
} while (0)
#define YY_USER_ACTION LOCATION_COLUMNS (*yylloc, yyleng)
-#define YY_LINES LOCATION_LINES (*yylloc, yyleng); lineno += yyleng;
+#define YY_LINES LOCATION_LINES (*yylloc, yyleng);
#define YY_STEP LOCATION_STEP (*yylloc)
/* STRING_OBSTACK -- Used to store all the characters that we need to
} while (0)
#define YY_USER_ACTION LOCATION_COLUMNS (*yylloc, yyleng)
-#define YY_LINES LOCATION_LINES (*yylloc, yyleng); lineno += yyleng;
+#define YY_LINES LOCATION_LINES (*yylloc, yyleng);
#define YY_STEP LOCATION_STEP (*yylloc)
/* STRING_OBSTACK -- Used to store all the characters that we need to
`-------------------------------------------------------------------*/
void
-symbol_make_alias (symbol_t *symbol, symbol_t *symval)
+symbol_make_alias (symbol_t *symbol, symbol_t *symval, location_t loc)
{
if (symval->alias)
- warn (_("symbol `%s' used more than once as a literal string"),
+ warn_at (loc, _("symbol `%s' used more than once as a literal string"),
symval->tag);
else if (symbol->alias)
- warn (_("symbol `%s' given more than one literal string"),
+ warn_at (loc, _("symbol `%s' given more than one literal string"),
symbol->tag);
else
{
if (this->prec != this->alias->prec)
{
if (this->prec != 0 && this->alias->prec != 0)
- complain (_("conflicting precedences for %s and %s"),
- this->tag, this->alias->tag);
+ complain_at (this->alias->location,
+ _("conflicting precedences for %s and %s"),
+ this->tag, this->alias->tag);
if (this->prec != 0)
this->alias->prec = this->prec;
else
not nice, fix this! */
if (this->assoc != right_assoc
&& this->alias->assoc != right_assoc)
- complain (_("conflicting associativities for %s and %s"),
- this->tag, this->alias->tag);
+ complain_at (this->alias->location,
+ _("conflicting associativities for %s and %s"),
+ this->tag, this->alias->tag);
if (this->assoc != 0)
this->alias->assoc = this->assoc;
else
{
/* A token which translation has already been set? */
if (token_translations[this->user_token_number] != undeftoken->number)
- complain (_("tokens %s and %s both assigned number %d"),
- symbols[token_translations[this->user_token_number]]->tag,
- this->tag, this->user_token_number);
+ complain_at (this->location,
+ _("tokens %s and %s both assigned number %d"),
+ symbols[token_translations[this->user_token_number]]->tag,
+ this->tag, this->user_token_number);
token_translations[this->user_token_number] = this->number;
}
symbol_t *dummy_symbol_get PARAMS ((location_t location));
/* Declare the new SYMBOL. Make it an alias of SYMVAL. */
-void symbol_make_alias PARAMS ((symbol_t *symbol, symbol_t *symval));
+void symbol_make_alias PARAMS ((symbol_t *symbol, symbol_t *symval,
+ location_t location));
/* Set the TYPE_NAME associated to SYMBOL. Does nothing if passed 0 as
TYPE_NAME. */
]])
AT_CHECK([bison -v input.y -o input.c], 0, [],
-[[input.y:6: warning: symbol `"<="' used more than once as a literal string
+[[input.y:6.8-14: warning: symbol `"<="' used more than once as a literal string
]])
AT_CLEANUP
input.y:6.2: invalid character: `-'
input.y:7.1-8.0: unexpected end of file in a prologue
input.y:7.1-8.0: parse error, unexpected PROLOGUE, expecting ";" or "|"
-input.y:5.2: symbol a is used, but is not defined as a token and has no rules
]])
AT_CLEANUP