home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1991-08-10 | 4.7 KB | 127 lines |
- (*======================================================================*)
- (* Error Messages *)
- (*======================================================================*)
- (* Version: 1.50 Author: Dennis Brueni *)
- (* Date: 07-09=91 Changes: Original *)
- (*======================================================================*)
- (* This MODULE houses most of the error messages generated by the *)
- (* parser, and a routine to print those messages. *)
- (*======================================================================*)
-
- IMPLEMENTATION MODULE Err;
-
- IMPORT FIO;
-
- @IF M2S THEN
- IMPORT RunTime;
- @ELSIF TDI THEN
- (* ???? *)
- @ELSE
- (* insert import needed to set return code *)
- @END
-
- @INCLUDE "MACROS"
-
- @NoLongAddressing
-
- (*----------------------------------------------------------------------*)
- (* A large array of pointers to strings, which are the error messages. *)
- (*----------------------------------------------------------------------*)
-
- TYPE Mess = ARRAY [0..63] OF CHAR;
-
- VAR MessTab : ARRAY [MIN(Names)..MAX(Names)] OF Mess;
-
- (*----------------------------------------------------------------------*)
- (* MESSAGE Handles the print and formatting of all those friendly *)
- (* error messages we all so like getting. *)
- (* *)
- (* PARAMETER Err - the error message number *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Message(Error: Names);
-
- BEGIN
- FIO.WriteString(FIO.OUTPUT,'Error ');
- FIO.WriteCard(FIO.OUTPUT,ORD(Error));
- FIO.WriteString(FIO.OUTPUT,', Line ');
- FIO.WriteCard(FIO.OUTPUT,LineNum);
- FIO.WriteString(FIO.OUTPUT,': ');
- FIO.WriteString(FIO.OUTPUT,MessTab[Error]);
- FIO.WriteLn(FIO.OUTPUT);
- INC(ErrorCount);
- END Message;
-
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Fatal(Code: INTEGER);
-
- BEGIN
- @IF AMIGA THEN
- @IF M2S THEN
- RunTime.CLIReturnCode:=Code;
- @ELSIF TDI THEN
- (* I wonder how this is done in TDI M2?? *)
- @ELSIF M2Amiga THEN
- HALT(Code);
- @ELSE
- (* insert compiler dependent return code slot here *)
- @END
- @END
- HALT;
- END Fatal;
-
- (*----------------------------------------------------------------------*)
- (* LASTMESSAGE Reports how many errors there were. *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE LastMessage;
-
- BEGIN
- FIO.WriteString(FIO.OUTPUT,'There ');
- IF ErrorCount = 0 THEN
- FIO.WriteString(FIO.OUTPUT,'were no errors. (');
- ELSIF ErrorCount = 1 THEN
- FIO.WriteString(FIO.OUTPUT,'was only one error. |');
- ELSE
- FIO.WriteString(FIO.OUTPUT,'were ');
- FIO.WriteCard(FIO.OUTPUT,ErrorCount);
- FIO.WriteString(FIO.OUTPUT,' errors. )');
- END;
- FIO.WriteString(FIO.OUTPUT,'-:');
- FIO.WriteLn(FIO.OUTPUT);
- IF ErrorCount # 0 THEN
- Fatal(Errors);
- END;
- END LastMessage;
-
- (************************************************************************)
-
- BEGIN
- ErrorCount:=0;
- LineNum:=1;
- MessTab[IFail] := 'Internal Failure';
- MessTab[StrNotEnded] := 'Strings may not be broken across line boundaries.';
- MessTab[ComNotEnded] := 'Comment not closed with *)';
- MessTab[TokTooLong] := 'Token is too long, limit is 255 charactors';
- MessTab[MissStr] := 'Filename (string) expected following @INCLUDE';
- MessTab[BadPPStmt] := 'Unrecognized Preprocessor statement';
- MessTab[IDNotMacro] := 'Identifier must be defined as a macro';
- MessTab[FlagReDefined]:='WARNING: Symbol has already been defined';
- MessTab[FlagUnDefined]:='WARNING: Symbol has not been defined';
- MessTab[UnDefXPctdID]:= 'Identifier expected following @UNDEF';
- MessTab[DefXPctdID] := 'Identifier expected following @DEFINE';
- MessTab[MacXPctdID] := 'Identifier expected following @MACRO';
- MessTab[UnBalParens] := 'Unbalanced parenthesis in expression';
- MessTab[IllFactor] := 'Illegal factor in expression';
- MessTab[MissAtElse] := 'Expected @ELSE or @END';
- MessTab[MissAtEnd] := 'Expected @END';
- MessTab[MissThen] := 'Expected THEN';
- MessTab[MissIfEnd] := 'Expected END after IF-THEN';
- MessTab[MissMacRP] := 'Expected , or )';
- MessTab[MissMacArg] := 'Expected Identifier for macro argument name';
- MessTab[TooMany] := 'Too many arguments in macro';
- MessTab[ArgNotEnded] := 'Argument to macro not terminated';
- MessTab[MacNotEnded] := 'Macro definition not terminated with @ENDM';
- END Err.
-