From: dick Date: Mon, 30 Oct 1989 16:19:35 +0000 (+0000) Subject: better (more restrained) error reporting X-Git-Tag: release-5-5~2128 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=a817264e904e50b47485f45aa4a16175dccf6064;p=ack.git better (more restrained) error reporting --- diff --git a/lang/cem/cemcom/BigPars b/lang/cem/cemcom/BigPars index 08aaa58b3..b3b746eb4 100644 --- a/lang/cem/cemcom/BigPars +++ b/lang/cem/cemcom/BigPars @@ -8,8 +8,9 @@ !File: errout.h #define ERROUT STDERR /* file pointer for writing messages */ -#define MAXERR_LINE 5 /* 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/cem/cemcom/LLlex.c b/lang/cem/cemcom/LLlex.c index 3ed953f7f..aa71ca5f2 100644 --- a/lang/cem/cemcom/LLlex.c +++ b/lang/cem/cemcom/LLlex.c @@ -25,6 +25,9 @@ /* Data about the token yielded */ struct token dot, ahead, aside; +int token_nmb = 0; /* number of the ahead token */ +int tk_nmb_at_last_syn_err = -5/*ERR_SHADOW*/; + /* token number at last syntax error */ #ifndef NOPP int ReplaceMacros = 1; /* replacing macros */ @@ -105,6 +108,8 @@ GetToken(ptok) char buf[(IDFSIZE > NUMSIZE ? IDFSIZE : NUMSIZE) + 1]; register int ch, nch; + token_nmb++; + if (File_Inserted) { File_Inserted = 0; goto firstline; @@ -219,37 +224,6 @@ firstline: case '=': if (nch == '=') return ptok->tk_symb = EQUAL; - /* The following piece of code tries to recognise - old-fashioned assignment operators `=op' - */ - switch (nch) { - case '+': - return ptok->tk_symb = PLUSAB; - case '-': - return ptok->tk_symb = MINAB; - case '*': - return ptok->tk_symb = TIMESAB; - case '/': - return ptok->tk_symb = DIVAB; - case '%': - return ptok->tk_symb = MODAB; - case '>': - case '<': - LoadChar(ch); - if (ch != nch) { - PushBack(); - lexerror("illegal operator '=%c%c'", - nch, ch); - } - return ptok->tk_symb = - nch == '<' ? LEFTAB : RIGHTAB; - case '&': - return ptok->tk_symb = ANDAB; - case '^': - return ptok->tk_symb = XORAB; - case '|': - return ptok->tk_symb = ORAB; - } PushBack(); return ptok->tk_symb = ch; case '>': diff --git a/lang/cem/cemcom/LLlex.h b/lang/cem/cemcom/LLlex.h index a714065a7..8a3317a4e 100644 --- a/lang/cem/cemcom/LLlex.h +++ b/lang/cem/cemcom/LLlex.h @@ -48,6 +48,8 @@ struct token { #endif NOFLOAT extern struct token dot, ahead, aside; +extern int token_nmb; /* number of the ahead token */ +extern int tk_nmb_at_last_syn_err; /* token number at last syntax error */ #ifndef NOPP extern int ReplaceMacros; /* "LLlex.c" */ diff --git a/lang/cem/cemcom/LLmessage.c b/lang/cem/cemcom/LLmessage.c index 23005c910..85cb4fc49 100644 --- a/lang/cem/cemcom/LLmessage.c +++ b/lang/cem/cemcom/LLmessage.c @@ -20,11 +20,13 @@ LLmessage(tk) { error("end of file expected"); } else if (tk) { - error("%s missing", symbol2str(tk)); + error("%s missing before %s", symbol2str(tk), symbol2str(DOT)); insert_token(tk); } - else + else { error("%s deleted", symbol2str(DOT)); + } + tk_nmb_at_last_syn_err = token_nmb; } insert_token(tk) diff --git a/lang/cem/cemcom/LintPars b/lang/cem/cemcom/LintPars index 37266f8d3..305a264d8 100644 --- a/lang/cem/cemcom/LintPars +++ b/lang/cem/cemcom/LintPars @@ -8,8 +8,9 @@ !File: errout.h #define ERROUT STDERR /* file pointer for writing messages */ -#define MAXERR_LINE 5 /* 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/cem/cemcom/Makefile b/lang/cem/cemcom/Makefile index 210492285..b2dc16d82 100644 --- a/lang/cem/cemcom/Makefile +++ b/lang/cem/cemcom/Makefile @@ -135,9 +135,6 @@ SRC = $(CSRC) $(LCSRC) $(GCSRC) LINT = /usr/bin/lint LINTFLAGS = -MYLINT = ../lpass2/lint -MYLINTFLAGS = -xh - #EXCLEXCLEXCLEXCL .SUFFIXES: .str .h @@ -188,11 +185,7 @@ clean: (cd .. ; rm -rf Xsrc) lint: Cfiles - sh -c 'if $(CC) nmclash.c > /dev/null 2>&1 ; then make "EMHOME="$(EMHOME) Xlint ; else sh Resolve Xlint ; fi' - @rm -f nmclash.o a.out - -mylint: Cfiles - sh -c 'if $(CC) nmclash.c > /dev/null 2>&1 ; then make "EMHOME="$(EMHOME) Xmylint ; else sh Resolve Xmylint ; fi' + sh -c 'if $(CC) nmclash.c > /dev/null 2>&1 ; then make "EMHOME="$(EMHOME) LINT=$(LINT) Xlint ; else sh Resolve Xlint ; fi' @rm -f nmclash.o a.out longnames: $(SRC) $(HFILES) @@ -274,8 +267,6 @@ $(CURRDIR)lnt: $(OBJ) $(CURRDIR)Makefile Xlint: $(SRC) $(LINT) $(CDEFS) $(LINTFLAGS) $(SRC) -Xmylint: $(SRC) - $(MYLINT) $(CDEFS) $(MYLINTFLAGS) $(SRC) #AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO main.o: LLlex.h diff --git a/lang/cem/cemcom/SmallPars b/lang/cem/cemcom/SmallPars index fb0bf2a5d..a55ebb2c6 100644 --- a/lang/cem/cemcom/SmallPars +++ b/lang/cem/cemcom/SmallPars @@ -8,8 +8,9 @@ !File: errout.h #define ERROUT STDERR /* file pointer for writing messages */ -#define MAXERR_LINE 5 /* 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/cem/cemcom/ch7bin.c b/lang/cem/cemcom/ch7bin.c index 72ee4ace7..2d81e2d5b 100644 --- a/lang/cem/cemcom/ch7bin.c +++ b/lang/cem/cemcom/ch7bin.c @@ -77,15 +77,19 @@ ch7bin(expp, oper, expr) #endif NOROPTION ch7mon('*', expp); } - if ((*expp)->ex_type->tp_fund != FUNCTION) { - expr_error(*expp, "call of non-function (%s)", + switch ((*expp)->ex_type->tp_fund) { + case FUNCTION: + *expp = new_oper((*expp)->ex_type->tp_up, + *expp, '(', expr); + break; + default: /* uncallable */ + expr_error(*expp, "calling an object of type %s", symbol2str((*expp)->ex_type->tp_fund)); + case ERRONEOUS: /* uncallable but no message */ /* leave the expression; it may still serve */ free_expression(expr); /* there go the parameters */ + break; } - else - *expp = new_oper((*expp)->ex_type->tp_up, - *expp, '(', expr); (*expp)->ex_flags |= EX_SIDEEFFECTS; break; diff --git a/lang/cem/cemcom/declar.g b/lang/cem/cemcom/declar.g index a85827342..54e68da87 100644 --- a/lang/cem/cemcom/declar.g +++ b/lang/cem/cemcom/declar.g @@ -196,15 +196,7 @@ initializer(struct idf *idf; int sc;) if (level == L_FORMAL2) warning("illegal initialization of formal parameter (ignored)"); } - [ - '=' - | - empty - {warning("old-fashioned initialization, insert =");} - /* This causes trouble at declarator and at - external_definition, q.v. - */ - ] + '=' /* used to be optional because of V6 */ { #ifdef LINT lint_statement(); @@ -247,10 +239,7 @@ declarator(register struct declarator *dc;) } : primary_declarator(dc) - [%while(1) /* int i (M + 2) / 4; - is a function, not an - old-fashioned initialization. - */ + [ '(' formal_list(&fm) ? /* semantic check later... */ ')' diff --git a/lang/cem/cemcom/error.c b/lang/cem/cemcom/error.c index 3aef50d8d..ed8312e50 100644 --- a/lang/cem/cemcom/error.c +++ b/lang/cem/cemcom/error.c @@ -236,17 +236,19 @@ _error(class, fn, ln, ap) unsigned int ln; va_list ap; { - /* _error attempts to limit the number of error messages - for a given line to MAXERR_LINE. - */ -#ifndef LINT - static char *last_fn = 0; - static unsigned int last_ln = 0; - static int e_seen = 0; -#endif LINT char *remark; char *fmt = va_arg(ap, char *); - + + /* check visibility of message */ + switch (class) { + case WARNING: + case ERROR: + if (token_nmb < tk_nmb_at_last_syn_err + ERR_SHADOW) + /* warning or error message overshadowed */ + return; + break; + } + /* 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. @@ -292,25 +294,6 @@ _error(class, fn, ln, ap) /*NOTREACHED*/; } -#ifndef LINT - if (ln == last_ln && fn && last_fn && strcmp(fn, last_fn) == 0) { - /* 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_fn = fn; - last_ln = ln; - e_seen = 0; - } -#endif LINT - #ifdef LINT if ( /* there is a file name */ fn diff --git a/lang/cem/cemcom/expression.g b/lang/cem/cemcom/expression.g index 8697f8ace..85fa67380 100644 --- a/lang/cem/cemcom/expression.g +++ b/lang/cem/cemcom/expression.g @@ -307,16 +307,6 @@ asgnop(register int *oper;): '^' '=' {*oper = XORAB;} | '|' '=' {*oper = ORAB;} -| - [ PLUSAB | MINAB | TIMESAB | DIVAB | MODAB | - LEFTAB | RIGHTAB | ANDAB | XORAB | ORAB ] - { - char *symbol2str(); - - warning("old-fashioned assignment operator, use %s", - symbol2str(DOT)); - *oper = DOT; - } ; constant(struct expr **expp;) : diff --git a/lang/cem/cemcom/program.g b/lang/cem/cemcom/program.g index 7e2d00a78..ac9f4e031 100644 --- a/lang/cem/cemcom/program.g +++ b/lang/cem/cemcom/program.g @@ -130,11 +130,7 @@ external_definition lint_ext_def(Dc.dc_idf, Ds.ds_sc); #endif LINT } - [%if (Dc.dc_idf->id_def->df_type->tp_fund == FUNCTION) - /* int i (1) {2, 3} - is a function, not an old-fashioned - initialization. - */ + [ function(&Ds, &Dc) | non_function(&Ds, &Dc)