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