better error handling, simplified EOI handling with improved input module

This commit is contained in:
ceriel
1989-04-04 14:53:48 +00:00
parent 05f256fb4c
commit c550c43fff
3 changed files with 47 additions and 79 deletions

View File

@@ -120,8 +120,10 @@ define(id, scope, kind)
) {
switch(df->df_kind) {
case D_INUSE:
if (kind != D_INUSE) {
if (kind != D_INUSE && kind != D_ERROR) {
error("identifier \"%s\" already used; may not be redefined in this scope", df->df_idf->id_text);
df->df_kind = D_ERROR;
break;
}
return df;
@@ -158,12 +160,9 @@ define(id, scope, kind)
break;
case D_FORWTYPE:
if (kind & (D_FORWTYPE|D_TYPE)) return df;
else {
error("identifier \"%s\" must be a type",
id->id_text);
}
return df;
error("identifier \"%s\" must be a type", id->id_text);
df->df_kind = D_ERROR;
break;
case D_FORWARD:
/* A forward reference, for which we may now have
found a definition.
@@ -171,29 +170,24 @@ define(id, scope, kind)
if (! (kind & (D_FORWARD | D_FORWMODULE))) {
FreeNode(df->for_node);
}
/* Fall through */
case D_ERROR:
/* A definition generated by the compiler, because
it found an error. Maybe, the user gives a
definition after all.
*/
if (kind & (D_TYPE|D_PROCEDURE|D_CONST)) {
df->df_flags = D_DEFINED;
}
df->df_kind = kind;
return df;
df->df_kind = D_ERROR; /* avoiding error message */
break;
}
if (kind != D_ERROR) {
if (kind != D_ERROR && df->df_kind != D_ERROR) {
/* Avoid spurious error messages
*/
error("identifier \"%s\" already declared",
id->id_text);
}
if (df->df_scope == scope || df->df_kind == D_ERROR) {
df->df_kind = kind;
if (kind & (D_TYPE|D_PROCEDURE|D_CONST)) {
df->df_flags = D_DEFINED;
}
return df;
return df;
}
}
return MkDef(id, scope, kind);