CLC-INTERCAL Reference

... The command-line compiler tool

Table of contents:

The command-line compiler tool

Starting from CLC-INTERCAL 1.-94, the preferred method to compile programs is to use the Integrated Programming Environment, sick (which stands for Superior INTERCAL Compiler Kluge or something like that). A program compatible with the old "oo, ick" is planned and will be made available if and when.

sick requires CLC-INTERCAL 1.-94 and newer. It won't work with older versions.

Although there are plans to provide some sort of interesting user interface to sick, at present it only works in batch mode, compiling programs using options specified on the command line, and either producing objects or running the program as soon as the compiler finishes.

The arguments on the command line are either options (in the form --name=value or -xvalue), or filenames. If a filename is encountered, it is immediately compiled with the options which precede it in the command line, and then optionally executed. After processing the command line, sick terminates.

Command-line options

There is a large number of command-line options, which are grouped by type for easy reference.

Source character set options

Before compiling a program, sick needs to know what character set has been used to encode the source. These days it's mostly ASCII but you never can tell. The default is --guess.

Long optionShortMeaning
--ascii-aASCII
--baudot-bExtended Baudot
--ebcdic-eNonstandard EBCDIC
--hollerith-hHollerith, straight from punched cards
--charset=NAMESelect a character set
--guess-gTry to guess looking at the program source

See the chapter about character sets for more information on supported character sets.

Compiler options

Once sick has loaded the source, and converted it to ASCII if necessary, it needs to compile it. This requires loading a compiler object and any necessary compiler options and extensions. This is done by specifying preloads, which, as the name suggests, are loaded before the program source. If no preloads are specified, sick attempts to guess the correct list of preloads by looking at the program suffix (or an alternative suffix specified on the command line).

Long optionShortMeaning
--include=DIR-IDIRAdd directory to search path for compiler objects
--nopreloadClears the list of preloads, reverting to the suffix-based guess
--preload=NAME-pNAMEAdd NAME to the list of preloads
--add-preload-AGuesses preloads by suffix, even if -p is specified
--suffix=SUFFIXIf using suffix-based guess, use SUFFIX instead of the source file's suffix
--imitate=WHOPretends to be a different compiler
--clc-intercalSame as --imitate=sick
--c-intercalSame as --imitate=ick
--intercal-72Same as --imitate=1972
--intercal-1972Same as --imitate=1972

By default, the compiler pretends to be itself, which means that the rules described here are valid; specifying --imitate causes the compiler to pretend it's somebody else, and use different rules, which will be described later. The default value can be requested explicitely with --imitate=sick or --clc-intercal

The suffix-based guessing of preloads relies on the the sickrc files found, which in turn depends on which extensions are installed, on which directories are specified with the --include option, and whether user and system sickrc files are considered: see Misc options below, and also see the sickrc specification). The defaults provided with the distributions will use the following table (if a suffix belongs to more than one row, it will use the first matching one):

SuffixPreloadsMeaning
.iacciaccCompiler source
.iasmasmCLC-INTERCAL assembler
.clcisickCLC-INTERCAL source
.clctisick, thickThreaded CLC-INTERCAL source
.tiick, thickThreaded INTERCAL source
.ciickC-INTERCAL source
.19721972Traditional INTERCAL source
.1972i1972Traditional INTERCAL source
.isickCLC-INTERCAL source

If the compiler is making an attempt of imitating C-INTERCAL, because you said --imitate=ick or --c-intercalM, the suffix rules will be:

SuffixPreloadsMeaning
.iacciaccCompiler source
.iasmasmCLC-INTERCAL assembler
.clcisickCLC-INTERCAL source
.clctisick, thickThreaded CLC-INTERCAL source
.tiick, thickThreaded INTERCAL source
.iickC-INTERCAL source
.19721972Traditional INTERCAL source
.1972i1972Traditional INTERCAL source

If the compiler is making an attempt of imitatind Traditional INTERCAL, because you said --imitate=1972, --intercal-72 or --intercal-1972, the suffix rules will be:

SuffixPreloadsMeaning
.iacciaccCompiler source
.iasmasmCLC-INTERCAL assembler
.clcisickCLC-INTERCAL source
.clctisick, thickThreaded CLC-INTERCAL source
.tiick, thickThreaded INTERCAL source
.i1972Traditional INTERCAL source
.19721972Traditional INTERCAL source
.1972i1972Traditional INTERCAL source

In addition to the above, extra letters can be present between the spot and the rest of the suffix, indicating extra preloads. Such extra letters can only be used with the ick or sick compilers, because 1972, iacc and iasm do not accept options or extensions.

LetterPreloadMeaning
22Change base to 2
33Change base to 3
44Change base to 4
55Change base to 5
66Change base to 6
77Change base to 7
bnon-blockingMake some statements non-blocking
dbitwise-divideSelect bitwise behaviour for unary divide
gcome-from-gerundEnable COME FROM gerund and NEXT FROM gerund
hclass-helpersLoad a special class with some useful lectures
lcomputed-labelsAllow computed statement labels
nnextAllow NEXT statements (sick only)
ssyscallEnable system call interface on label (666)
wwimpSet wimp mode as default for compiled program

If more than one base is specified, the first one matched by the sickrc files will be used: in the default, this is the highest base found on the suffix, so for example ".563i" means base 6.

CLC-INTERCAL 1.-94.-2 no longer includes the INTERNET extensions by default. When this extension is installed, an extra letter, "r" will be accepted in the suffix to preload it.

The "class-helpers" object, requested by adding a letter "h" to the suffix, contains class @65535 and a number of useful lectures. They are currently undocumented but the source is in "class-helpers.i" in the distribution.

Non-blocking operation affects WRITE IN and some system calls (if enabled); it also affects CASE, SMUGGLE and STEAL from the INET extension (if loaded). Before 1.-94.-1, all these statements blocked all threads until they completed, this option makes them block the current thread only while other threads can continue: it is the programmer's responsibility to avoid using the values produced by these statements before they are available, which is why the behaviour needs to be enabled explicitly when desired.

Not all these extra options are compatible with ick. See also the chapter about compiler extensions.

Normally, specifying any preloads on the command line disables the preload guess, which means that one might need to specify everything the guess would add. The --add-preloads (or -A) option asks to do the preload guess, then add to the result any preloads specified on the command line: it can be used, for example, to add threads support to sick: the ".ti" suffix would change the compiler to ick, but using -Apthick would use the normal preloads and then add thick. Consider the command:

    sick --add-preloads --preload=thick my-threaded-program.gi
The program being compiled here allows execution of COME FROM gerund statements (as requested by the "g" in the suffix) and additionally creates threads whenever a gerund listed in a COME FROM statement corresponds to more than one statement in the program. This document offers no opinion on whether this is a good idea.

Code generation options

Once the program source has been compiled, sick needs to use a module to generate the actual code. The default is Object, which produces an INTERCAL object, which can be executed directly or loaded back into sick as a preload.

Long optionShortMeaning
--nooptimiseDisable optimiser (default)
--optimise-OEnable optimiser
--backend=NAMES-lNAMESSelects one or more modules used to generate code
--listing=NAMES-LNAMESSelects one or more modules used to generate source listings
--output=NAME-oNAMEThe output file, defaults to the source file name with a new suffix
--name=NAME-nNAMEA name passed to the backend. Most backends don't use one
--directory=DIR-dDIRForces all outputs to go to DIR
--bug=NUMBERChange the probability of the compiler bug
--ubug=NUMBERChange the probability of the unexplainable compiler bug

The --backend option takes a comma-separated list of compiler back ends to run. The default is --backend=Object which saves the object to file using the default output file name or the value of any --output option in effect at that point. If more than one backend is specified, they will be executed in order, for example:


	sick --backend Run,Run,Object prog.i
Will compile "prog.i", run it twice, then save the object to "prog.io".

The --listing option takes a comma-separated list of source listing modules to run. The default is to produce no listings, and this can also be specified with the special value "none". For example, this produces both text and HTML listing of prog1,i but no listing of prog2.i:


	sick --listing text,html prog1.i --listing none prog2.i
(note that this is just an example, text listing is at present not supported).

Each module passed to --listing accepts a single argument, specified with an equal sign (=) following the module name, for example the "html" module accepts the name of a stylesheet to load, for example:


	sick --listing html=clc-intercal.css ...

Specifying the single name "help" for a backend will produce the list of all known backends without making any changes to the compile process. Similarly, specifying the single name "help" for a listing will produce the list of all known source listing modules without making any changes to what is actually produced.

The --output option recognises some special characters in the string passed to it: %p will be replaced by the name of the source file without the suffix and %o by the original name specified on the command line with the suffix removed: the difference is that when the compiler uses the search path to locate the program, %p could have a directory added to it to indicate where the source was found, while %o will be the name as typed. The %s sequence expands to a backend-supplied suffix, and %% is replaced by a single "%". The default is %p.%s. which means that the object is placed in the same directory where the source was found, but with a new suffix. To produce an executable without a suffix, specify "--output=%p"

If the --directory option is present, all objects are sent to that directory, even if the name produced by --output specifies a different directory.

The following backends are currently provided:

BackendSuffixMeaning
ListObject.ilstAssembler listing of the object
NoneNo-op: this can be used to avoid producing an object
Object.ioExecutable object
Perl.plPerl program
RunRun program immediately - does not save object

If an output file name is not specified with --output, the backend will generate a file name by appending its own suffix (shown in the table) to the base name of the source program. The table identifies backends which do not produce a file by showing an empty suffix for them,

If --directory is specified, it will replace the directory part on all output names. This works whether --output provides a name, or the backend's default is used. Specifying an empty string reinstates the default of using the source file's directory. Note that if --output specifies an absolute path, this will be used in the absence of a --directory but ignored if --directory is present.

Objects produced by the Object and Perl backends will accept the following command-line arguments when executed:

OptionMeaning
--nouserrcIgnore .sickrc files found
--nosystemrrcIgnore any files in /etc/sick
--rcfile=NAMEUses specified file instead of searching for files
--rcskip=VERBIgnores VERB when processing sickrc files
--traceEnable tracing for the object
--stdtrace=FILEEnable tracing and redirect tracing data to FILE
--notraceDisable tracing (default)
--wimpSelect wimp mode (default if the wimp object was preloaded)
--nowimpSelect normal mode (default if the wimp object was not preloaded)
--interpreter=NAMEUses an alternative CLC-INTERCAL Interpreter

Misc options

The following options control the way sick operates:

Long optionShortMeaning
--nouserrcIgnore .sickrc files found
--nosystemrrcIgnore any files in /etc/sick
--rcfile=NAME-rNAMEUses specified file instead of searching for files
--rcskip=VERB-RVERBIgnores VERB when processing sickrc files
--extension=NAMEMakes sure to load extension NAME
--rclistLists all .sickrc and system.sickrc files found, marking the ones which would be loaded based on other options
--stdverb=FILE-sFILESend verbose output to FILE
--verbose-vSend verbose outout to standard error
--quiet-qDo not produce verbose output (default)
--timesPrint compiler timing information on standard error
--notimesDo not print timing information (default)
--traceEnable tracing - this will trace the compiler, not the object
--stdtrace=FILEEnable tracing and redirect tracing data to FILE
--notraceDisable tracing (default)
--grammar-profileEnable profiling the compiler's grammar when compiling the object
--stdgrammar-profile=FILEEnable profiling the compiler's grammar and redirect profiling data to FILE
--nogrammar-profileDisable profiling the compiler's grammar (default)
--grammar-profile-max=NUMBERIf grammar profiling is enabled, limits the output to NUMBER lines
--grammar-profile-count=NUMBERIf grammar profiling is enabled, only outputs lines with count at least NUMBER
--grammar-profile-cost=NUMBERIf grammar profiling is enabled, only outputs lines with cost at least NUMBER
--interpreter=NAMEUses an alternative CLC-INTERCAL Interpreter

User interface options

At the time of writing, sick does not use any interface: it just gets its orders from the command line, does what it needs to do, and terminates. A future version may do more. In the meantime, there are a number of command-line options to select a user interface, but the selection is ignored.

Long optionShortMeaning
--graphic-XGTK-based graphical interface
--curses-cCurses-based text interface
--lineReadLine-based text interface
--batchBatch mode, no user interface (default)
--interface=NAME-iNAMELoad the specified interface

CLC-INTERCAL 1.-94.-2 no longer includes the user interfaces in the Base distribution: these are available as separate packages with name UI-Interface, for example UI-X, UI-Curses or UI-Line. This allows new interfaces to be developed and distributed separately.

Embedding INTERCAL in Perl source

Instead of calling sick from the command line, it is possible to just embed an INTERCAL program in Perl sources. The block of INTERCAL starts by loading the Language::INTERCAL module, and normally extends to the end of file. The generic syntax is:

	use Language::INTERCAL  [VERSION_REQUIRED,] OPTION => VALUE ...
Where each OPTION is a valid option to the sick command-line tool, or one of the options internally used by the compiler and not documented here. Additionally, there are three options provided by the module but not by the command-line tool: these options will be described below.

By default, the INTERCAL source starts immediately after the module has been loaded and extends to the end of file. For example, this programs will just produce "XLI" on standard read:


	#!/usr/bin/perl

	use Language::INTERCAL '1.-94.-2.2';
	DO READ OUT #42
	PLEASE GIVE UP

Adding option "debug" with a true value will show what the module is doing to your program by printing it to Perl's standard error.

Adding option "quick" with a true value loads the "sickrc" files in quick mode: this skips some checks, and is generally not recommended, but it may be necessary during testing if not all required modules are installed.

Option "escape" takes a compiled regular expression as argument and instructs the module to stop looking after any bit of source matching that regular expression. For example the following program produces "XLI" followed by "Back to perl":


	#!/usr/bin/perl -w

	use Language::INTERCAL
	    escape => qr/^\s*DO GET ME OUT OF HERE\s*$/m;

	DO .1 <- #42
	DO READ OUT .1
	DO GIVE UP
	DO GET ME OUT OF HERE

	print "Back to perl\n";
Note that the INTERCAL source must contain a GIVE UP, otherwise il will splat instead of going back to Perl.

Using the "escape" option it's possible to have multiple blocks of INTERCAL intereleaved with Perl, for example:


	#!/usr/bin/perl -w

	use Language::INTERCAL
	    escape => qr/^\s*DO GET ME OUT OF HERE\s*$/m;
	DO READ OUT #1
	DO GIVE UP
	DO GET ME OUT OF HERE

	print "Back to perl 1\n";

	use Language::INTERCAL
	    escape => qr/^\s*WE ARE HAVING FUN HERE\s*$/m;
	DO READ OUT #2
	DO GIVE UP
	WE ARE HAVING FUN HERE

	print "Back to perl 2\n";

	use Language::INTERCAL;
	DO READ OUT #3
	DO GIVE UP
This produces:
	I
	Back to perl 1
	II
	Back to perl 2
	III

Note that currently each block of INTERCAL is executed by its own independent interpreter, so that there is no communication between them; however a block running in a perl's loop will have all register values preserved across iterations. For example the program:

	#!/usr/bin/perl -w

	for my $i (1..5) {
	    print ".1 = ";
	    use Language::INTERCAL escape => qr/^\s*DO GET ME OUT OF HERE\s*$/m;
		(2) DO .2 <- #2 ~ .VVVVVVVVVVVVVVVV1
		(1) DO .1 <- #1
		    PLEASE COME FROM .2
		    DO .1 <- .1 ยข .1
		    PLEASE COME FROM (1)
		    DO READ OUT .1
		    DO GIVE UP
	    DO GET ME OUT OF HERE
	    print "i = $i\n";
	}
Will initialise register .1 to #1 the first time through the loop, subsequent iterations interleave .1 with itself instead, so the output is:
	.1 = I
	i = 1
	.1 = III
	i = 2
	.1 = XV
	i = 3
	.1 = CCLV
	i = 4
	.1 = lxvDXXXV
	i = 5

Since there is no filename, the module assumes that it is compiling a CLC-INTERCAL source with no special extensions; however, passing the "suffix" option will result in that being used to determine a set of preloads; or else, passing the "preload" option as many times as necessary will work the same as when running the command-line tool.

While most of sick's options will work the same as when provided on the command line, "backend" is ignored and the module will always use the "Run" backend.