!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
/* 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 */
char buf[(IDFSIZE > NUMSIZE ? IDFSIZE : NUMSIZE) + 1];
register int ch, nch;
+ token_nmb++;
+
if (File_Inserted) {
File_Inserted = 0;
goto 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 '>':
#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" */
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)
!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
LINT = /usr/bin/lint
LINTFLAGS =
-MYLINT = ../lpass2/lint
-MYLINTFLAGS = -xh
-
#EXCLEXCLEXCLEXCL
.SUFFIXES: .str .h
(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)
Xlint: $(SRC)
$(LINT) $(CDEFS) $(LINTFLAGS) $(SRC)
-Xmylint: $(SRC)
- $(MYLINT) $(CDEFS) $(MYLINTFLAGS) $(SRC)
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
main.o: LLlex.h
!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
#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;
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();
}
:
primary_declarator(dc)
- [%while(1) /* int i (M + 2) / 4;
- is a function, not an
- old-fashioned initialization.
- */
+ [
'('
formal_list(&fm) ? /* semantic check later... */
')'
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.
/*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
'^' '=' {*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;) :
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)