diff --git a/lang/m2/comp/BigPars b/lang/m2/comp/BigPars index 5bc986017..66a624018 100644 --- a/lang/m2/comp/BigPars +++ b/lang/m2/comp/BigPars @@ -1,8 +1,8 @@ !File: errout.h #define ERROUT STDERR /* file pointer for writing messages */ -#define MAXERR_LINE 100 /* maximum number of error messages given - on the same input line. */ - +#define ERR_SHADOW 5 /* a syntax error overshadows error messages + until ERR_SHADOW symbols have been + accepted without syntax error */ !File: idfsize.h #define IDFSIZE 128 /* maximum significant length of an identifier */ diff --git a/lang/m2/comp/LLlex.c b/lang/m2/comp/LLlex.c index e047bd776..15c27ff40 100644 --- a/lang/m2/comp/LLlex.c +++ b/lang/m2/comp/LLlex.c @@ -28,6 +28,7 @@ #include "def.h" #include "type.h" #include "warning.h" +#include "errout.h" extern char *getwdir(); @@ -40,6 +41,9 @@ int ForeignFlag; extern int cntlines; #endif +int token_nmb = 0; +int tk_nmb_at_last_syn_err = -ERR_SHADOW; + extern char options[]; extern int flt_status; @@ -266,6 +270,7 @@ LLlex() return tk->tk_symb; } + token_nmb++; again: ch = getch(); tk->tk_lineno = LineNumber; diff --git a/lang/m2/comp/LLlex.h b/lang/m2/comp/LLlex.h index 1f379227f..a91a76de9 100644 --- a/lang/m2/comp/LLlex.h +++ b/lang/m2/comp/LLlex.h @@ -65,3 +65,6 @@ extern struct type *toktype; #define DOT dot.tk_symb #define ASIDE aside.tk_symb + +extern int token_nmb; +extern int tk_nmb_at_last_syn_err; diff --git a/lang/m2/comp/LLmessage.c b/lang/m2/comp/LLmessage.c index c45403f63..232cc98b4 100644 --- a/lang/m2/comp/LLmessage.c +++ b/lang/m2/comp/LLmessage.c @@ -65,5 +65,6 @@ LLmessage(tk) error("garbage at end of program"); } else error("%s deleted", symbol2str(dot.tk_symb)); + tk_nmb_at_last_syn_err = token_nmb; } diff --git a/lang/m2/comp/SmallPars b/lang/m2/comp/SmallPars index fc7741399..13f987082 100644 --- a/lang/m2/comp/SmallPars +++ b/lang/m2/comp/SmallPars @@ -1,7 +1,8 @@ !File: errout.h #define ERROUT STDERR /* file pointer for writing messages */ -#define MAXERR_LINE 100 /* maximum number of error messages given - on the same input line. */ +#define ERR_SHADOW 5 /* a syntax error overshadows error messages + until ERR_SHADOW symbols have been + accepted without syntax error */ !File: idfsize.h diff --git a/lang/m2/comp/error.c b/lang/m2/comp/error.c index e3f4041fe..da84872b4 100644 --- a/lang/m2/comp/error.c +++ b/lang/m2/comp/error.c @@ -195,14 +195,17 @@ _error(class, node, ap) /* _error attempts to limit the number of error messages for a given line to MAXERR_LINE. */ - static unsigned int last_ln = 0; unsigned int ln = 0; - static char * last_fn = 0; - static int e_seen = 0; register char *remark = 0; int warn_class; 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 depending on the class, we first collect the relevant values and then decide what to print. @@ -271,27 +274,6 @@ _error(class, node, ap) } 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);