Subversion Repositories Kolibri OS

Rev

Rev 7597 | Blame | Last modification | View Log | Download | RSS feed

  1. (*
  2.     BSD 2-Clause License
  3.  
  4.     Copyright (c) 2018, 2019, Anton Krotov
  5.     All rights reserved.
  6. *)
  7.  
  8. MODULE ERRORS;
  9.  
  10. IMPORT C := CONSOLE, UTILS, mConst := CONSTANTS;
  11.  
  12.  
  13. PROCEDURE HintMsg* (name: ARRAY OF CHAR; line, col, hint: INTEGER);
  14. BEGIN
  15.     IF hint = 0 THEN
  16.         C.String("  hint ("); C.Int(line); C.String(":"); C.Int(col); C.String(") ");
  17.         C.String("variable '"); C.String(name); C.StringLn("' never used")
  18.     END
  19. END HintMsg;
  20.  
  21.  
  22. PROCEDURE WarningMsg* (line, col, warning: INTEGER);
  23. BEGIN
  24.     C.String("  warning ("); C.Int(line); C.String(":"); C.Int(col); C.String(") ");
  25.     CASE warning OF
  26.     |0: C.StringLn("passing a string value as a fixed array")
  27.     |1: C.StringLn("endless FOR loop")
  28.     END
  29. END WarningMsg;
  30.  
  31.  
  32. PROCEDURE ErrorMsg* (fname: ARRAY OF CHAR; line, col, errno: INTEGER);
  33. VAR
  34.     str: ARRAY 80 OF CHAR;
  35.  
  36. BEGIN
  37.     C.Ln;
  38.     C.String("  error  ("); C.Int(errno); C.String(") ("); C.Int(line); C.String(":"); C.Int(col); C.String(") ");
  39.  
  40.     CASE errno OF
  41.     |  1: str := "missing 'H' or 'X'"
  42.     |  2: str := "missing scale"
  43.     |  3: str := "unclosed string"
  44.     |  4: str := "illegal character"
  45.     |  5: str := "string too long"
  46.     |  6: str := "identifier too long"
  47.     |  7: str := "number too long"
  48.     |  8..12: str := "number too large"
  49.     | 13: str := "real numbers not supported"
  50.  
  51.     | 21: str := "'MODULE' expected"
  52.     | 22: str := "identifier expected"
  53.     | 23: str := "module name does not match file name"
  54.     | 24: str := "';' expected"
  55.     | 25: str := "identifier does not match module name"
  56.     | 26: str := "'.' expected"
  57.     | 27: str := "'END' expected"
  58.     | 28: str := "',', ';' or ':=' expected"
  59.     | 29: str := "module not found"
  60.     | 30: str := "multiply defined identifier"
  61.     | 31: str := "recursive import"
  62.     | 32: str := "'=' expected"
  63.     | 33: str := "')' expected"
  64.     | 34: str := "syntax error in expression"
  65.     | 35: str := "'}' expected"
  66.     | 36: str := "incompatible operand"
  67.     | 37: str := "incompatible operands"
  68.     | 38: str := "'RETURN' expected"
  69.     | 39: str := "integer overflow"
  70.     | 40: str := "floating point overflow"
  71.     | 41: str := "not enough floating point registers; simplify expression"
  72.     | 42: str := "out of range 0..255"
  73.     | 43: str := "expression is not an integer"
  74.     | 44: str := "out of range 0..MAXSET"
  75.     | 45: str := "division by zero"
  76.     | 46: str := "integer division by zero"
  77.     | 47: str := "'OF' or ',' expected"
  78.     | 48: str := "undeclared identifier"
  79.     | 49: str := "type expected"
  80.     | 50: str := "recursive type definition"
  81.     | 51: str := "illegal value of constant"
  82.     | 52: str := "not a record type"
  83.     | 53: str := "':' expected"
  84.     | 54: str := "need to import SYSTEM"
  85.     | 55: str := "pointer type not defined"
  86.     | 56: str := "out of range 0..MAXSET"
  87.     | 57: str := "'TO' expected"
  88.     | 58: str := "not a record type"
  89.     | 59: str := "this expression cannot be a procedure"
  90.     | 60: str := "identifier does not match procedure name"
  91.     | 61: str := "illegally marked identifier"
  92.     | 62: str := "expression should be constant"
  93.     | 63: str := "not enough RAM"
  94.     | 64: str := "'(' expected"
  95.     | 65: str := "',' expected"
  96.     | 66: str := "incompatible parameter"
  97.     | 67: str := "'OF' expected"
  98.     | 68: str := "type expected"
  99.     | 69: str := "result type of procedure is not a basic type"
  100.     | 70: str := "import not supported"
  101.     | 71: str := "']' expected"
  102.     | 72: str := "expression is not BOOLEAN"
  103.     | 73: str := "not a record"
  104.     | 74: str := "undefined record field"
  105.     | 75: str := "not an array"
  106.     | 76: str := "expression is not an integer"
  107.     | 77: str := "not a pointer"
  108.     | 78: str := "type guard not allowed"
  109.     | 79: str := "not a type"
  110.     | 80: str := "not a record type"
  111.     | 81: str := "not a pointer type"
  112.     | 82: str := "type guard not allowed"
  113.     | 83: str := "index out of range"
  114.     | 84: str := "dimension too large"
  115.     | 85: str := "procedure must have level 0"
  116.     | 86: str := "not a procedure"
  117.     | 87: str := "incompatible expression (RETURN)"
  118.     | 88: str := "'THEN' expected"
  119.     | 89: str := "'DO' expected"
  120.     | 90: str := "'UNTIL' expected"
  121.     | 91: str := "incompatible assignment"
  122.     | 92: str := "procedure call of a function"
  123.     | 93: str := "not a variable"
  124.     | 94: str := "read only variable"
  125.     | 95: str := "invalid type of expression (CASE)"
  126.     | 96: str := "':=' expected"
  127.     | 97: str := "not INTEGER variable"
  128.     | 98: str := "illegal value of constant (0)"
  129.     | 99: str := "incompatible label"
  130.     |100: str := "multiply defined label"
  131.     |101: str := "too large parameter of WCHR"
  132.     |102: str := "label expected"
  133.     |103: str := "illegal value of constant"
  134.     |104: str := "type too large"
  135.     |105: str := "access to intermediate variables not allowed"
  136.     |106: str := "qualified identifier expected"
  137.     |107: str := "too large parameter of CHR"
  138.     |108: str := "a variable or a procedure expected"
  139.     |109: str := "expression should be constant"
  140.  
  141.     |111: str := "record [noalign] cannot have a base type"
  142.     |112: str := "record [noalign] cannot be a base type"
  143.     |113: str := "result type of procedure should not be REAL"
  144.     |114: str := "identifiers 'lib_init' and 'version' are reserved"
  145.     |115: str := "recursive constant definition"
  146.     |116: str := "procedure too deep nested"
  147.  
  148.     |120: str := "too many formal parameters"
  149.  
  150.     |122: str := "negative divisor"
  151.     |123: str := "illegal flag"
  152.     |124: str := "unknown flag"
  153.     |125: str := "flag not supported"
  154.     END;
  155.     C.StringLn(str);
  156.     C.String("  file:  ");  C.StringLn(fname);
  157.     UTILS.Exit(1)
  158. END ErrorMsg;
  159.  
  160.  
  161. PROCEDURE Error1 (s1: ARRAY OF CHAR);
  162. BEGIN
  163.     C.Ln;
  164.     C.StringLn(s1);
  165.     UTILS.Exit(1)
  166. END Error1;
  167.  
  168.  
  169. PROCEDURE Error3 (s1, s2, s3: ARRAY OF CHAR);
  170. BEGIN
  171.     C.Ln;
  172.     C.String(s1); C.String(s2); C.StringLn(s3);
  173.     UTILS.Exit(1)
  174. END Error3;
  175.  
  176.  
  177. PROCEDURE Error5 (s1, s2, s3, s4, s5: ARRAY OF CHAR);
  178. BEGIN
  179.     C.Ln;
  180.     C.String(s1); C.String(s2); C.String(s3); C.String(s4); C.StringLn(s5);
  181.     UTILS.Exit(1)
  182. END Error5;
  183.  
  184.  
  185. PROCEDURE WrongRTL* (ProcName: ARRAY OF CHAR);
  186. BEGIN
  187.     Error5("procedure ", mConst.RTL_NAME, ".", ProcName, " not found")
  188. END WrongRTL;
  189.  
  190.  
  191. PROCEDURE BadParam* (param: ARRAY OF CHAR);
  192. BEGIN
  193.     Error3("bad parameter: ", param, "")
  194. END BadParam;
  195.  
  196.  
  197. PROCEDURE FileNotFound* (Path, Name, Ext: ARRAY OF CHAR);
  198. BEGIN
  199.     Error5("file ", Path, Name, Ext, " not found")
  200. END FileNotFound;
  201.  
  202.  
  203. PROCEDURE Error* (n: INTEGER);
  204. BEGIN
  205.     CASE n OF
  206.     |201: Error1("writing file error")
  207.     |202: Error1("too many relocations")
  208.     |203: Error1("size of program is too large")
  209.     |204: Error1("size of global variables is too large")
  210.     |205: Error1("not enough parameters")
  211.     |206: Error1("bad parameter <target>")
  212.     |207: Error3('inputfile name extension must be "', mConst.FILE_EXT, '"')
  213.     END
  214. END Error;
  215.  
  216.  
  217. END ERRORS.