mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
* 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.
This commit is contained in:
18
ChangeLog
18
ChangeLog
@@ -1,3 +1,13 @@
|
||||
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
|
||||
@@ -7737,19 +7747,19 @@
|
||||
|
||||
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.
|
||||
|
||||
101
src/complain.c
101
src/complain.c
@@ -159,55 +159,6 @@ warn_at (location, message, va_alist)
|
||||
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);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------.
|
||||
| An error has occurred, but we can proceed, and die later. |
|
||||
@@ -257,53 +208,6 @@ complain_at (location, message, va_alist)
|
||||
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);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------.
|
||||
| A severe error has occurred, we cannot proceed. |
|
||||
@@ -354,10 +258,7 @@ fatal (message, va_alist)
|
||||
#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);
|
||||
|
||||
|
||||
@@ -29,17 +29,11 @@ extern "C" {
|
||||
|
||||
/* 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)));
|
||||
|
||||
@@ -52,9 +46,7 @@ void fatal_at (location_t location, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
|
||||
# else
|
||||
void warn ();
|
||||
void warn_at ();
|
||||
void complain ();
|
||||
void complain_at ();
|
||||
void fatal ();
|
||||
void fatal_at ();
|
||||
@@ -62,7 +54,6 @@ 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;
|
||||
|
||||
@@ -51,7 +51,6 @@ main (int argc, char *argv[])
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
lineno = 0;
|
||||
getargs (argc, argv);
|
||||
|
||||
if (trace_flag)
|
||||
|
||||
@@ -1390,7 +1390,7 @@ yyreduce:
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -1400,7 +1400,7 @@ yyreduce:
|
||||
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;
|
||||
|
||||
|
||||
@@ -304,14 +304,14 @@ symbol_def:
|
||||
{
|
||||
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, @$);
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
27
src/reader.c
27
src/reader.c
@@ -34,7 +34,6 @@
|
||||
#include "conflicts.h"
|
||||
#include "muscle_tab.h"
|
||||
|
||||
int lineno;
|
||||
static symbol_list_t *grammar = NULL;
|
||||
static int start_flag = 0;
|
||||
merger_list *merge_functions;
|
||||
@@ -113,7 +112,8 @@ epilogue_set (const char *epilogue, location_t location)
|
||||
`-------------------------------------------------------------------*/
|
||||
|
||||
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;
|
||||
@@ -129,15 +129,17 @@ get_merge_function (const char* name, const char* type)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -367,7 +369,7 @@ grammar_current_rule_merge_set (const char* name, location_t location)
|
||||
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
|
||||
@@ -469,7 +471,6 @@ void
|
||||
reader (void)
|
||||
{
|
||||
gram_control_t gram_control;
|
||||
lineno = 1;
|
||||
|
||||
/* Initialize the symbol table. */
|
||||
symbols_new ();
|
||||
|
||||
@@ -768,7 +768,7 @@ do { \
|
||||
} 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
|
||||
|
||||
@@ -39,7 +39,7 @@ do { \
|
||||
} 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
|
||||
|
||||
23
src/symtab.c
23
src/symtab.c
@@ -238,13 +238,13 @@ symbol_check_defined (symbol_t *this)
|
||||
`-------------------------------------------------------------------*/
|
||||
|
||||
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
|
||||
{
|
||||
@@ -277,8 +277,9 @@ symbol_check_alias_consistence (symbol_t *this)
|
||||
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
|
||||
@@ -292,8 +293,9 @@ symbol_check_alias_consistence (symbol_t *this)
|
||||
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
|
||||
@@ -360,9 +362,10 @@ symbol_translation (symbol_t *this)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,8 @@ symbol_t *symbol_get PARAMS ((const char *key, location_t location));
|
||||
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. */
|
||||
|
||||
@@ -100,7 +100,7 @@ exp: '(' exp ')' | NUM ;
|
||||
]])
|
||||
|
||||
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
|
||||
@@ -299,7 +299,6 @@ input.y:6.1: invalid character: `%'
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user