Subversion Repositories Kolibri OS

Rev

Rev 7983 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7983 leency 1
(*
7597 akron1 2
    BSD 2-Clause License
6613 leency 3
 
7983 leency 4
    Copyright (c) 2018-2020, Anton Krotov
7597 akron1 5
    All rights reserved.
6613 leency 6
*)
7
 
8
MODULE ERRORS;
9
 
7983 leency 10
IMPORT C := CONSOLE, UTILS;
6613 leency 11
 
12
 
7693 akron1 13
PROCEDURE HintMsg* (name: ARRAY OF CHAR; line, col, hint: INTEGER);
7597 akron1 14
BEGIN
15
    IF hint = 0 THEN
7693 akron1 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")
7597 akron1 18
    END
7693 akron1 19
END HintMsg;
6613 leency 20
 
21
 
7693 akron1 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);
6613 leency 33
VAR
7597 akron1 34
    str: ARRAY 80 OF CHAR;
6613 leency 35
 
7597 akron1 36
BEGIN
37
    C.Ln;
7693 akron1 38
    C.String("  error  ("); C.Int(errno); C.String(") ("); C.Int(line); C.String(":"); C.Int(col); C.String(") ");
6613 leency 39
 
7597 akron1 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"
7693 akron1 49
    | 13: str := "real numbers not supported"
6613 leency 50
 
7597 akron1 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"
7983 leency 76
    | 46: str := "IV out of range"
7597 akron1 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"
7693 akron1 93
    | 63: str := "not enough RAM"
7597 akron1 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"
7983 leency 140
    |110: str := "out of range 0..65535"
7597 akron1 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"
8097 maxcodehac 147
    |117: str := "string expected"
148
    |118: str := "'$END', '$ELSE' or '$ELSIF' without '$IF'"
149
    |119: str := "'$IF', '$ELSIF', '$ELSE' or '$END' expected"
7597 akron1 150
    |120: str := "too many formal parameters"
7983 leency 151
    |121: str := "multiply defined handler"
152
    |122: str := "bad divisor"
7693 akron1 153
    |123: str := "illegal flag"
154
    |124: str := "unknown flag"
155
    |125: str := "flag not supported"
7597 akron1 156
    END;
157
    C.StringLn(str);
158
    C.String("  file:  ");  C.StringLn(fname);
159
    UTILS.Exit(1)
7693 akron1 160
END ErrorMsg;
6613 leency 161
 
162
 
7693 akron1 163
PROCEDURE Error1 (s1: ARRAY OF CHAR);
6613 leency 164
BEGIN
7597 akron1 165
    C.Ln;
166
    C.StringLn(s1);
167
    UTILS.Exit(1)
7693 akron1 168
END Error1;
6613 leency 169
 
170
 
7693 akron1 171
PROCEDURE Error3 (s1, s2, s3: ARRAY OF CHAR);
6613 leency 172
BEGIN
7597 akron1 173
    C.Ln;
174
    C.String(s1); C.String(s2); C.StringLn(s3);
175
    UTILS.Exit(1)
7693 akron1 176
END Error3;
6613 leency 177
 
178
 
7693 akron1 179
PROCEDURE Error5 (s1, s2, s3, s4, s5: ARRAY OF CHAR);
6613 leency 180
BEGIN
7597 akron1 181
    C.Ln;
182
    C.String(s1); C.String(s2); C.String(s3); C.String(s4); C.StringLn(s5);
183
    UTILS.Exit(1)
7693 akron1 184
END Error5;
6613 leency 185
 
186
 
7693 akron1 187
PROCEDURE WrongRTL* (ProcName: ARRAY OF CHAR);
188
BEGIN
7983 leency 189
    Error5("procedure ", UTILS.RTL_NAME, ".", ProcName, " not found")
7693 akron1 190
END WrongRTL;
191
 
192
 
193
PROCEDURE BadParam* (param: ARRAY OF CHAR);
194
BEGIN
195
    Error3("bad parameter: ", param, "")
196
END BadParam;
197
 
198
 
199
PROCEDURE FileNotFound* (Path, Name, Ext: ARRAY OF CHAR);
200
BEGIN
201
    Error5("file ", Path, Name, Ext, " not found")
202
END FileNotFound;
203
 
204
 
205
PROCEDURE Error* (n: INTEGER);
206
BEGIN
207
    CASE n OF
208
    |201: Error1("writing file error")
209
    |202: Error1("too many relocations")
210
    |203: Error1("size of program is too large")
7696 akron1 211
    |204: Error1("size of variables is too large")
7693 akron1 212
    |205: Error1("not enough parameters")
213
    |206: Error1("bad parameter ")
7983 leency 214
    |207: Error3('inputfile name extension must be "', UTILS.FILE_EXT, '"')
8097 maxcodehac 215
    |208: Error1("not enough RAM")
7693 akron1 216
    END
217
END Error;
218
 
219
 
7983 leency 220
END ERRORS.