/usr/bin/sick is in clc-intercal 1:1.0~4pre1.-94.-2-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | #!/usr/bin/perl -w
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
# Compiler/user interface/whatnot for CLC-INTERCAL
# This file is part of CLC-INTERCAL
# Copyright (c) 2006-2008 Claudio Calvelli, all rights reserved.
# CLC-INTERCAL is copyrighted software. However, permission to use, modify,
# and distribute it is granted provided that the conditions set out in the
# licence agreement are met. See files README and COPYING in the distribution.
require 5.005;
my $initial_times;
BEGIN { $initial_times = [time, times] }
use strict;
use Getopt::Long;
use vars qw($VERSION $PERVERSION);
($VERSION) = ($PERVERSION = "CLC-INTERCAL/Base bin/sick 1.-94.-2") =~ /\s(\S+)$/;
use Language::INTERCAL::Sick '1.-94.-2';
use Language::INTERCAL::GenericIO '1.-94.-2', qw($stdsplat);
use Language::INTERCAL::Rcfile '1.-94.-2';
use Language::INTERCAL::Interface '1.-94.-2';
$| = 1;
my $user_interface = '';
my $rclist = 0;
my $timehandle = 0;
my $rcfile = new Language::INTERCAL::Rcfile;
my $compiler = new Language::INTERCAL::Sick($rcfile);
if (defined &Getopt::Long::Configure) {
Getopt::Long::Configure qw(no_ignore_case auto_abbrev permute bundling);
} else {
$Getopt::Long::ignorecase = 0;
$Getopt::Long::autoabbrev = 1;
$Getopt::Long::order = $Getopt::Long::PERMUTE;
$Getopt::Long::bundling = 1;
}
my $setoption = sub { $compiler->setoption(@_) };
GetOptions(
# User Interface Options
'graphic|X' => sub { $user_interface = 'X' },
'curses|c' => sub { $user_interface = 'Curses' },
'line' => sub { $user_interface = 'Line' },
'batch' => sub { $user_interface = 'None' },
'interface|i=s' => \$user_interface,
# source character set options
'ascii|a' => sub { $compiler->setoption('charset', 'ASCII') },
'baudot|b' => sub { $compiler->setoption('charset', 'Baudot') },
'ebcdic|e' => sub { $compiler->setoption('charset', 'EBCDIC') },
'hollerith|h' => sub { $compiler->setoption('charset', 'Hollerith') },
'guess|g' => sub { $compiler->setoption('charset', '') },
'charset=s' => $setoption,
# code generation options
'optimise|O' => $setoption,
'nooptimise' => sub { $compiler->setoption('optimise', 0) },
'backend|l=s' => $setoption,
'bug=i' => $setoption,
'ubug=i' => $setoption,
'output|o=s' => $setoption,
'name|n=s' => $setoption,
'include|I=s' => sub { $rcfile->setoption(@_) },
'preload|p=s' => $setoption,
'nopreload' => sub { $compiler->clearoption('preload') },
'suffix=s' => $setoption,
# misc options
'nouserrc' => sub { $rcfile->setoption('nouserrc', 1) },
'rcfile|r=s' => sub { $rcfile->setoption(@_) },
'stdverb=s' => sub {
my ($opt, $file) = @_;
my $mode = $file =~ s/^([ra]),// ? lc($1) : 'r';
my $vh =
new Language::INTERCAL::GenericIO
('FILE', $mode, $file);
$compiler->setoption('verbose', $vh);
},
'verbose|v' => sub { $compiler->setoption('verbose', $stdsplat) },
'quiet|q' => sub { $compiler->setoption('verbose', 0) },
'rclist' => \$rclist,
'times' => sub { $timehandle = $stdsplat },
'notimes' => sub { $timehandle = 0 },
'stdtrace=s' => sub {
my ($opt, $file) = @_;
my $mode = $file =~ s/^([ra]),//i ? lc($1) : 'r';
my $th =
new Language::INTERCAL::GenericIO('FILE',
$mode,
$file);
$compiler->setoption('trace_fh', $th);
$compiler->setoption('trace', 1);
},
'trace' => sub { $compiler->setoption('trace', 1) },
'notrace' => sub { $compiler->setoption('trace', 0) },
# compile program
'<>' => sub { $compiler->source($_[0]); },
) or usage();
set_options();
my $server = Language::INTERCAL::Server->new();
$compiler->server($server);
my $now = printtimes($initial_times, "Time to start up");
$compiler->load_objects();
$now = printtimes($now, "Time to load objects");
if ($rclist) {
$compiler->save_objects(0);
printtimes($now, "Time to save objects");
printtimes($initial_times, "Total execution time");
print map { "$_\n" } @{$rcfile->getoption('rcfiles')};
exit 0;
}
# XXX sick has not yet been updated to work with interactive interfaces
#my $ui_obj = Language::INTERCAL::Interface->new($server,
# $user_interface,
# $rcfile->getitem('SPEAK'));
my $ui_obj = Language::INTERCAL::Interface->new(undef, 'None');
if (! $ui_obj->has_window) {
$compiler->save_objects(0);
printtimes($now, "Time to save objects");
printtimes($initial_times, "Total execution time");
exit 0;
}
$rcfile->run($ui_obj);
printtimes($now, "Time to set up rcfiles");
$ui_obj->run($compiler);
printtimes($initial_times, "Total execution time");
sub set_options {
$rcfile->load;
my $db = $rcfile->getitem('PRODUCE');
$compiler->setoption('default_backend', $db) if $db ne '';
$compiler->setoption('default_charset', $_)
for $rcfile->getitem('WRITE');
$compiler->setoption('default_suffix', $_)
for $rcfile->getitem('UNDERSTAND');
$compiler->setoption('default_extra', $_)
for $rcfile->getitem('UNDERSTAND ANYWHERE');
}
sub usage {
(my $p = $0) =~ s#^.*/##;
die "Usage: $p [-alphabet] files...\n";
}
sub printtimes {
return 0 unless $timehandle;
my ($prev, $title) = @_;
my @now = (time, times);
my $wall = $now[0] - $prev->[0];
my $user = $now[1] - $prev->[1];
my $system = $now[2] - $prev->[2];
for ($wall, $user, $system) {
if ($_ > 60) {
$_ = sprintf "%d:%05.2f", int($_ / 60), $_ - 60 * int($_ / 60)
} else {
$_ = sprintf "%.2f", $_;
}
}
$wall =~ s/\.00$//;
$timehandle->read_text("$title\: $wall (${user}u ${system}s)\n");
\@now;
}
__END__
=pod
=head1 NAME
sick - Compiler for CLC-INTERCAL
=head1 SYNOPSIS
B<sick> [options] B<files>...
=head1 DESCRIPTION
B<sick> is the main development environment for CLC-INTERCAL. If
files are specified, these will be compiled using the options in
effect at the point where they appear on the command line, and
they are compiled to objects (if they are not already object).
After all the options have been processed, the program enters
interactive mode, unless otherwise specified.
The program will be compiled using a compiler selected using command
line options; if nothing is selected, the compiler depends on the file
suffix:
=over 4
=item CLC-INTERCAL program source
These files must have suffix B<.i> or B<.clci>. These will be prefixed,
by default, with the compiler object I<sick.io>.
=item CLC-INTERCAL compiler source
These files must have suffix B<.iacc>. These will be prefixed, by default,
with the compiler object I<iacc.io> and produce a compiler object (which
can be executed as a program, but will do nothing - it's only useful as a
preload before compiling from source).
=item C-INTERCAL program source
These have suffix B<.ci> and will be prefixed with the compiler object
I<ick.io>.
=item CLC-INTERCAL assembler source
These have suffix B<.iasm> and will be prefixed with the compiler object
I<asm.io>.
=item Traditional INTERCAL program source
These will have suffix B<.1972> and will be prefixed with the compiler
object I<1972.io>
=item Compiler extensions
Suffixes B<.i>, B<.ci>, B<.clci> and B<.iasm> can contain a list of letters
and numbers between the spot (B<.>) and the rest of the suffix; these
select compiler extensions to be added.
=over 8
=item Base
Numbers between B<2> and B<7> change the default base by loading compiler
objects B<2.io> to B<7.io>.
=item Bitwise Divide
Letter B<d> in the suffix adds the compiler object I<bitwise-divide.io>,
which changes the normal unary divide operation to use bitwise, rather
than arithmetic, shifts. It can be used with I<sick> or I<iasm> but
not with I<ick>.
=item COME FROM gerund
Letter B<g> in the suffix adds the compiler object I<come-from-gerund.io>,
which enables the COME FROM gerund statements; since I<ick> does not parse
such statements, this letter can only be used with I<sick> or I<iasm>.
=item Computed labels
Letter B<l> in the suffix adds the compiler object I<computed-labels.io>,
which adds grammar rules to parse computed statement labels; this can
be used only with I<sick>.
=item NEXT
Letter B<n> in the suffix adds the compiler object I<next.io>,
which enables the NEXT statement in I<sick>; since I<ick> enables this
by default, this letter can only be used with I<sick>.
=item INTERcal NETworking
Letter B<r> in the suffix adds the compiler object I<internet.io>,
which adds syntax for the I<STEAL>, I<SMUGGLE> and I<CASE> statements;
it can be used with I<ick> or I<sick>.
=item System call
Letter B<s> in the suffix adds the compiler object I<syscall.io>, which hides
a "PLEASE NEXT FROM (666)" in a dark corner of your operating system.
=item Threaded program
Letter B<t> in the suffix selects threaded mode by loading compiler object
I<thick.io>. This also changes the default compiler to I<ick> if the suffix
is B<.i>: to use I<sick> one would use I<.tclci>.
=item Wimp mode
Letter B<w> in the suffix adds the compiler object I<wimp.io>, which causes
the program to start in wimp mode when it is executed. An equivalent result
can be obtained by passing the B<--wimp> option to the executable program.
=back
=back
The actual list of suffixes recognised can be changed by editing the file
F<system,sickrc> or F<.sickrc>. See the option B<--rcfile> for a discussion
on how and where B<sick> finds these files, and L<sickrc> for a description
of the file format.
If a preload file is specified on the command line, the defaults derived
from the suffix are not used. It is also possible to use default preloads
from a different file suffix by explicitely saying B<-suffix>=I<S> - in
this case, the compiler acts as if the file had name I<name.S>
In addition, compiler objects are always recognised, with whatever suffix.
These bypass the first compiler pass and jump directly to the runtime
(just-too-late) compiler. However, if the optimiser has been selected
when these objects were compiled, and there are no postprocessor statements,
the just-too-late compiler will be automatically replaced by a more
traditional "compile-time" compiler. If this is confusing, wait until
you see the rest.
If a file is specified without suffix, and there is a compiler object in the
include path with the same name and suffix B<.io>, the suffix is automatically
added, whether you wanted it or now.
As soon as each program is written into B<sick>, a pre-compiler will
produce an internal compiler object. If B<sick> enters interactive mode,
these objects will be available in memory for single-stepping, running,
or just ignoring completely and getting on with the real work.
If B<sick> loads all the required programs and objects successfully, but
does not enter interactive mode, any program source is read back out to
disk in object format, using the same file name with the suffix replaced
by B<.io> if no output file is specified. If a backend is specified in
the command line before a program is loaded, B<sick> will produce an
executable via that backend instead of an object.
The compiler accepts several options, some of which are documented here.
Options and files can be mixed in any order, each file is loaded and
compiled using whatever options precedes it on the command line. For
example:
sick --verbose --optimise prog1.i --quiet prog2.i --batch
will tell you everything about compiling I<prog1.i> but not about I<prog2.i>.
Both programs will be optimised. On the other hand:
sick --optimise prog1.i --nooptimise prog2.i --batch
will optimise I<prog1.i> but not I<prog2.i>.
All options can be "undone" (sometimes it's even clear how) except
B<--include> which applies to all objects loaded after it, and
B<--rcfile> which applies to all objects, even the ones loaded before
it (just to be different).
=head2 User Interface Options
=over 4
=item B<-X> / B<--graphic>
Enters X-based graphical user interface. Requires Perl-GTK. This is the
default if Perl-GTK is installed, the environment variable I<$DISPLAY> is
set and the opening of the X display succeeds.
=item B<-c> / B<--curses>
Enters full screen, curses-based interface. This is the default if the
X based interface cannot be started, the environment variable I<$TERM>
is set and the terminal name is known.
=item B<--line>
Enters the line-mode user interface. This is the default if the X based
and the curses based interfaces do not work.
=item B<--batch>
Avoids entering interactive mode. This is the default if the standard
input and output are not connected to a terminal and the X based interface
cannot be started.
=item B<-i>I<type> / B<--interface>=I<type>
Selects the user interface I<type>. Currently, only I<X>, I<Curses>,
I<Line> and I<None> are defined, but more can be installed as compiler
plug-ins. If the interface selected is I<None>, B<sick> will work in
batch mode. In addition, an empty string will reinstate the default
behaviour.
=back
=head2 Source Character Set Options
=over 4
=item B<-a> / B<--ascii>
Assumes that program source is in ASCII.
=item B<-b> / B<--baudot>
Assumes that program source is in Baudot.
=item B<-e> / B<--ebcdic>
Assumes that program source is in EBCDIC.
=item B<-h> / B<--hollerith>
Assumes that program source is in Hollerith.
=item B<-g> / B<--guess>
Does not make assumptions about the source character set. If the character
set cannot be guessed, will produce an error. This is the default.
=item B<--charset>=I<name>
Assumes that program source is in the given character sets. Valid values are
currently I<ASCII>, I<Baudot>, I<EBCDIC>, I<Hollerith>; an empty I<name> is
equivalent to specifying option B<--guess>).
=back
=head2 Code Generation Options
=over 4
=item B<-O> / B<--optimise>
Invokes the optimiser. This is a letter o, not a zero. This will cause the
extra object I<optimise.io> to be prefixed after the last compiler and
before the real program. The program is then executed: when the optimiser
takes control, it will force compilation of the rest of the program (thereby
executing the compiler at compile-time, instead of runtime as it normally
does), and the resulting object is checkpointed, so the next time it will
automatically skip the initialisation and compilation stages. In addition,
the "optimise" register is set, instructing the compiler to invoke the
optimiser when it runs.
If you specify B<-O> and B<-poptimise> (see below), you are asking for
trouble, so don't do that.
=item B<--nooptimise>
Disables automatic preloading and execution of I<optimise.io>.
=item B<-o>I<name> / B<--output>=I<name>
Selects a name for the output file. Some character sequences are recognised
inside I<name>: I<%p> will be replaced by the source program's basename;
I<%s> will be replaced by the appropriate suffix for the selected backend,
I<%o> will provide the original file name specified on the command line,
without suffix (this can differ from I<%s> because I<%s> can be prefixed
with a directory from the search path) and I<%%> will produce a single I<%>.
The default is I<%p.%s>, which produces the object name described at the
beginning of this document. A suffix is not automatically added if the
output name does not contain I<%s>; this might be useful in ocnjunction
with the I<Perl> backend to produce a file without a suffix, for example:
sick --output=%p --backend=Perl sourcefile.i
will compile I<sourcefile.i> and produce perl script I<sourcefile>.
If the output file is specified as an empty string, the code generation step
will never be done.
=item B<-n>I<name> / B<--name>=I<name>
Sets the program's I<name>, if the code generator requires it (currently,
no backends use a name, but some of the planned ones will). The default is
I<%o>. The same %-escapes as defined for the output file name are defined.
=item B<-l>I<name> / B<--backend>=I<name>
Selects a different compiler back end. The default is I<Object>, which
produces a compiler object (suffix I<.io>). The distribution also includes
a I<Perl> backend, which produces an executable Perl program (suffix I<.pl>).
In addition, the pseudo backend I<Run> will run the program instead of
writing any object. In this case, the output file name is ignored. Note
that the program will only run if the compiler is in batch mode.
Other back ends can be provided as compiler plug ins. The distribution
also contains a I<ListObject> backend, which does not produce executables
but object listings. A future version might allow to "compile" the output
of the I<ListObject> back end, but this is currently impossible because not
all the internal state of the object is provided, only the part which is
likely to be useful to a human reader.
=item B<--bug>=I<number>
Selects a different probability for the compiler bug. The compiler bug is
implemented by initialising the compiler's state with the required probability:
when a statement is compiled (usually at runtime), a "BUG" instruction is
emitted with the required probability. The default is 1%.
=item B<--ubug>=I<number>
Selects a probability for the unexplainable compiler bug. This is the compiler
bug which occurs when the probability of a (explainable) compiler bug is zero.
Only wimps would use this option. The default is 0.01%.
=item B<-p>I<name> / B<--preload>=I<name>
Selects a compiler object to prefix to the program. If this option is
specified, the compiler won't automatically prefix objects as suggested by
the suffix. The program B<'oo, ick'> included in previous version of
CLC-INTERCAL used option B<-p> to select a parser. Since the main use of
preloads is to select an alternative (runtime) compiler, it is felt that
it is appropriate to keep the same letter for this option.
The file name specified does not include the suffix F<.io>, which is
always added. The file must be a compiler object, not source code.
The special object I<optimise> should always loaded via B<-O>. Using
B<-poptimise> will not necessarily put the object in the correct place,
and will not instruct the precompiler to do whatever magic it needs to
do to bootstrap the optimiser.
To completely disable preloading (this is only done when compiling the
optimiser, which is used to compile itself) use an empty string.
=item B<--nopreload>
Resets the default behaviour of selecting preloads based on suffixes.
=item B<--suffix>=I<suffix>
Specifies a suffix to use when selecting preloads. If this option is
not specified, the suffix is taken from the file name to be compiled.
=item B<-I>I<path> / B<--include>=I<path>
Adds a directory before the standard search path for compiler objects
and source code. If a file is accessible from the current directory,
it is never searched in any include path.
If this option is repeated, the given paths will be searched in the
order given, followed by the standard paths.
=back
=head2 Misc Options
=over 4
=item B<-r>I<name> / B<--rcfile>=I<name>
Executes commands from file I<name> before entering interactive mode.
This option can be repeated, to execute more than one file. If it is
not specified, the standard library, the current directory, and the
current user's home directory are searched for files with name
F<system.sickrc> or F<.sickrc>, which are then executed. The order
for this search is: specified library (B<--include>), system library,
home directory, current directory. This is different from the search
order used when looking for objects or source code. If a directory
contains both F<.sickrc> and F<system.sickrc>, the F<system.sickrc>
is executed first, followed by F<.sickrc>. Also note that if the
current directory or the home directory appear in the search path
and contain one of these files, they will be executed twice.
If filenames are explicitely specified, they must be fully qualified:
the search path is not used to find them.
=item B<--nouserrc>
Prevents loading a user rcfile (.sickrc); also limits loading of
system.sickrc to the first one found. This option is normally only
used during installation, to prevent interference from previous
versions of CLC-INTERCAL.
=item B<-v> / B<--verbose>
Tells everything it's doing (on Standard Error).
=item B<--stdverb>=I<file>
Sends verbose output to I<file>.
=item B<--trace>
Enables tracing; if compiling from source, the compiler is also
traced; to trace a program, compile it to an object and then run
it with B<--trace>.
=item B<--stdtrace>=I<file>
Enables tracing and selects an output file for the trace information.
=item B<--notrace>
Disables tracing; preloading I<trace.io> has priority over this option.
=item B<-q> / B<--quiet>
Stop talking to Standard Error.
=item B<--times>
Prints a summary of the time take for each major action. This setting is
independent of B<--verbose>.
=item B<--notimes>
Does not print execution times: this is the default.
=item B<--rclist>
Prints the names of all rcfiles found. It prevents starting interactive mode.
For example, the following command (which should work with I<any> Unix shell)
opens all the system and user sickrc files in your favourite editor:
sh -c '"${EDITOR:-vi}" "`sick --rclist`"'
This can be useful to update the defaults.
=back
=head1 BUGS
There are more options than ls(1). This is construed to be a feature.
=head1 SEE ALSO
The INTERCAL on-line documentation, by entering B<sick>'s interactive mode
and finding the "help" menu (X), key (Curses) or command (Line).
|