home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 549b.lha / M2P_v1.0_sources / source.lzh / Err.mpp < prev    next >
Text File  |  1991-08-10  |  5KB  |  127 lines

  1. (*======================================================================*)
  2. (*                         Error Messages                               *)
  3. (*======================================================================*)
  4. (*  Version:  1.50              Author:   Dennis Brueni                 *)
  5. (*  Date:     07-09=91          Changes:  Original                      *)
  6. (*======================================================================*)
  7. (*  This MODULE houses most of the error messages generated by the      *)
  8. (*  parser, and a routine to print those messages.                      *)
  9. (*======================================================================*)
  10.  
  11. IMPLEMENTATION MODULE Err;
  12.  
  13. IMPORT FIO;
  14.  
  15. @IF    M2S THEN
  16.    IMPORT RunTime;
  17. @ELSIF TDI THEN
  18.    (* ???? *)
  19. @ELSE
  20.    (* insert import needed to set return code *)
  21. @END
  22.  
  23. @INCLUDE "MACROS"
  24.  
  25. @NoLongAddressing
  26.  
  27. (*----------------------------------------------------------------------*)
  28. (*  A large array of pointers to strings, which are the error messages. *)
  29. (*----------------------------------------------------------------------*)
  30.  
  31. TYPE Mess    = ARRAY [0..63] OF CHAR;
  32.      
  33. VAR  MessTab : ARRAY [MIN(Names)..MAX(Names)] OF Mess;
  34.  
  35. (*----------------------------------------------------------------------*)
  36. (* MESSAGE      Handles the print and formatting of all those friendly  *)
  37. (*              error messages we all so like getting.                  *)
  38. (*                                                                      *)
  39. (* PARAMETER    Err - the error message number                          *)
  40. (*----------------------------------------------------------------------*)
  41.  
  42. PROCEDURE Message(Error: Names);
  43.  
  44. BEGIN
  45.    FIO.WriteString(FIO.OUTPUT,'Error ');
  46.    FIO.WriteCard(FIO.OUTPUT,ORD(Error));
  47.    FIO.WriteString(FIO.OUTPUT,', Line ');
  48.    FIO.WriteCard(FIO.OUTPUT,LineNum);
  49.    FIO.WriteString(FIO.OUTPUT,':  ');
  50.    FIO.WriteString(FIO.OUTPUT,MessTab[Error]);
  51.    FIO.WriteLn(FIO.OUTPUT);
  52.    INC(ErrorCount);
  53. END Message;
  54.  
  55. (*----------------------------------------------------------------------*)
  56.  
  57. PROCEDURE Fatal(Code: INTEGER);
  58.  
  59. BEGIN
  60.    @IF AMIGA THEN
  61.       @IF    M2S THEN
  62.          RunTime.CLIReturnCode:=Code;
  63.       @ELSIF TDI THEN
  64.              (* I wonder how this is done in TDI M2?? *)
  65.       @ELSIF M2Amiga THEN
  66.          HALT(Code);
  67.       @ELSE
  68.              (* insert compiler dependent return code slot here *)
  69.       @END
  70.    @END
  71.    HALT;
  72. END Fatal;
  73.  
  74. (*----------------------------------------------------------------------*)
  75. (* LASTMESSAGE  Reports how many errors there were.                     *)
  76. (*----------------------------------------------------------------------*)
  77.  
  78. PROCEDURE LastMessage;
  79.  
  80. BEGIN
  81.    FIO.WriteString(FIO.OUTPUT,'There ');
  82.    IF ErrorCount = 0 THEN
  83.       FIO.WriteString(FIO.OUTPUT,'were no errors.  (');
  84.    ELSIF ErrorCount = 1 THEN
  85.       FIO.WriteString(FIO.OUTPUT,'was only one error.  |');
  86.    ELSE
  87.       FIO.WriteString(FIO.OUTPUT,'were ');
  88.       FIO.WriteCard(FIO.OUTPUT,ErrorCount);
  89.       FIO.WriteString(FIO.OUTPUT,' errors.  )');  
  90.    END;
  91.    FIO.WriteString(FIO.OUTPUT,'-:');
  92.    FIO.WriteLn(FIO.OUTPUT);
  93.    IF ErrorCount # 0 THEN
  94.       Fatal(Errors);
  95.    END;
  96. END LastMessage;
  97.  
  98. (************************************************************************)
  99.  
  100. BEGIN
  101.    ErrorCount:=0;
  102.    LineNum:=1;
  103.    MessTab[IFail]       := 'Internal Failure';
  104.    MessTab[StrNotEnded] := 'Strings may not be broken across line boundaries.';
  105.    MessTab[ComNotEnded] := 'Comment not closed with *)';
  106.    MessTab[TokTooLong]  := 'Token is too long, limit is 255 charactors';
  107.    MessTab[MissStr]     := 'Filename (string) expected following @INCLUDE';
  108.    MessTab[BadPPStmt]   := 'Unrecognized Preprocessor statement';
  109.    MessTab[IDNotMacro]  := 'Identifier must be defined as a macro';
  110.    MessTab[FlagReDefined]:='WARNING: Symbol has already been defined';
  111.    MessTab[FlagUnDefined]:='WARNING: Symbol has not been defined';
  112.    MessTab[UnDefXPctdID]:= 'Identifier expected following @UNDEF';
  113.    MessTab[DefXPctdID]  := 'Identifier expected following @DEFINE';
  114.    MessTab[MacXPctdID]  := 'Identifier expected following @MACRO';
  115.    MessTab[UnBalParens] := 'Unbalanced parenthesis in expression';
  116.    MessTab[IllFactor]   := 'Illegal factor in expression';
  117.    MessTab[MissAtElse]  := 'Expected @ELSE or @END';
  118.    MessTab[MissAtEnd]   := 'Expected @END';
  119.    MessTab[MissThen]    := 'Expected THEN';
  120.    MessTab[MissIfEnd]   := 'Expected END after IF-THEN';
  121.    MessTab[MissMacRP]   := 'Expected , or )';
  122.    MessTab[MissMacArg]  := 'Expected Identifier for macro argument name';
  123.    MessTab[TooMany]     := 'Too many arguments in macro';
  124.    MessTab[ArgNotEnded] := 'Argument to macro not terminated';
  125.    MessTab[MacNotEnded] := 'Macro definition not terminated with @ENDM';
  126. END Err.
  127.