[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Remove lineno uses
From: |
Akim Demaille |
Subject: |
Remove lineno uses |
Date: |
09 Jul 2002 17:52:29 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) |
Index: ChangeLog
from Akim Demaille <address@hidden>
* 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.
Index: src/complain.c
===================================================================
RCS file: /cvsroot/bison/bison/src/complain.c,v
retrieving revision 1.9
diff -u -u -r1.9 complain.c
--- src/complain.c 15 Jun 2002 18:21:46 -0000 1.9
+++ src/complain.c 9 Jul 2002 15:50:08 -0000
@@ -159,55 +159,6 @@
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 @@
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 @@
#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);
Index: src/complain.h
===================================================================
RCS file: /cvsroot/bison/bison/src/complain.h,v
retrieving revision 1.7
diff -u -u -r1.7 complain.h
--- src/complain.h 15 Jun 2002 18:21:46 -0000 1.7
+++ src/complain.h 9 Jul 2002 15:50:08 -0000
@@ -29,17 +29,11 @@
/* 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 @@
__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 @@
/* 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;
Index: src/main.c
===================================================================
RCS file: /cvsroot/bison/bison/src/main.c,v
retrieving revision 1.59
diff -u -u -r1.59 main.c
--- src/main.c 2 Jul 2002 13:51:26 -0000 1.59
+++ src/main.c 9 Jul 2002 15:50:11 -0000
@@ -51,7 +51,6 @@
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- lineno = 0;
getargs (argc, argv);
if (trace_flag)
Index: src/parse-gram.y
===================================================================
RCS file: /cvsroot/bison/bison/src/parse-gram.y,v
retrieving revision 1.18
diff -u -u -r1.18 parse-gram.y
--- src/parse-gram.y 9 Jul 2002 14:48:01 -0000 1.18
+++ src/parse-gram.y 9 Jul 2002 15:50:20 -0000
@@ -304,14 +304,14 @@
{
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, @$);
}
;
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.204
diff -u -u -r1.204 reader.c
--- src/reader.c 9 Jul 2002 14:48:01 -0000 1.204
+++ src/reader.c 9 Jul 2002 15:50:23 -0000
@@ -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 @@
`-------------------------------------------------------------------*/
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 @@
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 @@
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 @@
reader (void)
{
gram_control_t gram_control;
- lineno = 1;
/* Initialize the symbol table. */
symbols_new ();
Index: src/scan-gram.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-gram.l,v
retrieving revision 1.20
diff -u -u -r1.20 scan-gram.l
--- src/scan-gram.l 3 Jul 2002 06:52:02 -0000 1.20
+++ src/scan-gram.l 9 Jul 2002 15:50:39 -0000
@@ -39,7 +39,7 @@
} 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
Index: src/symtab.c
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.c,v
retrieving revision 1.43
diff -u -u -r1.43 symtab.c
--- src/symtab.c 3 Jul 2002 06:52:02 -0000 1.43
+++ src/symtab.c 9 Jul 2002 15:50:45 -0000
@@ -238,13 +238,13 @@
`-------------------------------------------------------------------*/
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 @@
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 @@
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 @@
{
/* 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;
}
Index: src/symtab.h
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.h,v
retrieving revision 1.41
diff -u -u -r1.41 symtab.h
--- src/symtab.h 30 Jun 2002 17:34:52 -0000 1.41
+++ src/symtab.h 9 Jul 2002 15:50:48 -0000
@@ -99,7 +99,8 @@
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. */
Index: tests/regression.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/regression.at,v
retrieving revision 1.58
diff -u -u -r1.58 regression.at
--- tests/regression.at 30 Jun 2002 17:35:06 -0000 1.58
+++ tests/regression.at 9 Jul 2002 15:50:48 -0000
@@ -100,7 +100,7 @@
]])
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.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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Remove lineno uses,
Akim Demaille <=