ERRORS.ob07 7.8 KB

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