996
|
1 package Language::INTERCAL::Splats;
|
|
2
|
|
3 # Splats and error messages
|
|
4
|
|
5 # This file is part of CLC-INTERCAL
|
|
6
|
|
7 # Copyright (c) 2006-2008 Claudio Calvelli, all rights reserved.
|
|
8
|
|
9 # CLC-INTERCAL is copyrighted software. However, permission to use, modify,
|
|
10 # and distribute it is granted provided that the conditions set out in the
|
|
11 # licence agreement are met. See files README and COPYING in the distribution.
|
|
12
|
|
13
|
|
14 use strict;
|
|
15 use vars qw($VERSION $PERVERSION);
|
|
16 ($VERSION) = ($PERVERSION = "CLC-INTERCAL/Base INTERCAL/Splats.pm 1.-94.-2") =~ /\s(\S+)$/;
|
|
17
|
|
18 use Carp;
|
|
19 use Language::INTERCAL::Exporter '1.-94.-2';
|
|
20 use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS);
|
|
21
|
|
22 @EXPORT_OK = qw(
|
|
23 splatnumber splatname splatdescription faint
|
|
24 SP_ARRAY SP_ASSIGN SP_BASE SP_BCMATCH SP_BUG SP_CHARSET SP_CIRCULAR
|
|
25 SP_CLASS SP_CLASSWAR SP_COMEFROM SP_COMMENT SP_CONTEXT SP_CONVERT
|
|
26 SP_CREATION SP_DIGITS SP_DIVIDE SP_EARLY SP_EVENT SP_EVOLUTION
|
|
27 SP_FALL_OFF SP_FORBIDDEN SP_FREE SP_HIDDEN SP_HOLIDAY SP_ILLEGAL
|
|
28 SP_INDIGESTION SP_INTERNAL SP_INTERNET SP_INVALID SP_INVARRAY
|
|
29 SP_INVCLASS SP_INVLABEL SP_INVSPLAT SP_IOERR SP_IOMODE SP_IOTYPE
|
|
30 SP_ISARRAY SP_ISCLASS SP_ISNUMBER SP_JUNK SP_LANGUAGE SP_LECTURE
|
|
31 SP_MAKE_NEW SP_MODEERR SP_NEXTING SP_NOARRAY SP_NOASSIGN SP_NOBELONG
|
|
32 SP_NOCLASS SP_NOCURRICULUM SP_NODIM SP_NONUMBER SP_NOOWNER
|
|
33 SP_NOREGISTER SP_NORESUME SP_NOSPECIAL SP_NOSTUDENT SP_NOSUCHCHAR
|
|
34 SP_NOSUCHLABEL SP_NOSYSCALL SP_NOTCLASS SP_NOTHREAD SP_NOVALUE
|
|
35 SP_NUMBER SP_OVREG SP_OWNER SP_QUANTUM SP_READ SP_REGGRIM SP_REGISTER
|
|
36 SP_REGNUM SP_RESUME SP_ROMAN SP_SEEKERR SP_SPECIAL SP_SPLAT SP_SPOTS
|
|
37 SP_SUBSCRIPT SP_SUBSIZE SP_SWAP SP_SYMBOL SP_SYSCALL SP_THREESPOT
|
|
38 SP_TODO SP_TOOMANYLABS SP_UBUG
|
|
39 );
|
|
40
|
|
41 %EXPORT_TAGS = (
|
|
42 SP => [qw(
|
|
43 faint
|
|
44 SP_ARRAY SP_ASSIGN SP_BASE SP_BCMATCH SP_BUG SP_CHARSET SP_CIRCULAR
|
|
45 SP_CLASS SP_CLASSWAR SP_COMEFROM SP_COMMENT SP_CONTEXT SP_CONVERT
|
|
46 SP_CREATION SP_DIGITS SP_DIVIDE SP_EARLY SP_EVENT SP_EVOLUTION
|
|
47 SP_FALL_OFF SP_FORBIDDEN SP_FREE SP_HIDDEN SP_HOLIDAY SP_ILLEGAL
|
|
48 SP_INDIGESTION SP_INTERNAL SP_INTERNET SP_INVALID SP_INVARRAY
|
|
49 SP_INVCLASS SP_INVLABEL SP_INVSPLAT SP_IOERR SP_IOMODE SP_IOTYPE
|
|
50 SP_ISARRAY SP_ISCLASS SP_ISNUMBER SP_JUNK SP_LANGUAGE SP_LECTURE
|
|
51 SP_MAKE_NEW SP_MODEERR SP_NEXTING SP_NOARRAY SP_NOASSIGN
|
|
52 SP_NOBELONG SP_NOCLASS SP_NOCURRICULUM SP_NODIM SP_NONUMBER
|
|
53 SP_NOOWNER SP_NOREGISTER SP_NORESUME SP_NOSPECIAL SP_NOSTUDENT
|
|
54 SP_NOSUCHCHAR SP_NOSUCHLABEL SP_NOSYSCALL SP_NOTCLASS SP_NOTHREAD
|
|
55 SP_NOVALUE SP_NUMBER SP_OVREG SP_OWNER SP_QUANTUM SP_READ
|
|
56 SP_REGGRIM SP_REGISTER SP_REGNUM SP_RESUME SP_ROMAN SP_SEEKERR
|
|
57 SP_SPECIAL SP_SPLAT SP_SPOTS SP_SUBSCRIPT SP_SUBSIZE SP_SWAP
|
|
58 SP_SYMBOL SP_SYSCALL SP_THREESPOT SP_TODO SP_TOOMANYLABS SP_UBUG
|
|
59 )],
|
|
60 );
|
|
61
|
|
62 my %splatbyname = (
|
|
63 ARRAY => 280,
|
|
64 ASSIGN => 277,
|
|
65 BASE => 8,
|
|
66 BCMATCH => 578,
|
|
67 BUG => 774,
|
|
68 CHARSET => 10,
|
|
69 CIRCULAR => 818,
|
|
70 CLASS => 254,
|
|
71 CLASSWAR => 603,
|
|
72 COMEFROM => 555,
|
|
73 COMMENT => 0,
|
|
74 CONTEXT => 398,
|
|
75 CONVERT => 444,
|
|
76 CREATION => 816,
|
|
77 DIGITS => 534,
|
|
78 DIVIDE => 662,
|
|
79 EARLY => 999,
|
|
80 EVENT => 751,
|
|
81 EVOLUTION => 815,
|
|
82 FALL_OFF => 633,
|
|
83 FORBIDDEN => 796,
|
|
84 FREE => 511,
|
|
85 HIDDEN => 436,
|
|
86 HOLIDAY => 799,
|
|
87 ILLEGAL => 997,
|
|
88 INDIGESTION => 664,
|
|
89 INTERNAL => 634,
|
|
90 INTERNET => 899,
|
|
91 INVALID => 69,
|
|
92 INVARRAY => 251,
|
|
93 INVCLASS => 253,
|
|
94 INVLABEL => 131,
|
|
95 INVSPLAT => 457,
|
|
96 IOERR => 642,
|
|
97 IOMODE => 641,
|
|
98 IOTYPE => 9,
|
|
99 ISARRAY => 243,
|
|
100 ISCLASS => 244,
|
|
101 ISNUMBER => 438,
|
|
102 JUNK => 128,
|
|
103 LANGUAGE => 700,
|
|
104 LECTURE => 699,
|
|
105 MAKE_NEW => 443,
|
|
106 MODEERR => 644,
|
|
107 NEXTING => 123,
|
|
108 NOARRAY => 245,
|
|
109 NOASSIGN => 752,
|
|
110 NOBELONG => 512,
|
|
111 NOCLASS => 250,
|
|
112 NOCURRICULUM => 823,
|
|
113 NODIM => 241,
|
|
114 NONUMBER => 701,
|
|
115 NOOWNER => 513,
|
|
116 NOREGISTER => 437,
|
|
117 NORESUME => 621,
|
|
118 NOSPECIAL => 257,
|
|
119 NOSTUDENT => 822,
|
|
120 NOSUCHCHAR => 109,
|
|
121 NOSUCHLABEL => 129,
|
|
122 NOSYSCALL => 660,
|
|
123 NOTCLASS => 242,
|
|
124 NOTHREAD => 369,
|
|
125 NOVALUE => 256,
|
|
126 NUMBER => 281,
|
|
127 OVREG => 252,
|
|
128 OWNER => 514,
|
|
129 QUANTUM => 666,
|
|
130 READ => 432,
|
|
131 REGGRIM => 898,
|
|
132 REGISTER => 433,
|
|
133 REGNUM => 70,
|
|
134 RESUME => 632,
|
|
135 ROMAN => 4,
|
|
136 SEEKERR => 643,
|
|
137 SPECIAL => 247,
|
|
138 SPLAT => 456,
|
|
139 SPOTS => 274,
|
|
140 SUBSCRIPT => 276,
|
|
141 SUBSIZE => 279,
|
|
142 SWAP => 445,
|
|
143 SYMBOL => 535,
|
|
144 SYSCALL => 661,
|
|
145 THREESPOT => 702,
|
|
146 TODO => 1,
|
|
147 TOOMANYLABS => 130,
|
|
148 UBUG => 775,
|
|
149 );
|
|
150
|
|
151 my %splats = (
|
|
152 0 => ['COMMENT', '%'],
|
|
153 1 => ['TODO', 'Not implemented: %'],
|
|
154 4 => ['ROMAN', 'Unknown read type for Roman numerals: %'],
|
|
155 8 => ['BASE', 'Base must be between 2 and 7 (got %)'],
|
|
156 9 => ['IOTYPE', 'Invalid I/O Type: %'],
|
|
157 10 => ['CHARSET', 'Invalid character set: %'],
|
|
158 69 => ['INVALID', 'Invalid bytecode (%) for %'],
|
|
159 70 => ['REGNUM', 'Invalid register number "%"'],
|
|
160 109 => ['NOSUCHCHAR', 'Invalid character (%) for %'],
|
|
161 123 => ['NEXTING', 'Program attempted more than % levels of NEXTing'],
|
|
162 128 => ['JUNK', 'Cannot use JUNK in this grammar'],
|
|
163 129 => ['NOSUCHLABEL', 'Could not find label %'],
|
|
164 130 => ['TOOMANYLABS', 'Cannot decide between % instances of label %'],
|
|
165 131 => ['INVLABEL', 'Invalid label %'],
|
|
166 241 => ['NODIM', 'Array not dimensioned'],
|
|
167 242 => ['NOTCLASS', 'Non-class value used as class'],
|
|
168 243 => ['ISARRAY', 'Array register used as value'],
|
|
169 244 => ['ISCLASS', 'Class register used as value'],
|
|
170 245 => ['NOARRAY', 'Non-array register used as array'],
|
|
171 247 => ['SPECIAL', 'Attempt to use special register %'],
|
|
172 250 => ['NOCLASS', 'Invalid value % assigned to class'],
|
|
173 251 => ['INVARRAY', 'Invalid value in array element: %'],
|
|
174 252 => ['OVREG', 'Cannot use overload register %'],
|
|
175 253 => ['INVCLASS', 'Invalid lecture: %'],
|
|
176 254 => ['CLASS', 'Invalid subject: %'],
|
|
177 256 => ['NOVALUE', 'This register cannot hold a value'],
|
|
178 257 => ['NOSPECIAL', 'Normal register used as special'],
|
|
179 274 => ['SPOTS', 'Number % too large for %'],
|
|
180 276 => ['SUBSCRIPT', 'Invalid subscript %: %'],
|
|
181 277 => ['ASSIGN', 'Impossible assignment (base %): cannot find #X such that #%X is #%'],
|
|
182 279 => ['SUBSIZE', 'Invalid number of subscripts: % provided, % required'],
|
|
183 280 => ['ARRAY', 'Invalid array: %'],
|
|
184 281 => ['NUMBER', 'Invalid number: %'],
|
|
185 369 => ['NOTHREAD', 'Thread % does not exist'],
|
|
186 398 => ['CONTEXT', 'Invalid context: %'],
|
|
187 432 => ['READ', 'Not suitable for %'],
|
|
188 433 => ['REGISTER', 'Not a valid register: %'],
|
|
189 436 => ['HIDDEN', 'Register % stashed away too well'],
|
|
190 437 => ['NOREGISTER', 'Cannot % numbers'],
|
|
191 438 => ['ISNUMBER', 'Numbers cannot %'],
|
|
192 443 => ['MAKE_NEW', 'Cannot make new opcode %'],
|
|
193 444 => ['CONVERT', 'Cannot convert % to %'],
|
|
194 445 => ['SWAP', 'Cannot swap % and %'],
|
|
195 456 => ['SPLAT', 'No splat'],
|
|
196 457 => ['INVSPLAT', 'Invalid splat %'],
|
|
197 511 => ['FREE', 'Register % is not a slave'],
|
|
198 512 => ['NOBELONG', 'Register % does not belong to register %'],
|
|
199 513 => ['NOOWNER', 'Slave % does not have % owners (just %)'],
|
|
200 514 => ['OWNER', 'Invalid owner number: %'],
|
|
201 534 => ['DIGITS', 'Wrong number of digits for base %: %'],
|
|
202 535 => ['SYMBOL', 'Invalid symbol: %'],
|
|
203 555 => ['COMEFROM', 'Multiple "COME FROM" %'],
|
|
204 578 => ['BCMATCH', 'Invalid bytecode pattern in %: %'],
|
|
205 603 => ['CLASSWAR', 'Class war between % and %'],
|
|
206 621 => ['NORESUME', 'Pointless RESUME'],
|
|
207 632 => ['RESUME', 'Program terminated via RESUME'],
|
|
208 633 => ['FALL_OFF', 'Falling off the edge of the program'],
|
|
209 634 => ['INTERNAL', 'Internal error: %'],
|
|
210 641 => ['IOMODE', 'Invalid I/O mode %'],
|
|
211 642 => ['IOERR', 'Input output error in %: %'],
|
|
212 643 => ['SEEKERR', 'Seek/tell error: %'],
|
|
213 644 => ['MODEERR', 'I/O error: %'],
|
|
214 660 => ['NOSYSCALL', 'Undefined system call %'],
|
|
215 661 => ['SYSCALL', 'Missing system call number'],
|
|
216 662 => ['DIVIDE', 'Unary division by zero'],
|
|
217 664 => ['INDIGESTION', 'Program is too large'],
|
|
218 666 => ['QUANTUM', '% does not have a quantum version'],
|
|
219 699 => ['LECTURE', 'Not in a lecture'],
|
|
220 700 => ['LANGUAGE', 'Invalid language: %'],
|
|
221 701 => ['NONUMBER', 'Value written in is not a number: %'],
|
|
222 702 => ['THREESPOT', 'Value written in is larger than two spots'],
|
|
223 751 => ['EVENT', 'Invalid event: BODY WHILE CONDITION'],
|
|
224 752 => ['NOASSIGN', 'Cannot assign %: %'],
|
|
225 774 => ['BUG', 'Compiler error'],
|
|
226 775 => ['UBUG', 'Unexplainable compiler error'],
|
|
227 796 => ['FORBIDDEN', '% is forbidden in INTERCAL-1972'],
|
|
228 799 => ['HOLIDAY', 'No class teaches subjects %'],
|
|
229 815 => ['EVOLUTION', 'Creation not allowed: %'],
|
|
230 816 => ['CREATION', 'CREATE statement misconfiguration: %'],
|
|
231 818 => ['CIRCULAR', 'Circular reasoning in %'],
|
|
232 822 => ['NOSTUDENT', 'Register % is not a student'],
|
|
233 823 => ['NOCURRICULUM', 'Subject % is not in %\'s curriculum'],
|
|
234 898 => ['REGGRIM', 'Error in Regular Grimace: %'],
|
|
235 899 => ['INTERNET', 'INTERcal NETwork error talking to %: %'],
|
|
236 997 => ['ILLEGAL', 'Illegal operator % for base %'],
|
|
237 999 => ['EARLY', 'Lecture at % is too early'],
|
|
238 );
|
|
239
|
|
240 sub SP_ARRAY () { 280 }
|
|
241 sub SP_ASSIGN () { 277 }
|
|
242 sub SP_BASE () { 8 }
|
|
243 sub SP_BCMATCH () { 578 }
|
|
244 sub SP_BUG () { 774 }
|
|
245 sub SP_CHARSET () { 10 }
|
|
246 sub SP_CIRCULAR () { 818 }
|
|
247 sub SP_CLASS () { 254 }
|
|
248 sub SP_CLASSWAR () { 603 }
|
|
249 sub SP_COMEFROM () { 555 }
|
|
250 sub SP_COMMENT () { 0 }
|
|
251 sub SP_CONTEXT () { 398 }
|
|
252 sub SP_CONVERT () { 444 }
|
|
253 sub SP_CREATION () { 816 }
|
|
254 sub SP_DIGITS () { 534 }
|
|
255 sub SP_DIVIDE () { 662 }
|
|
256 sub SP_EARLY () { 999 }
|
|
257 sub SP_EVENT () { 751 }
|
|
258 sub SP_EVOLUTION () { 815 }
|
|
259 sub SP_FALL_OFF () { 633 }
|
|
260 sub SP_FORBIDDEN () { 796 }
|
|
261 sub SP_FREE () { 511 }
|
|
262 sub SP_HIDDEN () { 436 }
|
|
263 sub SP_HOLIDAY () { 799 }
|
|
264 sub SP_ILLEGAL () { 997 }
|
|
265 sub SP_INDIGESTION () { 664 }
|
|
266 sub SP_INTERNAL () { 634 }
|
|
267 sub SP_INTERNET () { 899 }
|
|
268 sub SP_INVALID () { 69 }
|
|
269 sub SP_INVARRAY () { 251 }
|
|
270 sub SP_INVCLASS () { 253 }
|
|
271 sub SP_INVLABEL () { 131 }
|
|
272 sub SP_INVSPLAT () { 457 }
|
|
273 sub SP_IOERR () { 642 }
|
|
274 sub SP_IOMODE () { 641 }
|
|
275 sub SP_IOTYPE () { 9 }
|
|
276 sub SP_ISARRAY () { 243 }
|
|
277 sub SP_ISCLASS () { 244 }
|
|
278 sub SP_ISNUMBER () { 438 }
|
|
279 sub SP_JUNK () { 128 }
|
|
280 sub SP_LANGUAGE () { 700 }
|
|
281 sub SP_LECTURE () { 699 }
|
|
282 sub SP_MAKE_NEW () { 443 }
|
|
283 sub SP_MODEERR () { 644 }
|
|
284 sub SP_NEXTING () { 123 }
|
|
285 sub SP_NOARRAY () { 245 }
|
|
286 sub SP_NOASSIGN () { 752 }
|
|
287 sub SP_NOBELONG () { 512 }
|
|
288 sub SP_NOCLASS () { 250 }
|
|
289 sub SP_NOCURRICULUM () { 823 }
|
|
290 sub SP_NODIM () { 241 }
|
|
291 sub SP_NONUMBER () { 701 }
|
|
292 sub SP_NOOWNER () { 513 }
|
|
293 sub SP_NOREGISTER () { 437 }
|
|
294 sub SP_NORESUME () { 621 }
|
|
295 sub SP_NOSPECIAL () { 257 }
|
|
296 sub SP_NOSTUDENT () { 822 }
|
|
297 sub SP_NOSUCHCHAR () { 109 }
|
|
298 sub SP_NOSUCHLABEL () { 129 }
|
|
299 sub SP_NOSYSCALL () { 660 }
|
|
300 sub SP_NOTCLASS () { 242 }
|
|
301 sub SP_NOTHREAD () { 369 }
|
|
302 sub SP_NOVALUE () { 256 }
|
|
303 sub SP_NUMBER () { 281 }
|
|
304 sub SP_OVREG () { 252 }
|
|
305 sub SP_OWNER () { 514 }
|
|
306 sub SP_QUANTUM () { 666 }
|
|
307 sub SP_READ () { 432 }
|
|
308 sub SP_REGGRIM () { 898 }
|
|
309 sub SP_REGISTER () { 433 }
|
|
310 sub SP_REGNUM () { 70 }
|
|
311 sub SP_RESUME () { 632 }
|
|
312 sub SP_ROMAN () { 4 }
|
|
313 sub SP_SEEKERR () { 643 }
|
|
314 sub SP_SPECIAL () { 247 }
|
|
315 sub SP_SPLAT () { 456 }
|
|
316 sub SP_SPOTS () { 274 }
|
|
317 sub SP_SUBSCRIPT () { 276 }
|
|
318 sub SP_SUBSIZE () { 279 }
|
|
319 sub SP_SWAP () { 445 }
|
|
320 sub SP_SYMBOL () { 535 }
|
|
321 sub SP_SYSCALL () { 661 }
|
|
322 sub SP_THREESPOT () { 702 }
|
|
323 sub SP_TODO () { 1 }
|
|
324 sub SP_TOOMANYLABS () { 130 }
|
|
325 sub SP_UBUG () { 775 }
|
|
326
|
|
327 sub faint {
|
|
328 @_ >= 1 or croak "Usage: faint(NUM, ARGS)";
|
|
329 die splatdescription(@_) . "\n";
|
|
330 }
|
|
331
|
|
332 sub splatnumber {
|
|
333 @_ == 1 or croak "Usage: splatnumber(SPLATNAME)";
|
|
334 my $s = shift;
|
|
335 exists $splatbyname{$s} ? $splatbyname{$s} : -1;
|
|
336 }
|
|
337
|
|
338 sub splatname {
|
|
339 @_ == 1 or croak "Usage: splatname(SPLAT)";
|
|
340 my $s = shift;
|
|
341 exists $splats{$s} ? $splats{$s}[0] : undef;
|
|
342 }
|
|
343
|
|
344 sub splatdescription {
|
|
345 @_ >= 1 or croak "Usage: splatdescription(SPLAT, ARGS)";
|
|
346 my $s = shift;
|
|
347 $s %= 1000;
|
|
348 return 'Unknown splat code' if ! exists $splats{$s};
|
|
349 my $desc = $splats{$s}[1];
|
|
350 $desc =~ s/%/shift || '?'/ge;
|
|
351 $desc .= " (?" . join(' ', @_) . "?)" if @_;
|
|
352 sprintf("*%03d %s", $s, $desc);
|
|
353 }
|
|
354
|
|
355 1;
|
|
356
|
|
357 __END__
|
|
358
|
|
359 =pod
|
|
360
|
|
361 =head1 TITLE
|
|
362
|
|
363 Language::INTERCAL::Splats - errors
|
|
364
|
|
365 =head1 DESCRIPTION
|
|
366
|
|
367 Execution of I<CLC-INTERCAL> program can produce many errors, one of
|
|
368 the most common is attempting to execute a comment. Errors are
|
|
369 reported using a I<splat>, consisting of an error code and an error
|
|
370 message. The splat code is also available in the special expression
|
|
371 I<*> after the error occurred: this is only useful when the
|
|
372 program is multithreaded (another thread produced the splat) or
|
|
373 within events, as producing a splat is always fatal and causes the
|
|
374 program to terminate.
|
|
375
|
|
376 When printing a splat, the format will always be:
|
|
377
|
|
378 *nnn message
|
|
379
|
|
380 where nnn is the splat code. See file blib/htmldoc/errors.html in
|
|
381 the distribution build directory (or the corresponding page in the
|
|
382 online reference manual) for a list of splat codes.
|
|
383
|
|
384 =head1 SEE ALSO
|
|
385
|
|
386 A qualified psychiatrist
|
|
387
|
|
388 =head1 AUTHOR
|
|
389
|
|
390 Claudio Calvelli - intercal (whirlpool) sdf.lonestar.org
|
|
391 (Please include the word INTERLEAVING in the subject when emailing that
|
|
392 address, or the email may be ignored)
|
|
393
|