2020-05-25 22:48:33 +02:00
|
|
|
(*
|
2019-03-11 09:59:55 +01:00
|
|
|
BSD 2-Clause License
|
2016-10-24 01:30:27 +02:00
|
|
|
|
2022-06-21 22:32:43 +02:00
|
|
|
Copyright (c) 2018-2022, Anton Krotov
|
2019-03-11 09:59:55 +01:00
|
|
|
All rights reserved.
|
2016-10-24 01:30:27 +02:00
|
|
|
*)
|
|
|
|
|
|
|
|
MODULE ERRORS;
|
|
|
|
|
2020-05-25 22:48:33 +02:00
|
|
|
IMPORT C := CONSOLE, UTILS;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
|
|
|
|
2019-09-26 22:23:06 +02:00
|
|
|
PROCEDURE HintMsg* (name: ARRAY OF CHAR; line, col, hint: INTEGER);
|
2019-03-11 09:59:55 +01:00
|
|
|
BEGIN
|
|
|
|
IF hint = 0 THEN
|
2019-09-26 22:23:06 +02:00
|
|
|
C.String(" hint ("); C.Int(line); C.String(":"); C.Int(col); C.String(") ");
|
|
|
|
C.String("variable '"); C.String(name); C.StringLn("' never used")
|
2019-03-11 09:59:55 +01:00
|
|
|
END
|
2019-09-26 22:23:06 +02:00
|
|
|
END HintMsg;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
|
|
|
|
2019-09-26 22:23:06 +02:00
|
|
|
PROCEDURE WarningMsg* (line, col, warning: INTEGER);
|
|
|
|
BEGIN
|
|
|
|
C.String(" warning ("); C.Int(line); C.String(":"); C.Int(col); C.String(") ");
|
|
|
|
CASE warning OF
|
|
|
|
|0: C.StringLn("passing a string value as a fixed array")
|
|
|
|
|1: C.StringLn("endless FOR loop")
|
2021-06-15 19:33:16 +02:00
|
|
|
|2: C.StringLn("identifier too long")
|
2019-09-26 22:23:06 +02:00
|
|
|
END
|
|
|
|
END WarningMsg;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE ErrorMsg* (fname: ARRAY OF CHAR; line, col, errno: INTEGER);
|
2016-10-24 01:30:27 +02:00
|
|
|
VAR
|
2019-03-11 09:59:55 +01:00
|
|
|
str: ARRAY 80 OF CHAR;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
|
|
|
BEGIN
|
2019-03-11 09:59:55 +01:00
|
|
|
C.Ln;
|
2019-09-26 22:23:06 +02:00
|
|
|
C.String(" error ("); C.Int(errno); C.String(") ("); C.Int(line); C.String(":"); C.Int(col); C.String(") ");
|
2019-03-11 09:59:55 +01:00
|
|
|
|
|
|
|
CASE errno OF
|
|
|
|
| 1: str := "missing 'H' or 'X'"
|
|
|
|
| 2: str := "missing scale"
|
|
|
|
| 3: str := "unclosed string"
|
|
|
|
| 4: str := "illegal character"
|
|
|
|
| 5: str := "string too long"
|
2021-06-15 19:33:16 +02:00
|
|
|
|
2019-03-11 09:59:55 +01:00
|
|
|
| 7: str := "number too long"
|
|
|
|
| 8..12: str := "number too large"
|
2019-09-26 22:23:06 +02:00
|
|
|
| 13: str := "real numbers not supported"
|
2019-03-11 09:59:55 +01:00
|
|
|
|
|
|
|
| 21: str := "'MODULE' expected"
|
|
|
|
| 22: str := "identifier expected"
|
|
|
|
| 23: str := "module name does not match file name"
|
|
|
|
| 24: str := "';' expected"
|
|
|
|
| 25: str := "identifier does not match module name"
|
|
|
|
| 26: str := "'.' expected"
|
|
|
|
| 27: str := "'END' expected"
|
|
|
|
| 28: str := "',', ';' or ':=' expected"
|
|
|
|
| 29: str := "module not found"
|
|
|
|
| 30: str := "multiply defined identifier"
|
|
|
|
| 31: str := "recursive import"
|
|
|
|
| 32: str := "'=' expected"
|
|
|
|
| 33: str := "')' expected"
|
|
|
|
| 34: str := "syntax error in expression"
|
|
|
|
| 35: str := "'}' expected"
|
|
|
|
| 36: str := "incompatible operand"
|
|
|
|
| 37: str := "incompatible operands"
|
|
|
|
| 38: str := "'RETURN' expected"
|
|
|
|
| 39: str := "integer overflow"
|
|
|
|
| 40: str := "floating point overflow"
|
|
|
|
| 41: str := "not enough floating point registers; simplify expression"
|
|
|
|
| 42: str := "out of range 0..255"
|
|
|
|
| 43: str := "expression is not an integer"
|
|
|
|
| 44: str := "out of range 0..MAXSET"
|
|
|
|
| 45: str := "division by zero"
|
2020-05-25 22:48:33 +02:00
|
|
|
| 46: str := "IV out of range"
|
2019-03-11 09:59:55 +01:00
|
|
|
| 47: str := "'OF' or ',' expected"
|
|
|
|
| 48: str := "undeclared identifier"
|
|
|
|
| 49: str := "type expected"
|
|
|
|
| 50: str := "recursive type definition"
|
|
|
|
| 51: str := "illegal value of constant"
|
|
|
|
| 52: str := "not a record type"
|
|
|
|
| 53: str := "':' expected"
|
|
|
|
| 54: str := "need to import SYSTEM"
|
|
|
|
| 55: str := "pointer type not defined"
|
|
|
|
| 56: str := "out of range 0..MAXSET"
|
|
|
|
| 57: str := "'TO' expected"
|
|
|
|
| 58: str := "not a record type"
|
|
|
|
| 59: str := "this expression cannot be a procedure"
|
|
|
|
| 60: str := "identifier does not match procedure name"
|
|
|
|
| 61: str := "illegally marked identifier"
|
|
|
|
| 62: str := "expression should be constant"
|
2019-09-26 22:23:06 +02:00
|
|
|
| 63: str := "not enough RAM"
|
2019-03-11 09:59:55 +01:00
|
|
|
| 64: str := "'(' expected"
|
|
|
|
| 65: str := "',' expected"
|
|
|
|
| 66: str := "incompatible parameter"
|
|
|
|
| 67: str := "'OF' expected"
|
|
|
|
| 68: str := "type expected"
|
|
|
|
| 69: str := "result type of procedure is not a basic type"
|
|
|
|
| 70: str := "import not supported"
|
|
|
|
| 71: str := "']' expected"
|
|
|
|
| 72: str := "expression is not BOOLEAN"
|
|
|
|
| 73: str := "not a record"
|
|
|
|
| 74: str := "undefined record field"
|
|
|
|
| 75: str := "not an array"
|
|
|
|
| 76: str := "expression is not an integer"
|
|
|
|
| 77: str := "not a pointer"
|
|
|
|
| 78: str := "type guard not allowed"
|
|
|
|
| 79: str := "not a type"
|
|
|
|
| 80: str := "not a record type"
|
|
|
|
| 81: str := "not a pointer type"
|
|
|
|
| 82: str := "type guard not allowed"
|
|
|
|
| 83: str := "index out of range"
|
|
|
|
| 84: str := "dimension too large"
|
|
|
|
| 85: str := "procedure must have level 0"
|
|
|
|
| 86: str := "not a procedure"
|
|
|
|
| 87: str := "incompatible expression (RETURN)"
|
|
|
|
| 88: str := "'THEN' expected"
|
|
|
|
| 89: str := "'DO' expected"
|
|
|
|
| 90: str := "'UNTIL' expected"
|
|
|
|
| 91: str := "incompatible assignment"
|
|
|
|
| 92: str := "procedure call of a function"
|
|
|
|
| 93: str := "not a variable"
|
|
|
|
| 94: str := "read only variable"
|
|
|
|
| 95: str := "invalid type of expression (CASE)"
|
|
|
|
| 96: str := "':=' expected"
|
|
|
|
| 97: str := "not INTEGER variable"
|
|
|
|
| 98: str := "illegal value of constant (0)"
|
|
|
|
| 99: str := "incompatible label"
|
|
|
|
|100: str := "multiply defined label"
|
|
|
|
|101: str := "too large parameter of WCHR"
|
|
|
|
|102: str := "label expected"
|
|
|
|
|103: str := "illegal value of constant"
|
|
|
|
|104: str := "type too large"
|
|
|
|
|105: str := "access to intermediate variables not allowed"
|
|
|
|
|106: str := "qualified identifier expected"
|
|
|
|
|107: str := "too large parameter of CHR"
|
|
|
|
|108: str := "a variable or a procedure expected"
|
|
|
|
|109: str := "expression should be constant"
|
2020-05-25 22:48:33 +02:00
|
|
|
|110: str := "out of range 0..65535"
|
2019-03-11 09:59:55 +01:00
|
|
|
|111: str := "record [noalign] cannot have a base type"
|
|
|
|
|112: str := "record [noalign] cannot be a base type"
|
|
|
|
|113: str := "result type of procedure should not be REAL"
|
|
|
|
|114: str := "identifiers 'lib_init' and 'version' are reserved"
|
|
|
|
|115: str := "recursive constant definition"
|
|
|
|
|116: str := "procedure too deep nested"
|
2020-10-13 09:58:51 +02:00
|
|
|
|117: str := "string expected"
|
|
|
|
|118: str := "'$END', '$ELSE' or '$ELSIF' without '$IF'"
|
|
|
|
|119: str := "'$IF', '$ELSIF', '$ELSE' or '$END' expected"
|
2019-03-11 09:59:55 +01:00
|
|
|
|120: str := "too many formal parameters"
|
2020-05-25 22:48:33 +02:00
|
|
|
|121: str := "multiply defined handler"
|
|
|
|
|122: str := "bad divisor"
|
2019-09-26 22:23:06 +02:00
|
|
|
|123: str := "illegal flag"
|
|
|
|
|124: str := "unknown flag"
|
|
|
|
|125: str := "flag not supported"
|
2022-06-21 22:32:43 +02:00
|
|
|
|126: str := "type of formal parameter should not be REAL"
|
2019-03-11 09:59:55 +01:00
|
|
|
END;
|
|
|
|
C.StringLn(str);
|
|
|
|
C.String(" file: "); C.StringLn(fname);
|
|
|
|
UTILS.Exit(1)
|
2019-09-26 22:23:06 +02:00
|
|
|
END ErrorMsg;
|
2019-03-11 09:59:55 +01:00
|
|
|
|
|
|
|
|
2019-09-26 22:23:06 +02:00
|
|
|
PROCEDURE Error1 (s1: ARRAY OF CHAR);
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2019-03-11 09:59:55 +01:00
|
|
|
C.Ln;
|
|
|
|
C.StringLn(s1);
|
|
|
|
UTILS.Exit(1)
|
2019-09-26 22:23:06 +02:00
|
|
|
END Error1;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
|
|
|
|
2019-09-26 22:23:06 +02:00
|
|
|
PROCEDURE Error3 (s1, s2, s3: ARRAY OF CHAR);
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2019-03-11 09:59:55 +01:00
|
|
|
C.Ln;
|
|
|
|
C.String(s1); C.String(s2); C.StringLn(s3);
|
|
|
|
UTILS.Exit(1)
|
2019-09-26 22:23:06 +02:00
|
|
|
END Error3;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
|
|
|
|
2019-09-26 22:23:06 +02:00
|
|
|
PROCEDURE Error5 (s1, s2, s3, s4, s5: ARRAY OF CHAR);
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2019-03-11 09:59:55 +01:00
|
|
|
C.Ln;
|
|
|
|
C.String(s1); C.String(s2); C.String(s3); C.String(s4); C.StringLn(s5);
|
|
|
|
UTILS.Exit(1)
|
2019-09-26 22:23:06 +02:00
|
|
|
END Error5;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE WrongRTL* (ProcName: ARRAY OF CHAR);
|
|
|
|
BEGIN
|
2020-05-25 22:48:33 +02:00
|
|
|
Error5("procedure ", UTILS.RTL_NAME, ".", ProcName, " not found")
|
2019-09-26 22:23:06 +02:00
|
|
|
END WrongRTL;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE BadParam* (param: ARRAY OF CHAR);
|
|
|
|
BEGIN
|
|
|
|
Error3("bad parameter: ", param, "")
|
|
|
|
END BadParam;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE FileNotFound* (Path, Name, Ext: ARRAY OF CHAR);
|
|
|
|
BEGIN
|
|
|
|
Error5("file ", Path, Name, Ext, " not found")
|
|
|
|
END FileNotFound;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE Error* (n: INTEGER);
|
|
|
|
BEGIN
|
|
|
|
CASE n OF
|
|
|
|
|201: Error1("writing file error")
|
|
|
|
|202: Error1("too many relocations")
|
|
|
|
|203: Error1("size of program is too large")
|
2019-10-06 19:55:12 +02:00
|
|
|
|204: Error1("size of variables is too large")
|
2019-09-26 22:23:06 +02:00
|
|
|
|205: Error1("not enough parameters")
|
|
|
|
|206: Error1("bad parameter <target>")
|
2020-05-25 22:48:33 +02:00
|
|
|
|207: Error3('inputfile name extension must be "', UTILS.FILE_EXT, '"')
|
2020-10-13 09:58:51 +02:00
|
|
|
|208: Error1("not enough RAM")
|
2019-09-26 22:23:06 +02:00
|
|
|
END
|
|
|
|
END Error;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
|
|
|
|
2020-05-25 22:48:33 +02:00
|
|
|
END ERRORS.
|