Subversion Repositories Kolibri OS

Rev

Rev 8097 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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