Table of contents:
This section will be left blank until somebody volunteers to write it.
INTERCAL enjoys a very simple and regular syntax. The input file is
completely free format. The whole program can bein one (very long) line,
or a newline can be inserted anywhere a space is permitted. There is
no need for a special statement termination symbol (like the hybrid
(;
) used by C, Perl, Java, and other languages). Instead,
a statement simply ends when the next one starts.
Whitespace is allowed almost anywhere. The only exception is inside keywords (so IGNORE cannot be written IG NORE) and numbers (so #65535 is not the same as #655 35). However, if a keyword already contains a space (like COME FROM), more can be added to keep it company, or the lone space can be removed.
Note that a future version of CLC-INTERCAL plans to embed a Whitespace compiler inside the standard compiler. When that is done, whitespace will be still ignored by the standard compiler, but it will have a new meaning. We'll change this chapter as necessary when we do that.
A statement consists of up to five fields; only the second and fifth are required, the rest being optional. When the compiler is looking for the start of a statement, it will look for anything which resembles the contents of the first or the second field and take it from there. The five fields are:
¬
(this is the symbol for logical negation, if the
character set is ISO-8859-1). See the discussion on ABSTAIN FROM in
the chapter about Statements.
%
) followed by an expression. Before executing the statement,
the value is calculated: if it is 100 or over, the statement is executed.
Otherwise, the statement might or might not be executed, and the
probability of executing it is the value of the expression. For
compatibility with INTERCAL-72, which only accepted constant probabilities,
constants can be written without the leading "#", i.e. "%#50" can be
written simply "%50".
For example, all the following statements are equivalent when executed:
DON'T PANIC
PLEASE DO NOT PANIC
PLEASE ¬ PANIC
DO¬PANIC
DONOTPANIC
As an aside, the above is a useful "no operation" statement which you might want to know about. It does nothing, so it can't do any more damage than the rest of the program already does. It can be REINSTATEd, though, so you might end up executing it which will print DON'T PANIC on the terminal and exit - this might also be useful.