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 @@DATA Splats@@
|
|
14
|
|
15 use strict;
|
|
16 use vars qw($VERSION $PERVERSION);
|
|
17 ($VERSION) = ($PERVERSION = "CLC-INTERCAL/Base INTERCAL/Splats.pm 1.-94.-2") =~ /\s(\S+)$/;
|
|
18
|
|
19 use Carp;
|
|
20 use Language::INTERCAL::Exporter '1.-94.-2';
|
|
21 use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS);
|
|
22
|
|
23 @EXPORT_OK = qw(
|
|
24 splatnumber splatname splatdescription faint
|
|
25 @@FILL SPLATS 'SP_' NAME '' 76 ' '@@
|
|
26 );
|
|
27
|
|
28 %EXPORT_TAGS = (
|
|
29 SP => [qw(
|
|
30 faint
|
|
31 @@FILL SPLATS 'SP_' NAME '' 76 ' '@@
|
|
32 )],
|
|
33 );
|
|
34
|
|
35 my %splatbyname = (
|
|
36 @@ALL SPLATS NAME@@ => @@NUMBER@@,
|
|
37 );
|
|
38
|
|
39 my %splats = (
|
|
40 @@ALL SPLATS NUMBER@@ => ['@@NAME@@', '@@'DESCR'@@'],
|
|
41 );
|
|
42
|
|
43 sub SP_@@ALL SPLATS NAME@@ () { @@NUMBER@@ }
|
|
44
|
|
45 sub faint {
|
|
46 @_ >= 1 or croak "Usage: faint(NUM, ARGS)";
|
|
47 die splatdescription(@_) . "\n";
|
|
48 }
|
|
49
|
|
50 sub splatnumber {
|
|
51 @_ == 1 or croak "Usage: splatnumber(SPLATNAME)";
|
|
52 my $s = shift;
|
|
53 exists $splatbyname{$s} ? $splatbyname{$s} : -1;
|
|
54 }
|
|
55
|
|
56 sub splatname {
|
|
57 @_ == 1 or croak "Usage: splatname(SPLAT)";
|
|
58 my $s = shift;
|
|
59 exists $splats{$s} ? $splats{$s}[0] : undef;
|
|
60 }
|
|
61
|
|
62 sub splatdescription {
|
|
63 @_ >= 1 or croak "Usage: splatdescription(SPLAT, ARGS)";
|
|
64 my $s = shift;
|
|
65 $s %= 1000;
|
|
66 return 'Unknown splat code' if ! exists $splats{$s};
|
|
67 my $desc = $splats{$s}[1];
|
|
68 $desc =~ s/%/shift || '?'/ge;
|
|
69 $desc .= " (?" . join(' ', @_) . "?)" if @_;
|
|
70 sprintf("*%03d %s", $s, $desc);
|
|
71 }
|
|
72
|
|
73 1;
|
|
74
|
|
75 __END__
|
|
76
|
|
77 =pod
|
|
78
|
|
79 =head1 TITLE
|
|
80
|
|
81 Language::INTERCAL::Splats - errors
|
|
82
|
|
83 =head1 DESCRIPTION
|
|
84
|
|
85 Execution of I<CLC-INTERCAL> program can produce many errors, one of
|
|
86 the most common is attempting to execute a comment. Errors are
|
|
87 reported using a I<splat>, consisting of an error code and an error
|
|
88 message. The splat code is also available in the special expression
|
|
89 I<*> after the error occurred: this is only useful when the
|
|
90 program is multithreaded (another thread produced the splat) or
|
|
91 within events, as producing a splat is always fatal and causes the
|
|
92 program to terminate.
|
|
93
|
|
94 When printing a splat, the format will always be:
|
|
95
|
|
96 *nnn message
|
|
97
|
|
98 where nnn is the splat code. See file blib/htmldoc/errors.html in
|
|
99 the distribution build directory (or the corresponding page in the
|
|
100 online reference manual) for a list of splat codes.
|
|
101
|
|
102 =head1 SEE ALSO
|
|
103
|
|
104 A qualified psychiatrist
|
|
105
|
|
106 =head1 AUTHOR
|
|
107
|
|
108 Claudio Calvelli - intercal (whirlpool) sdf.lonestar.org
|
|
109 (Please include the word INTERLEAVING in the subject when emailing that
|
|
110 address, or the email may be ignored)
|
|
111
|