Changed error-messages mechanism

This commit is contained in:
ceriel 1991-11-27 13:40:52 +00:00
parent 505494c560
commit bf0caa6f32
6 changed files with 21 additions and 29 deletions

View file

@ -1,8 +1,8 @@
!File: errout.h !File: errout.h
#define ERROUT STDERR /* file pointer for writing messages */ #define ERROUT STDERR /* file pointer for writing messages */
#define MAXERR_LINE 100 /* maximum number of error messages given #define ERR_SHADOW 5 /* a syntax error overshadows error messages
on the same input line. */ until ERR_SHADOW symbols have been
accepted without syntax error */
!File: idfsize.h !File: idfsize.h
#define IDFSIZE 128 /* maximum significant length of an identifier */ #define IDFSIZE 128 /* maximum significant length of an identifier */

View file

@ -28,6 +28,7 @@
#include "def.h" #include "def.h"
#include "type.h" #include "type.h"
#include "warning.h" #include "warning.h"
#include "errout.h"
extern char *getwdir(); extern char *getwdir();
@ -40,6 +41,9 @@ int ForeignFlag;
extern int cntlines; extern int cntlines;
#endif #endif
int token_nmb = 0;
int tk_nmb_at_last_syn_err = -ERR_SHADOW;
extern char options[]; extern char options[];
extern int flt_status; extern int flt_status;
@ -266,6 +270,7 @@ LLlex()
return tk->tk_symb; return tk->tk_symb;
} }
token_nmb++;
again: again:
ch = getch(); ch = getch();
tk->tk_lineno = LineNumber; tk->tk_lineno = LineNumber;

View file

@ -65,3 +65,6 @@ extern struct type *toktype;
#define DOT dot.tk_symb #define DOT dot.tk_symb
#define ASIDE aside.tk_symb #define ASIDE aside.tk_symb
extern int token_nmb;
extern int tk_nmb_at_last_syn_err;

View file

@ -65,5 +65,6 @@ LLmessage(tk)
error("garbage at end of program"); error("garbage at end of program");
} }
else error("%s deleted", symbol2str(dot.tk_symb)); else error("%s deleted", symbol2str(dot.tk_symb));
tk_nmb_at_last_syn_err = token_nmb;
} }

View file

@ -1,7 +1,8 @@
!File: errout.h !File: errout.h
#define ERROUT STDERR /* file pointer for writing messages */ #define ERROUT STDERR /* file pointer for writing messages */
#define MAXERR_LINE 100 /* maximum number of error messages given #define ERR_SHADOW 5 /* a syntax error overshadows error messages
on the same input line. */ until ERR_SHADOW symbols have been
accepted without syntax error */
!File: idfsize.h !File: idfsize.h

View file

@ -195,14 +195,17 @@ _error(class, node, ap)
/* _error attempts to limit the number of error messages /* _error attempts to limit the number of error messages
for a given line to MAXERR_LINE. for a given line to MAXERR_LINE.
*/ */
static unsigned int last_ln = 0;
unsigned int ln = 0; unsigned int ln = 0;
static char * last_fn = 0;
static int e_seen = 0;
register char *remark = 0; register char *remark = 0;
int warn_class; int warn_class;
char *fmt; char *fmt;
/* check visibility of message */
if (class == ERROR || class == WARNING) {
if (token_nmb < tk_nmb_at_last_syn_err + ERR_SHADOW)
/* warning or error message overshadowed */
return;
}
/* Since name and number are gathered from different places /* Since name and number are gathered from different places
depending on the class, we first collect the relevant depending on the class, we first collect the relevant
values and then decide what to print. values and then decide what to print.
@ -271,27 +274,6 @@ _error(class, node, ap)
} }
fmt = va_arg(ap, char *); fmt = va_arg(ap, char *);
#ifdef DEBUG
if (class != VDEBUG) {
#endif
if (FileName == last_fn && ln == last_ln) {
/* we've seen this place before */
e_seen++;
if (e_seen == MAXERR_LINE) fmt = "etc ...";
else
if (e_seen > MAXERR_LINE)
/* and too often, I'd say ! */
return;
}
else {
/* brand new place */
last_ln = ln;
last_fn = FileName;
e_seen = 0;
}
#ifdef DEBUG
}
#endif DEBUG
if (FileName) fprint(ERROUT, "\"%s\", line %u: ", FileName, ln); if (FileName) fprint(ERROUT, "\"%s\", line %u: ", FileName, ln);