Changed error-messages mechanism
authorceriel <none@none>
Wed, 27 Nov 1991 13:40:52 +0000 (13:40 +0000)
committerceriel <none@none>
Wed, 27 Nov 1991 13:40:52 +0000 (13:40 +0000)
lang/m2/comp/BigPars
lang/m2/comp/LLlex.c
lang/m2/comp/LLlex.h
lang/m2/comp/LLmessage.c
lang/m2/comp/SmallPars
lang/m2/comp/error.c

index 5bc9860..66a6240 100644 (file)
@@ -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  */
index e047bd7..15c27ff 100644 (file)
@@ -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;
index 1f37922..a91a76d 100644 (file)
@@ -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;
index c45403f..232cc98 100644 (file)
@@ -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;
 }
 
index fc77413..13f9870 100644 (file)
@@ -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
index e3f4041..da84872 100644 (file)
@@ -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);