-- File ParserError.mesa
--
March 1, 1980 1:51 PM

DIRECTORY

ParserInputDefs: FROM "ParserInputDefs" USING [Identify],

OutputDefs: FROM "OutputDefs" USING [
SendMessage],

ParserErrorDefs: FROM "ParserErrorDefs" USING [ErrorType];

ParserError: PROGRAM IMPORTS ParserInputDefs, OutputDefs
EXPORTS ParserErrorDefs =

BEGIN
errorCounts: ARRAY
ParserErrorDefs.ErrorType[FIRST[ParserErrorDefs.ErrorType]..
LAST[ParserErrorDefs.ErrorType]]
OF CARDINAL;

ParserAbort: PUBLIC ERROR = CODE;

InitError: PUBLIC PROCEDURE RETURNS [BOOLEAN] =
BEGIN
errorCounts ← ALL[0];
RETURN[TRUE];
END;

FinishError: PUBLIC PROCEDURE RETURNS [BOOLEAN] =
BEGIN
RETURN[TRUE];
END;

Report: PUBLIC PROCEDURE [message: STRING, error: ParserErrorDefs.ErrorType] =
BEGIN OPEN OutputDefs;
IF error = Advisory THEN SendMessage[Advisory, "Warning: ", FALSE];
SendMessage[error, message];
ParserInputDefs.Identify[];
errorCounts[error] ← errorCounts[error] + 1;

IF error = FatalInternal THEN
-- horrors, abort
BEGIN
SendMessage[FatalInternal, "Aborting, please wait"];
ERROR ParserAbort;
END;
END;

ErrorSummary: PUBLIC PROCEDURE RETURNS
[ARRAY
ParserErrorDefs.ErrorType[FIRST[ParserErrorDefs.ErrorType]..
LAST[ParserErrorDefs.ErrorType]]
OF CARDINAL] =
BEGIN
RETURN[errorCounts];
END;

END.